Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:07:06+00:00 2026-05-31T12:07:06+00:00

I am new to Java and I would like to know which would be

  • 0

I am new to Java and I would like to know which would be the best approach to create my app’s navigation.
I will now explain my app functionality and the approach I chose.

Leaving all the networking and other details behind, I will concentrate on the GUI part, since this is what I am here for.

Basically my app does the following :

  1. When you start it, you are presented with a login screen, and 2 buttons(Register and Login).
  2. The sign up screen is a basic register screen with it’s accordingly components.
  3. If the users enters correct login information, he will be presented with a view containing some data.

Now, I thought to make a JDialog/JFrame/Frame that is global for the app and when the users clicks a button, remove the previous content of it and “re-paint” new components.

Snippet from my sign up screen :

private JButton signUp;
private final JDialog parent;
.....

signUp = new JButton("Sign Up");
signUp.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        // TODO Auto-generated method stub
        parent.getContentPane().removeAll();
        parent.validate();
        parent.pack();
        Account v = new Account(parent);
        v.init();
    }
});
// add all the components to the parent frame
parent.add(signUp); 
.....

By calling Account v = new Account(parent); I have passed the global frame(JDialog in my case) to be “repopulated” with other contents using v.init();.
So my idea is : all the “views” I need to my app should have a “parent” field (which gets the global frame when the constructor is called) on which I add the components I need. Every time, before I call the .init() method for a view, I will remove all the previous content.
I am not sure this is a good approach since I read about Threads and MVC. On the other hand my approach seems really simple and I am not sure if I should complicate it with multithreading or MVC.

By using my approach I have managed to make a quite flexible UI, I can “play” with the frame’s properties (size, focus, enabling,etc.) from any view.

NOTE: If I have not been clear enough, when I say “view” I am referring to the class that receives the parent field when created and uses .init() to add content inside my parent frame.

EDIT: I do not need any code from you guys, just a simple piece of advice. I do this because I don’t want further in the development of the app to encounter some serious issues because of my approach on the navigation style.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:07:07+00:00Added an answer on May 31, 2026 at 12:07 pm

    You can either remove/readd new content calling

    revalidate();
    repaint();
    

    Or use CardLayout shwoing actual card with necessary UI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relativity new to multithreading in Java, and I would like to know
I am new to Java, the function I would like to perform is to
I would like to know if this is possible in java that i want
I would like to know how practical it would be to create a program
I would like to create an initialisation method for a Java class that accepts
I would like to know how to use multiples clas in Java. I know
On a java webserver, I would like to know if there are any active
I am currently working on a lab and would like to know how to
We are using the new Java printing API which uses PrinterJob.printDialog(attributes) to display the
As you have seen from my subject above, I would like to know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.