Pink Poogle Toy Forum

The official community of Pink Poogle Toy
Main Site
NeoDex
It is currently Wed Apr 24, 2024 5:07 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Java Help Needed
PostPosted: Thu Nov 02, 2006 5:20 pm 
PPT Warrior
PPT Warrior
User avatar

Posts: 765
Joined: Thu Jun 17, 2004 1:28 pm
Location: Among the crayons on my desk..
I'm redoing a textbased Computer Aided Instruction program I created last year. The thing is, my teacher wants the program with a GUI. I'm not doing it as an applet, but with AWT and Swing. So basically, a standalone program.

I just dived right into graphics, so I'm basically drawing from textbook info and previous knowledge I had on Java, C++ and OOProg. So please excuse the bad code.

The problem is this. The main goal (for me anyways) is to keep the program to ONE window. That means that in the start window (say, the menu) I click a button, the window is supposed to clear and show me a completely different interface. The action passes right into the ActionListener, and works right until after repaint(); After removing previous panels and repainting, I try to add new panels. Except, it doesn't work.

Thoughts? Suggestions? Help? Anything is appreciated.

You'll notice that I tried several methods (via commenting out). I also didn't put comments regarding what each part was supposed to do, so if you don't understand what my purpose was supposed to be, please ask.

Here are the links:

http://www.geocities.com/whitemagicdesi ... troyer.txt
http://www.geocities.com/whitemagicdesi ... oveAll.txt


Image
. Set by Medusa ♥


Last edited by ArwenEarendil on Fri Nov 03, 2006 5:40 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 1:43 am 
Honorary Member
Honorary Member

Posts: 731
Joined: Tue Jun 01, 2004 3:26 pm
I believe I know what you're trying to do. Out of curiosity, are you using a Container?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 5:42 pm 
PPT Warrior
PPT Warrior
User avatar

Posts: 765
Joined: Thu Jun 17, 2004 1:28 pm
Location: Among the crayons on my desk..
Universal Senja wrote:
I believe I know what you're trying to do. Out of curiosity, are you using a Container?


Yes. However, I just looked at my previous post (I was in a rush yesterday) and I posted the same link. -_-; That has been corrected now. The main file is TestRemoveAll.txt

In the ActionListener, this is what happens:

Code:
contentPane.removeAll(); //or contentPane.remove(Component component)
repaint(); //works right up to here
contentPane.add(Component component); //doesn't work


In my mind, this works, but it's probably wrong. If I compile the project, I just get a blank window after the object is passed to the ActionListener.


Image
. Set by Medusa ♥


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 1:46 am 
Honorary Member
Honorary Member

Posts: 731
Joined: Tue Jun 01, 2004 3:26 pm
Just letting you know I haven't forgotten about this. I've been pretty busy myself and haven't really found a nice block of time yet. Is there a due date or a day you'll need this done by?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 5:16 pm 
PPT Warrior
PPT Warrior
User avatar

Posts: 765
Joined: Thu Jun 17, 2004 1:28 pm
Location: Among the crayons on my desk..
I have until January-February.. which is really a lot of time for the project. My only obstacle right now is this.


Image
. Set by Medusa ♥


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 4:49 am 
Honorary Member
Honorary Member

Posts: 731
Joined: Tue Jun 01, 2004 3:26 pm
Ok, I think I might have it. On line 83 where you have a repaint(), change that to contentPane.validate();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 6:03 pm 
PPT Warrior
PPT Warrior
User avatar

Posts: 765
Joined: Thu Jun 17, 2004 1:28 pm
Location: Among the crayons on my desk..
*glomps*

IT WORKS!

By itself, it didn't work.. if froze after a while. But I did a combo of repaint() and contentPane.validate(); and it works! Thank you! ^_^

So this is what the ActionListener looked like in the end:

Code:
public void actionPerformed (ActionEvent e)
  {
    Container contentPane = getContentPane();
   
    if (e.getActionCommand().equals("Clear"))
    {
      contentPane.remove(buttonPanel);
      contentPane.remove(textPanel);
      repaint();
      contentPane.add(textPanel2, BorderLayout.CENTER);
      contentPane.add(buttonPanel2, BorderLayout.SOUTH);
      contentPane.validate();
    }
    else if(e.getActionCommand().equals("Return"))
    {
      contentPane.remove(textPanel2);
      contentPane.remove(buttonPanel2);
      repaint();
      contentPane.add(textPanel, BorderLayout.CENTER);
      contentPane.add(buttonPanel, BorderLayout.SOUTH);
      contentPane.validate();
    }
    else
    {
      System.exit(0);
    }
  }


Image
. Set by Medusa ♥


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 11, 2006 5:13 am 
Honorary Member
Honorary Member

Posts: 731
Joined: Tue Jun 01, 2004 3:26 pm
No problem. Glad to see everything turned out alright. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group