Solved

Custom JOptionPane

Posted on 1998-06-18
2
926 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
[X]
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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
Maven Project: Hibernate Dependencies Conflict 10 49
couple of eclipse 5 52
Android development question 2 76
Java 8 to Java 6 8 32
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

740 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