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 3349600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:41:04+00:00 2026-05-18T01:41:04+00:00

I have a created a UI in swing using NetBeans. There are some use

  • 0

I have a created a UI in swing using NetBeans.
There are some use cases where the user presses buttons and a JDialog appears as a result.
The JDialog accepts input via JComboBox, at least 4.
E.g.
User presses “ButtonA” and a JDialog appears that displays the following:

"select X:" combo  
"select Y:" combo  
"select Z:" combo  
"select O:" combo  etc  

I.e. beside each combo is a descriptive label. There are a few other controls in each JDialog besides each combo, i.e. JCheckbox, JTextarea
If user presses “ButtonB” a JDialog appears that displays the following:

"select A:" combo  
"select B:" combo  
"select C:" combo  etc  

So the dialogs are not the same but have some pattern in their presentation format. I.e. usage of comboboxes.
Initially I though to create a single JDialog and pass some arguments for the text it should display on the labels of the JDialogs and whether the JCheckbox should appear or not, if the JTextArea should appear or not and with what text etc, all depending on parameters passed in the initialization of the JDialog so as to have a single class for all use cases, but the code started getting really complicated and I rejected this approach.
What I did was create via GUI designer a JDialog, exactly as needed for each button press and came up with about 10-11 such JDialogs.
This appoach has made the programming much simpler but I do not know if it is a standard way to deal with this since I created 10-11 extra classes for the input.
My question is, whether what I did is reasonable, or there are better ways to deal with situation like this.
Thank you!

  • 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-18T01:41:05+00:00Added an answer on May 18, 2026 at 1:41 am

    I think I would write a DialogBuilder class that returns a JDialog.


    EDIT:

    Visual vs Programatic creation of Dialogs

    I’m used to generating Dialogs by writing code. before Java I used to code in Delphi in which Dialogs were created using a GUI – so initially I did find this annoying and even tedious. Nowadays I rather enjoy it. So yes, I would probably throw out (most of) the dialog code created by netbeans. Unless your dialogs are more complicated than your question suggests.

    Complexity

    Yes, there is a danger that you’ll end up taking a lot of time to create quite complex code. However, if you are like me, you’ll learn a lot doing it. One thing you’ll learn is how to use various patterns to avoid that complexity. Finding an elegant way to solve those issues is something I find pretty satisfying – it’s one of the aspects of programming I find most enjoyable.

    Parameters

    When you mention your concern about “if argA&& argB && !argC then display JCheckbox etc for 10-11 different jdialogs” – I can only suggest you try to approach the problem from a different direction. For example, you could pass the DialogBuilder a list of pairs of labels and JComboboxes. Or maybe you could extend JCombobox so that it has an additional field and a getter for it’s label.

    e.g.

    DialogBuilder builder = new DialogFactory();
    builder.add("Select X:", new Xcombo(...), true);  // with checkbox
    builder.add("Select Y:", new Ycombo(...), false); // without
    ...
    builder.getDialog.setVisible(true);
    

    or

    builder.add("Select X:", new MyCombo(xList), false);
    builder.add("Select Y:", new MyCombo(yList), false);
    

    You can see (I hope) that the DialogBuilder.add(String, JComboBox, boolean) method wouldn’t need dozens of complex if ... then ... else clauses.

    Just my $0.02 worth.

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

Sidebar

Related Questions

I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a C# class file by using a XSD-file as an input.
How can I create in a Swing interface a toggle image button? I have
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
i have created a workflow activity that do give the item creater of a
I have created a foreign key (in SQL Server) by: alter table company add

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.