Results 1 to 6 of 6
  1. #1
    Felic is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Question GUI. Button opening another GUI

    Hi there

    I recently started at a university where we have to spend the first 3 semesters learning a bit of Java. Now I have a project where I need to create a GUI for some classes about the weather.

    My question is, we have a GUI made with WindowBuilder from Google with a main method in it. We want this GUI to have a button (which we already made) that opens up another window (that we made in another class with the WindowBuilder, wich means it also has a main method which probably needs to be removed).

    How do you refer or get a button to open a new GUI class? Any help is appreciated!

  2. #2
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    As a user I hate applications that opens multiple windows and make it difficult and confusing which one is in use.
    As a programmer I tell you that you can re-use frame of your application and re-fill it with new content. You will simple swap one panel in frame with new panel.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Quote Originally Posted by Felic View Post
    How do you refer or get a button to open a new GUI class?
    How would you do it without the button? How would you do it from the main method, or from any other method?

  4. #4
    Felic is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by peter_budo View Post
    As a user I hate applications that opens multiple windows and make it difficult and confusing which one is in use.
    As a programmer I tell you that you can re-use frame of your application and re-fill it with new content. You will simple swap one panel in frame with new panel.
    Well I am pretty clueless, as I said I am new to this. We only had Java for 2 months and we already have to create a project and turn it in for examination the 16th. We'll only have Java for around 1 year total, then we'll proceed to Databases and a more managerial perspective of IT and Project Management. But I'd like to actually know what I am doing still, which is why I even came here in the first place.

    A swap method could work, it sounds clever atleast. I just need some pointers. At the moment I created 2 GUI's in each their class. When you use WindowBuilder it automatically creates a main method in each of the classes, and to my knowledge that won't work if you try to open another GUI with a main method in it??

    Could you perhaps give or link me to an example that uses a simple swap method from 1 GUI window to another ? Anything would be appreciated. I could try to provide some more details if you want aswell.
    Last edited by Felic; 12-02-2010 at 04:03 PM.

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Honestly, I'd recommend you ditch the GUI builder until you're more comfortable with programming in general. I promise you're only hurting yourself by trying to learn programming and how the GUI builder works at the same time.

    But for the "swap method", check out CardLayout: How to Use CardLayout (The Java Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

  6. #6
    Felic is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    Honestly, I'd recommend you ditch the GUI builder until you're more comfortable with programming in general. I promise you're only hurting yourself by trying to learn programming and how the GUI builder works at the same time.

    But for the "swap method", check out CardLayout: How to Use CardLayout (The Java Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
    I will take a look at it.

    Well the problem is we HAVE to turn in the paper like that. Basicly the description was:

    Create 3 classes constisting of 1/2 get/set methods describing Wind/Rain/Temperature. A 4th class Collecting it all and creating a method for statistics, min/max temp and a reset button that sets them all to 0.

    The 5th class is the GUI where the data is shown and it has to have working buttons showing the data. So our GUI have to be able to swap to the statistic page showing min/max temp and amount of rain (data that we just give, when we expand we will make the user able to give the input in a textfield).

    Anyway, I'll take a look at your link now. Ty for your help so far!

Similar Threads

  1. Reg Java Opening
    By krishnash in forum Jobs Wanted
    Replies: 0
    Last Post: 02-07-2010, 11:58 AM
  2. Replies: 4
    Last Post: 10-07-2009, 09:14 AM
  3. opening ports
    By prashant in forum Networking
    Replies: 2
    Last Post: 03-22-2009, 08:23 PM
  4. Opening a workspace twice
    By javaplus in forum Eclipse
    Replies: 0
    Last Post: 01-08-2008, 09:56 AM
  5. Opening URLConnection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-24-2007, 07:37 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
  •