Java-swing Programming dialog box case detailed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.