sgenoves116
asked on
New Java code isn't seen at run time. Still see "old code"
I built a small swing program that displays a button and using an ActionEvent changes the button text from "click me" to "I've been clicked". I then decided to delete *all* button code and associated ActionEvent and add a JTextField instead. It complies fine, but when I run it, I still get the button and the ActionEvent behaviour. I made sure I saved my edits and am at a loss why I still get the old code behaviour.
Probably 'cos you're running the old code ;-)
When i've had this before, i've put this as the first line of main:
System.out.println("This is the NEW code");
System.out.println("This is the NEW code");
ASKER
Here's the code. I added the println and do see "This is the NEW code" in the command window, but still get the button instead of my textfield. I'm using javac/java on the command line, no IDEs.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class OpenGui4 {
public static void main (String[] args) {
SimpleGui1 gui = new SimpleGui1();
System.out.println("This is the NEW code");
gui.go();
}
public void go() {
//create a frame
JFrame frame = new JFrame();
JTextField Tfield = new JTextField(20);
// Tfield.addActionListener(t his);
// when the window is closed, exit the program
frame.setDefaultCloseOpera tion(JFram e.EXIT_ON_ CLOSE);
frame.getContentPane().add (BorderLay out.EAST, Tfield);
//set the size, in pixels of the frame
frame.setSize(500,500);
// make frame visible
frame.setVisible(true);
Tfield.requestFocus();
} // end of go method
} //end of class
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class OpenGui4 {
public static void main (String[] args) {
SimpleGui1 gui = new SimpleGui1();
System.out.println("This is the NEW code");
gui.go();
}
public void go() {
//create a frame
JFrame frame = new JFrame();
JTextField Tfield = new JTextField(20);
// Tfield.addActionListener(t
// when the window is closed, exit the program
frame.setDefaultCloseOpera
frame.getContentPane().add
//set the size, in pixels of the frame
frame.setSize(500,500);
// make frame visible
frame.setVisible(true);
Tfield.requestFocus();
} // end of go method
} //end of class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)