Package Com.xushouwei.cn.photo;
Import java.awt.GraphicsConfiguration;
Import Java.awt.GridLayout;
Import java.awt.HeadlessException;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPanel;
Import Javax.swing.JTextField;
Import javax.swing.SwingConstants;
Import javax.swing.SwingUtilities;
Import Javax.swing.UIManager;
public class Feedinfo extends JFrame {
Private JLabel Jl1,jl2,jl3;
Private JTextField jtf1,jtf2,jtf3;
Private JPanel JP1;
Public Feedinfo () {
TODO auto-generated Constructor stub
Super ("Feed information");
SetSize (400,105);
Setdefaultcloseoperation (Jframe.exit_on_close);
Jl1=new JLabel ("Name:", swingconstants.right);
Jl2=new JLabel ("URL:", swingconstants.right);
Jl3=new JLabel ("Type:", swingconstants.right);
String Response1=joptionpane.showinputdialog (NULL, "Enter the site Name:");
Jtf1=new JTextField (response1,20);
String Response2=joptionpane.showinputdialog (NULL, "Enter the Site Address:");
Jtf2=new JTextField (response2,20);
String[] choices={"Personal", "commercial", "Unknown"};
int Response3=joptionpane.showoptiondialog (NULL, "What type of site is it?", "Site Type", 0, Joptionpane.question_message , NULL, choices, choices[0]);
Jtf3=new JTextField (choices[response3],20);
This.setlayout (New GridLayout (3,2));
This.add (JL1);
This.add (JTF1);
This.add (JL2);
This.add (JTF2);
This.add (JL3);
This.add (JTF3);
This.setlookandfeel ();
This.setvisible (TRUE);
}
private void Setlookandfeel () {
TODO auto-generated Method Stub
try {
Uimanager.setlookandfeel (Uimanager.getsystemlookandfeelclassname ());
Swingutilities.updatecomponenttreeui (this);
} catch (Exception e) {
Todo:handle exception
E.printstacktrace ();
}
}
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
Feedinfo fi=new feedinfo ();
}
}
Java-swing Programming dialog box case detailed