Results 1 to 8 of 8
  1. #1
    aianta is offline Member
    Join Date
    Apr 2011
    Posts
    63
    Rep Power
    0

    Default Old gui showing instead of new gui code

    Now, I think I'm on the verge of going crazy because something very weird is happening. I had an old gui design which was very rudimentary, and I wanted to replace it with something cleaner. So I used my newly installed GUI design plugin in eclipse and designed a nice neat new gui. Then I migrated the old gui functionality to the new gui. I removed references to the old gui from the main execution thread and then ran the application only to find my old gui design sill being used by the application.

    After trying repeatedly to see if there was any remaining reference to the old gui I finally erased the old gui code all together. But it would appear that just to spit in my face life decided to sill use my old gui.

    So can anyone tell me why my old gui won't go away?

    old gui: (I do realize there is a misspelling in the windows title, ill fix that soon)

    Old gui showing instead of new gui code-old_gui.jpg

    new gui: (from design plugin preview)
    Old gui showing instead of new gui code-new_gui.jpg

    Execute.java

    Java Code:
    import javax.swing.JFrame;
    
    
    public class Execute {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    		//Store the sentence to be examined
    		String sentence [] = {"The","cat","ran"};
    		
    		//Initialize a new Word Manager
    		WordManager test = new WordManager (3);
    		
    		//Initialize a new Action Module
    		Actions testAction = new Actions();
    		
    		//For each word in the sentence to be examined create a word 
    		for (int i = 0; i< sentence.length; i++){
    			
    			Word word = new Word(sentence[i],test);
    		}
    		
    		//Get the words that were added in the previous loop
    		for (int i = 0; i < test.getWords().length; i++){
    			//Print out each word.
    			System.out.println(test.getWords()[i].getName());
    		}
    		
    		MainApplicationWindow gui = new MainApplicationWindow (test);
    		
    		gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		gui.setVisible(true);
    	
    	}
    
    }
    new gui code:

    Java Code:
    
    import java.awt.event.ActionEvent;
    
    public class MainApplicationWindow extends JFrame {
    
    	private JPanel contentPane;
    	private JPanel wordPanel;
    	private JComboBox selectColor;
    	private JComboBox selectWord;
    	private JButton button;
    	private WordManager manager;
    	
    	Actions action = new Actions();
    	/**
    	 * Create the frame.
    	 */
    	public MainApplicationWindow(WordManager manager) {
    		
    		super ("Algorithm Analyser 0.1");
    		this.manager = manager;
    		this.setLayout(null);
    		
    		setBounds(100, 100, 450, 156);
    		contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		setContentPane(contentPane);
    		contentPane.setLayout(null);
    		
    		wordPanel = action.getWordPanel(manager);
    		wordPanel.setBounds(10, 11, 414, 59);
    		contentPane.add(wordPanel);
    		
    		SelectListener handler = new SelectListener ();
    		
    		selectWord = new JComboBox(manager.getWordNames());
    		selectWord.setSelectedIndex(0);
    		selectWord.setBounds(10, 81, 93, 20);
    		selectWord.addActionListener(handler);
    		contentPane.add(selectWord);
    		
    		selectColor = new JComboBox(action.getColorNames());
    		selectColor.setSelectedIndex(0);
    		selectColor.addActionListener(handler);
    		selectColor.setBounds(113, 81, 93, 20);
    		contentPane.add(selectColor);
    		
    		button = new JButton ("Submit");
    		button.setBounds(216, 81, 89, 23);
    		button.addActionListener(handler);
    		contentPane.add(button);
    
    	}
    	
    	//Begin action listener
    	private class SelectListener implements  ActionListener  {
    		
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    			//When Submit button is pressed get the word and the colour then change them appropriately
    			if (e.getActionCommand() == "Submit"){
    	
    				action.ChangeColor(manager.getWords()[selectWord.getSelectedIndex()],
    						action.getColors()[selectColor.getSelectedIndex()]);
    
    				
    			}
    			
    		}
    	}
    
    }
    old gui code:


    Java Code:
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    
    public class GUI extends JFrame {
    	
    	//ComboBox for choosing the colour
    	private JComboBox SelectColor;
    	
    	//ComboBox for choosing the word
    	private JComboBox SelectWord;
    	
    	//Submit button to confirm colour and word
    	private JButton Button;
    	
    	//Word manager to deal with the handling of words
    	private WordManager manager;
    	
    	//Action manager to deal with actions
    	Actions action = new Actions();
    	
    	public GUI (WordManager manager){
    		
    		//Title of the GUI
    		super ("Algorithm Analyser 0.1");
    		
    		//Initialise layout
    		this.setLayout(new FlowLayout());
    		
    		//set manager
    		this.manager = manager;
    		
    		//Add the words to the GUI
    		for (int i = 0; i < manager.getWords().length; i++){
    			
    			this.add(manager.getWords()[i].getLabel());
    		}
    		
    		//Initialise event handler
    		SelectListener handler = new SelectListener ();
    		
    		//Create and setup combobox for the words
    		SelectWord = new JComboBox(manager.getWordNames());
    		SelectWord.setSelectedIndex(0);
    		SelectWord.addActionListener(handler);
    		this.add(SelectWord);
    		
    		//Create and setup combobox for the colours
    		SelectColor = new JComboBox(action.getColorNames());
    		SelectColor.setSelectedIndex(0);
    		SelectColor.addActionListener(handler);
    		this.add(SelectColor);
    		
    		//Create and setup Submit button
    	    Button = new JButton ("Submit");
    		Button.addActionListener(handler);
    		this.add(Button);
    			
    		}
    	
    	//Begin action listener
    	private class SelectListener implements  ActionListener  {
    		
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    			//When Submit button is pressed get the word and the colour then change them appropriately
    			if (e.getActionCommand() == "Submit"){
    	
    				action.ChangeColor(manager.getWords()[SelectWord.getSelectedIndex()],
    						action.getColors()[SelectColor.getSelectedIndex()]);
    
    				
    			}
    			
    		}
    	}
    
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: Old gui showing instead of new gui code

    Not sure what your problem is. If you remove all references to the old classes from your code and remove all definitions for the old classes from your PC, how can the old versions of the programs come back?
    The only answer is that somewhere there is still a version of the old code.

    What is the purpose of your posted code? What does it show?

  3. #3
    aianta is offline Member
    Join Date
    Apr 2011
    Posts
    63
    Rep Power
    0

    Default Re: Old gui showing instead of new gui code

    Execute.java is my main class it runs the program and as you can see there is no reference there to GUI.java (which is my old GUI code) instead there is a reference to MainApplicationWindow.java (my new gui code) however despite this when I run Execute.java the old gui shows.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: Old gui showing instead of new gui code

    Does the new GUI sure the same Strings as the old GUI?
    Change them to see what code is being used.

  5. #5
    aianta is offline Member
    Join Date
    Apr 2011
    Posts
    63
    Rep Power
    0

    Default Re: Old gui showing instead of new gui code

    Well, this is interesting, I changed the strings in Execute.java and found that the old gui shows, with "The cat ran" even though I changed the strings. I suppose I should also mention that I am using Subversion with eclipse to manage this project, I don't know if that helps but I could erase all local copies and grab another copy of the files from my local server.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: Old gui showing instead of new gui code

    Sounds like your IDE is in control. Did you pay your monthly fees?
    Good luck.

  7. #7
    aianta is offline Member
    Join Date
    Apr 2011
    Posts
    63
    Rep Power
    0

    Default Re: Old gui showing instead of new gui code

    Good god! Skynet, the machines are rising :(

  8. #8
    aianta is offline Member
    Join Date
    Apr 2011
    Posts
    63
    Rep Power
    0

    Default Re: Old gui showing instead of new gui code

    Ok well, I found the culprit, it has something to do with my SVN since I moved all the files to another java project and everything worked through the new gui. Now however I have to deal with a faulty svn :/

Similar Threads

  1. Image not showing up!!
    By ThrashingBoy in forum New To Java
    Replies: 1
    Last Post: 11-08-2010, 10:22 PM
  2. Table not showing up
    By dilpreet28 in forum New To Java
    Replies: 3
    Last Post: 08-04-2010, 07:05 AM
  3. Replies: 1
    Last Post: 03-30-2010, 09:23 PM
  4. Showing
    By bostonstate in forum New To Java
    Replies: 3
    Last Post: 08-25-2008, 07:49 PM
  5. Why isn't this showing?
    By JToolTip in forum Java Applets
    Replies: 2
    Last Post: 07-07-2007, 11:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •