InputDialog
Aus Programmers Guide
Roy (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „import javax.swing.*;<br>import java.awt.event.*; public class ShowInputDialog{<br> <br> public ShowInputDialog(){<br> JFrame frame = new JFrame("Input Dialog Bo…“) |
Roy (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
- | import javax.swing.*;<br>import java.awt.event.*; | + | import javax.swing.*;<br>import java.awt.event.*; |
- | public class ShowInputDialog{<br> <br> public ShowInputDialog(){<br> JFrame frame = new JFrame("Input Dialog Box Frame");<br> JButton button = new JButton("Show Input Dialog Box");<br> button.addActionListener(new ActionListener(){<br> public void actionPerformed(ActionEvent ae){<br> String str = JOptionPane.showInputDialog(null, "Enter some text : ", "Roseindia.net", 1);<br> if(str != null){<br> JOptionPane.showMessageDialog(null, "You entered the text : " + str, "Roseindia.net", 1);<br> }<br> else<br> JOptionPane.showMessageDialog(null, "Abbruch...", "Roseindia.net", 1);<br> }<br> });<br> JPanel panel = new JPanel();<br> panel.add(button);<br> frame.add(panel);<br> frame.setSize(400, 400);<br> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br> frame.setVisible(true);<br> }<br>}<br> | + | public class ShowInputDialog{<br> <br> public ShowInputDialog(){<br> JFrame frame = new JFrame("Input Dialog Box Frame");<br> JButton button = new JButton("Show Input Dialog Box");<br> button.addActionListener(new ActionListener(){<br> public void actionPerformed(ActionEvent ae){<br> String str = JOptionPane.showInputDialog(null, "Enter some text : ", "Roseindia.net", 1);<br> if(str != null){<br> JOptionPane.showMessageDialog(null, "You entered the text : " + str, "Roseindia.net", 1);<br> }<br> else<br> JOptionPane.showMessageDialog(null, "Abbruch...", "Roseindia.net", 1);<br> }<br> });<br> JPanel panel = new JPanel();<br> panel.add(button);<br> frame.add(panel);<br> frame.setSize(400, 400);<br> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br> frame.setVisible(true);<br> }<br>}<br> |
+ | |||
+ | |||
+ | |||
+ | [[Category:Java]] |
Version vom 07:08, 30. Mär. 2010
import javax.swing.*;
import java.awt.event.*;
public class ShowInputDialog{
public ShowInputDialog(){
JFrame frame = new JFrame("Input Dialog Box Frame");
JButton button = new JButton("Show Input Dialog Box");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String str = JOptionPane.showInputDialog(null, "Enter some text : ", "Roseindia.net", 1);
if(str != null){
JOptionPane.showMessageDialog(null, "You entered the text : " + str, "Roseindia.net", 1);
}
else
JOptionPane.showMessageDialog(null, "Abbruch...", "Roseindia.net", 1);
}
});
JPanel panel = new JPanel();
panel.add(button);
frame.add(panel);
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}