开发者

JLabel.setVisible(false) make other components' position change

开发者 https://www.devze.com 2023-03-13 00:09 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消