📄 showdialog.java
字号:
import javax.swing.*;
import java.awt.event.*;
public class showdialog extends JFrame
{
private JLabel titleLabel=new JLabel("Title: ",SwingConstants.RIGHT);
private JTextField title;
private JLabel addressLabel=new JLabel("address: ",SwingConstants.RIGHT);
private JTextField address;
private JLabel typeLabel=new JLabel("type: ",SwingConstants.RIGHT);
private JTextField type;
public showdialog()
{
super("site Information");
addWindowListener(new quitEvent()); //Event
String response1=JOptionPane.showInputDialog(null,"Enterth");
title =new JTextField(response1,20);
String response2=JOptionPane.showInputDialog(null,"address");
address=new JTextField(response2,20);
String[] choices={"personal","Commercial","unknown"};
int response3=JOptionPane.showOptionDialog(null,"type","site",0,JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
type=new JTextField(choices[response3],20);
JPanel pane=new JPanel();
pane.setLayout(new GridLayout(3,2));
pane.add(titleLabel);
pane.add(title);
pane.add(addressLabel);
pane.add(address);
pane.add(typeLabel);
pane.add(type);
setContentPane(pane);
}
public static void main(String args[])
{
try
{
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName());
} catch(Exception e)
{
System.err.println("Couldn't use the system "+"look and feel: "+e);}
showdialog frame=new showdialog();
frame.pack();
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -