I was just wondering how (and if) this is possible. I read somewhere about an ActionEvent with resize window(int, int) but I wasn't sure if that was an appropriate way to handle it.
Edit: sorry this is in an GUI interface set up by JPanel
解决方案
public static void main(String[] args) {
final JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Click Me");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setSize(200, 200);
}
});
frame.add(panel);
panel.add(button);
frame.pack();
frame.setVisible(true);
}