Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Custom JOptionPane

Posted on 1998-06-18
2
918 Views
Last Modified: 2012-06-27
How can I make a custom JDialog containing a JOptionPane which can be used for validating the users password and user name?
So, in this JDialog should appear:
1. an icon (questionmark) if possible
2. a JLabel "user name"
3. a JTextField for typing in the name
4. a JLabel "password"
5. a JPasswordField for typing in the encrypted password
6. a "cancel" and "ok" JButton
(7. Maybe a text, eg. "Please enter user name and password.")

Some code appreciated.

This dialog shall be invoked from within an JApplet!
Of course, I need some methods to handle the input (getValue(); ...).
0
Comment
Question by:dirku
2 Comments
 
LVL 4

Accepted Solution

by:
evijay earned 10 total points
ID: 1223382
See this portion of code from swingset demo program swingset.java




                JComboBox cb = new JComboBox();
                cb.addItem("One");
                cb.addItem("Two");
                cb.addItem("Three");
                message[0] = "JOptionPane can contain any number of components,
and any number options.";
                message[1] = new JButton("a button");
                message[2] = new JTextField("a text field");
                message[3] = cb;


                String[]      options = { "Option 1", "Option 2", "Option 3",
                                          "Option 4" };
                JOptionPane.showOptionDialog(SwingSet.this, message, "Example",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);

You can use this as a template for building your own password dialog.
0
 

Author Comment

by:dirku
ID: 1223383
I think I should read the SwingSet-Examples more exactly! :-))
=> This would be cheaper (...but would take more time ;-) )
Thanks!!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Groovy problem when using SOAPUI : DispatchException occurred 7 58
mysql jsp example issue 32 48
Java basic valueOf question 1 29
jsp error 6 25
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question