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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:54:13+00:00 2026-05-15T01:54:13+00:00

What would be the easiest way for creating a dialog: in one window I’m

  • 0

What would be the easiest way for creating a dialog:

  • in one window I’m giving data for envelope addressing, also set font type from list of sizes
  • when clicked OK, in the same window or in next window I get preview of how the envelope would look like with the given names, and used selected font size

It should look similarly to:

alt text http://img15.imageshack.us/img15/7355/lab10aa.gif

Should I use Jdialog? Or will JOptionPane will be enough? The next step will be to choose color of font and background so I must keep that in mind.

  • 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-15T01:54:14+00:00Added an answer on May 15, 2026 at 1:54 am

    If you need to use JOptionPane :

    import java.awt.*;
    import javax.swing.*;
    
    public class Main extends JFrame {
    
        private static JTextField nameField = new JTextField(20);
        private static JTextField surnameField = new JTextField();
        private static JTextField addr1Field = new JTextField();
        private static JTextField addr2Field = new JTextField();
        private static JComboBox sizes = new JComboBox(new String[] { "small", "medium", "large", "extra-large" });
    
        public Main(){
            JPanel mainPanel = new JPanel();
            mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
            getContentPane().add(mainPanel);
    
            JPanel addrPanel = new JPanel(new GridLayout(0, 1));
            addrPanel.setBorder(BorderFactory.createTitledBorder("Receiver"));
            addrPanel.add(new JLabel("Name"));
            addrPanel.add(nameField);
            addrPanel.add(new JLabel("Surname"));
            addrPanel.add(surnameField);
            addrPanel.add(new JLabel("Address 1"));
            addrPanel.add(addr1Field);
            addrPanel.add(new JLabel("Address 2"));
            addrPanel.add(addr2Field);
            mainPanel.add(addrPanel);
            mainPanel.add(new JLabel(" "));
            mainPanel.add(sizes);
    
            String[] buttons = { "OK", "Cancel"};
    
            int c = JOptionPane.showOptionDialog(
                    null,
                    mainPanel,
                    "My Panel",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    buttons,
                    buttons[0]
             );
    
            if(c ==0){
                new Envelope(nameField.getText(), surnameField.getText(), addr1Field.getText()
                        , addr2Field.getText(), sizes.getSelectedIndex());
            }
    
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            setVisible(true);
        }
    
        public static void main(String[] args) {
            new Main();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would be the easiest way to convert the following key->value object array to
What would be the easiest way to update a HTML tag with the following
What would be the easiest way of using commands in the code to programatically
What would be the easiest way to have the color of a text field
What's the easiest way to generate a bitmap using Python? Text support would be
I would like to know what is the best, fastest and easiest way to
What would be the easiest or recommended way for making an NSOutlineView indent multiple
What is the easiest way of doing it? I started by creating a class
What would be the easiest way to get the current day of the week
What would be the easiest way to execute a Python script and, for each

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.