Results 1 to 4 of 4
  1. #1
    seemant.bisht is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Question GUI is visible but content is not.

    :confused:
    I have two java classes extending JFrame: HTTPServer.java and Welcome.java. When I run HTTPServer.java with placing public static void main in it. It shows me the perfect GUI with all its content like button,table, etc. But when I call the object of HTTPServer within new ActionListener() in Welcome.java. It is not showing the content within GUI as it is showing the GUI only.
    Java Code:
    	    ActionListener actionListener = new ActionListener() {
    	    	public void actionPerformed(ActionEvent actionEvent) {
    	    		String command = actionEvent.getActionCommand();
    	    		if(command == "Commit"){
    	    			add(mainPanel, BorderLayout.EAST);	
    	    			int j = 0;
    	    			while(selectedServers[j] != -1){	    				
    	    				System.out.println(serverOptions[selectedServers[j]] + " ");
    	    				j++;
    	    				}
    	    			new HTTPServerSim();
    	    			}
    	    		if(command == "Reset")
    	    			serverList.clearSelection();
    	    		if(command == "Cancel")
    	    			System.exit(0);
    	    		}
    	    	};
    Both the java files are within same package.Please help as Iam stuck becoz of this.
    Last edited by Fubarable; 10-07-2009 at 06:24 PM. Reason: Code tags added

  2. #2
    Hugo is offline Member
    Join Date
    Oct 2009
    Posts
    16
    Rep Power
    0

    Default GUI Not Showing

    Is it the content of the HTTPServerSim() class that is not showing?

    Not sure if this will help, but you can try calling the following two methods at the end of HTTPServerSim's constructor:

    this.repaint();
    this.validate();

    Good luck

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    paste the main code and ask.
    Ramya:cool:

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I added code tags to your original post to help make it readable. I've got a concern here:
    Java Code:
    if(command == "Commit"){
    While this probably has nothing to do with your current problem (and I'm suspecting a threading issue here but can't tell based in info provided), you will rarely want to compare Strings with == or !=, but rather would usually want to use the equals or equalsIgnoreCase methods, i.e.,
    Java Code:
    if(command.equals("Commit")) {

Similar Threads

  1. Replies: 2
    Last Post: 05-30-2009, 10:42 AM
  2. JTextField not visible?
    By McChill in forum New To Java
    Replies: 2
    Last Post: 05-20-2009, 12:17 AM
  3. Text are not visible in GUI
    By VinTiger in forum New To Java
    Replies: 5
    Last Post: 05-15-2009, 08:14 AM
  4. Tab or Table not visible
    By madhuvanthi2312 in forum SWT / JFace
    Replies: 1
    Last Post: 04-25-2009, 09:00 AM
  5. constructor ... is not visible
    By emceenugget in forum New To Java
    Replies: 2
    Last Post: 09-27-2008, 05:12 AM

Posting Permissions

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