Solved

Custom JOptionPane

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i compare an object based on two fields 6 54
nextBoolean(double p) for Random class 3 40
tomcat not starting 6 45
Which non-HTML GUI front end to use with Java? 3 22
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

803 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