
January 3rd, 2013, 07:17 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 2
Time spent in forums: 9 m 57 sec
Reputation Power: 0
|
|
|
Setting a button to run a constructor?
Hi!
I am new here, and have a simple question
say I had a simple jframe and button:
Code:
public static void main(String[] args){
JFrame frame = new JFrame();
frame.setSize(new Dimension(800, 600));
frame.setVisible(true);
frame.setLocationRelativeTo(null);
JButton button = new JButton();
button.setSize(new Dimension(100 ,100));
button.setLocation(5,5);
button.setVisible(true);
frame.getContentPane().add(button);
}
How would I make button run a certain constructor?
also, can it run one that is in a different class?
|