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

  • Home
  • SEARCH
  • 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 7852013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:19:09+00:00 2026-06-02T19:19:09+00:00

i need some advice on JDialog stuff. I need to catch the input data,

  • 0

i need some advice on JDialog stuff.

I need to catch the “input” data, and i am wondering, what is the best way to do it.
Ok, here is complete problem. When user clicks the button (located on JFrame), JDialog pops out, and there are 3 text fields for entrys and one combo box. After user presses ok, i need to return those data in JFrame. Well, i can do this on my way, but thats too much of spaghetti code :)) What listener should i use? And if you are willing to give me code example i would be thankful 🙂

  • 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-06-02T19:19:10+00:00Added an answer on June 2, 2026 at 7:19 pm

    Hmm there are a lot of ways of solving it, maybe you can try a delegate approach with an interface like the following one:

    public interface DialogListener {
        public boolean okClicked(String input1, String input2, String input3, String combo);
        public void cancelClicked();
    }
    

    (The boolean is if you decide to wether dismiss the dialog or not).

    Implement that in your frame or frame controller if you’re using a MVC approach and add that component as a listener of your custom dialog.

    Another approach would be to set properties on the dialog and then your frame or controller could query the dialog for the input values.

    This depends on how generic you want things to be.

    You could also have someting like this which is more generic and reusable but less convenient:

    public interface DialogListener {
        public boolean okClicked(JDialog dialog, Map<String, JComponent> components);
        public void cancelClicked();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some advice about a best-approach for this problem: I've fallen madly in love
I need some advice please on the best way to achieve a particular outcome...
I need some advice on which library is the best choice when it comes
I need some advice here. I need to make a webservice, that can make
I need some advice on modelling my data tables. I need to apply inheritance
I need some advice. I know how to solve this problem clumsily, but I
I need some advice here, I hope somebody can help me. I have the
I need some advice regarding how to organize my data for effective and fast
Web Developer here and need some advice on how to achieve what must be
I need some advice on how to tackle an algorithmic problem (ie. not programming

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.