JButton does not work in java swing
I am working on Java swings. I have a case wherein I have a JButton present inside a JTable.
I have also written a ButtonRenderer for the same.The problem is that whenever I place i click on the JButton created it does not open anything,the window remains still and nothing happens.
How could I get rid of this.please help.
Re: JButton does not work in java swing
Code:
button.setOpaque(false);
button.setFocusPainted(false);
button.setBorderPainted(false);
button.setContentAreaFilled(false);
setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
setBorder(null) might work, but there is a bug sun explaining it is by design that the UI set a border on a component unless the client sets a non-null border which does not implement the UIResource interface.
Rather than the JDK itself setting the border to an EmptyBorder when null is passed in, the clients should set an EmptyBorder themselves (a very easy workaround). That way there is no confusion about who's doing what in the code.
Re: JButton does not work in java swing
It is on the frame but you are not working with it. You need to call the setVisible(false) to the Frame which is shown and not to the just created one.
Re: JButton does not work in java swing
You need to write a cell editor in addition to the cell renderer. If you're not using a cell editor for the cell with the button, I don't see how that could be.