• Java-Swing编程之对话框案例详解


    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();

             }

    }

  • 相关阅读:
    找最后的字符
    统计指定数字和
    班级排队
    python编程题
    python函数题
    2019.6.24-2019.6.28(实训数据结构)3.数组编码求解问题
    2019.6.24-2019.6.28(实训数据结构)1.商品管理系统实训c++(实现的基本功能:初始化,创建表,插入,删除,更新,查询,链表数据与文件之间的转换)
    2019.6.24-2019.6.28(实训数据结构) 2.背包问题
    2019.6.24-2019.6.28(实训数据结构)4.树和二叉树应用项目
    2019.6.24-2019.6.28(实训数据结构)5.图的邻接矩阵表示
  • 原文地址:https://www.cnblogs.com/Jasxu/p/javaswing.html
Copyright © 2020-2023  润新知