将JLabel设置为窗口的百分比

时间:2014-04-01 18:01:09

标签: java swing jlabel layout-manager dimensions

我有一个JLabel我希望将高度和宽度都设置为JFrame的百分比,比如说10%。如何在Java中实现这一目标?我有JLabel名称外观和JFrame命名屏幕

JFrame screen = new JFrame("Example");

...

JPanel lookReplyGUIPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
JLabel lookx = new JLabel("something");
c.gridx = x+1;
c.gridy = y+1;     
lookReplyGUIPanel.add(lookx,c);

谢谢!所有帮助赞赏

0 个答案:

没有答案