This is my program so far:
It complies an runs, but the textfield ends up being as big as the entire frame, and when I click the button, nothing happens.
import java.awt.event.*; import java.applet.*; import java.awt.*; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; public class ButtonStart extends Frame { private int mouseclicked=0; TextField objTextField; public static void main(String args[]) { ButtonStart BS= new ButtonStart(); } public ButtonStart() { Frame objFrame; Button objButton; TextField objTextField; objFrame=new Frame("Clicking Buttons"); objButton= new Button("Click me!"); objTextField= new TextField("0"); objTextField.setBounds(90, 50, 100, 100); objButton.setBounds(10, 30, 60, 60); objFrame.addMouseListener(new MyMouseListener()); objFrame.setSize(300,300); objFrame.setVisible(true); objFrame.add(objButton); objFrame.add(objTextField); objFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); } public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent me) { int mouseclicked= me.getClickCount(); objTextField.setText("Mouse clicked this many times:" + mouseclicked ); } } }
Anyone have any idea of how I could make this program work? Thanks!