JLabel.setVisible(false) make other components' position change
I meet a relayout problem that is in my swing application I add four components (two JLabels, one JTextField and one table, each occupies one row) to a panel by using GridBagLayout, for some logic, I need to make one label visible true or false based on some conditions, but when I invoke setVisible(false) the components below this label will come up a little and when I invoke setVisible(true) they come down a l开发者_Python百科ittle which makes the GUI flashing. Are there any methods which can make other components stick on the panel? Thanks.
Instead of setting the label visible or not, you could just change the text between the default and ""
. The Label would still stack the same height but no text would be visible.
How about TableLayout with fixed columns and rows?
精彩评论