?
Solved

New Java code isn't seen at run time.  Still see "old code"

Posted on 2005-04-22
5
Medium Priority
?
176 Views
Last Modified: 2010-03-31
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.
0
Comment
Question by:sgenoves116
  • 4
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13846097
Probably 'cos you're running the old code ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13846104
When i've had this before, i've put this as the first line of main:

System.out.println("This is the NEW code");
0
 

Author Comment

by:sgenoves116
ID: 13846431
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(this);
     
   
     
     // when the window is closed, exit the program
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
     
     frame.getContentPane().add(BorderLayout.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
     
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 13846554
You're not running the go() of OpenGui4

>>SimpleGui1 gui = new SimpleGui1();

should be

OpenGui4  gui = new  OpenGui4();
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13846598
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question