Solved

Custom JOptionPane

Posted on 1998-06-18
2
897 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now