java gui放大_Java GUI自动调整大小

这里是绘制GUI的地方(注意,这个类扩展了JFrame)。

public Cache() {

SubstanceColorChooserUI col = new SubstanceColorChooserUI();

while (mode == 0);

setResizable(false);

setTitle("Cache");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100, 100, 483, 374);

setLocationRelativeTo(null);

contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);

contentPane.setLayout(new BorderLayout());

textField = new JTextField();

textField.setBounds(10, 11, 328, 20);

contentPane.add(textField);

textField.setColumns(10);

JButton btnLoadCache = new JButton("Load cache");

btnLoadCache.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

try {

String loc = textField.getText();

if (loc.equals("")) {

JOptionPane.showMessageDialog(Cache.this, "Please specify a location for the cache.", "Unable to load", JOptionPane.ERROR_MESSAGE);

return;

}

if (!loc.endsWith("\\"))

loc = loc + "\\";

cache = new Store(loc);

loadImages();

} catch (Exception e) {

JOptionPane.showMessageDialog(Cache.this, "Cache failed to initialize.\n" + e.getMessage(), "Unable to load", JOptionPane.ERROR_MESSAGE);

}

}

});

btnLoadCache.setBounds(351, 9, 112, 23);

contentPane.add(btnLoadCache);

JSplitPane splitPane = new JSplitPane();

splitPane.setDividerLocation(150);

splitPane.setContinuousLayout(true);

splitPane.setBounds(10, 44, 453, 279);

contentPane.add(splitPane);

JPanel panellie = new JPanel();

panellie.setLayout(new BorderLayout(0, 0));

panel = new ImagePanel(null);

scrollPane_1 = new JScrollPane();

panellie.add(scrollPane_1, "Center");

scrollPane_1.setViewportView(panel);

splitPane.setRightComponent(panellie);

JPanel panel_1 = new JPanel();

splitPane.setLeftComponent(panel_1);

panel_1.setLayout(new BorderLayout(0, 0));

JScrollPane scrollPane = new JScrollPane();

panel_1.add(scrollPane, BorderLayout.CENTER);

model = new DefaultListModel();

list = new JList(model);

list.addListSelectionListener(new ListSelectionListener() {

public void valueChanged(ListSelectionEvent arg0) {

if (arg0.getValueIsAdjusting())

return;

ListedImage img = list.getModel().getElementAt(list.getSelectedIndex());

panel.setImage(img.getImage());

}

});

scrollPane.setViewportView(list);

progressBar = new JProgressBar();

progressBar.setStringPainted(true);

progressBar.setDoubleBuffered(true);

progressBar.setBounds(10, 328, 453, 14);

contentPane.add(progressBar);

}我怎么做到这一点,所以当我setResizeable为真,我开始拖动程序越来越小,我怎么做,使框架内的组件(按钮,标签等)调整整个框架调整大小时

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值