Solved

Custom JOptionPane

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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.

911 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

24 Experts available now in Live!

Get 1:1 Help Now