Author
Show Dialog with TextArea & Buttons
Unnsse Khan
Ranch Hand
Joined: Nov 12, 2001
Posts: 511
I am using the JOptionPane to show a small dialog box... How do I show a custom dialog box (or another frame) which contains a TextArea and two buttons? Sorry, I'm a Swing dummy Here's where the code is executed: taskDescription.addActionListener(new ActionListener () { public void actionPerformed(ActionEvent event) { JOptionPane.showInternalInputDialog(desk, "Enter Description"); } }); Any help, tips, suggestions, will be greatly appreciated.... With thanks,
Kriti Garg
Ranch Hand
Joined: Sep 13, 2004
Posts: 50
Hi, We can add Components to the options array of the JOptionDialog whc is actually an object array. ....Sample Code..... package abc; import javax.swing.*; import java.awt.*; //import javax.swing.event.*; import java.awt.event.*; public class OptionDlg extends JFrame { // JOptionPane optionPane = null; public OptionDlg() { this.setSize(new Dimension(300, 300)); JButton btn = new JButton ("Click"); this.getContentPane().add(btn); this.setVisible(true); btn.addActionListener(new ActionListener () { public void actionPerformed(ActionEvent e) { Object options[] = { new JTextField ("Text Field"),new JButton ("Button")}; int stopOption = JOptionPane.showOptionDialog(null, "Option Dialog", "Option Dialog", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } }); } public static void main(String [] args) { OptionDlg optionDlg1 = new OptionDlg(); } } U can also use your own JDialog and JFrame instead of thisnd ur componentns like Textfiled or button to this. Bbye
Unnsse Khan
Ranch Hand
Joined: Nov 12, 2001
Posts: 511
This is a good example, thank you... Can you show me an example of a TextArea that is embedded inside the Dialog??
Pat Hays
Ranch Hand
Joined: Aug 20, 2004
Posts: 138
posted Nov 18, 2004 22:22:00
0
Hi Unnsse, You could use JFrameBuilder to make some examples of a TextArea that is embedded inside the Dialog by yourself.
Download Java GUI Builder, <a href="http://www.mars3000.com" target="_blank" rel="nofollow">http://www.mars3000.com</a>
subject: Show Dialog with TextArea & Buttons