import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
class BigB extends JButton {
BigB(String label) {
super(label);
}
public Dimension getPreferredSize() {
Dimension oyaD = super.getPreferredSize();
return new Dimension(oyaD.width * 2, oyaD.height * 2);
}
}
public class FirstGUI implements ActionListener {
static JFrame parent;
public static void main(String[] args) {
JFrame jf = new JFrame("FirstGUI");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
parent = jf;
JButton jb = new BigB("BigSize asfdasdfasdf sdf");// JButton("Button");
jf.getContentPane().add(jb);
jf.getContentPane().add(new JButton("2nd Button"), BorderLayout.SOUTH);
jb.addActionListener(new FirstGUI());
jf.setSize(300, 300);
jf.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
parent.pack();
}
}