爱问知识人 爱问教育 医院库

用JAVA编一个界面,高手进来!编码越基本越好!

首页

用JAVA编一个界面,高手进来!编码越基本越好!


        

提交回答
好评回答
  • 2008-11-10 21:05:00
      按你的要求搞定,试一下还满意吗? import  t。*;import  t。event。*;import javax。swing。*;import javax。swing。event。*;public class PanDuan implements ActionListener{ JTextField jtf1; JButton b1; JFrame f=null; String title="结果"; String message=""; int type=JOptionPane。
      PLAIN_MESSAGE; public PanDuan(){ f=new JFrame(); Container c= tContentPane(); tLayout(new BorderLayout()); JPanel p1=new JPanel(); tLayout(new GridBagLayout()); GridBagConstraints gb=new GridBagConstraints(); idx=0; idy=0; d(new JLabel("请输入数字:",JLabel。
      CENTER),gb); idx=1; idy=0; jtf1=new JTextField(8); // tEnabled(false); d(jtf1,gb); idx=0; idy=1; b1=new JButton("确定"); dActionListener(this); d(b1,gb); d(p1); tSize(300, 300); tTitle("添加员工资料"); tVisible(true); dWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System。
      exit(0); } }); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if( tSource()==b1){ String zhi= tText(); if(zhi。
      equals("")){//判断输入的内容是否为空 type=JOptionPane。WARNING_MESSAGE; message="内容不能为空!!!"; owMessageDialog(f, message,title,type); return; } for(int i=0;i<zhi。
      length();i++){//判断输入的是否是数字 if(! Digit( arAt(i))){ type=JOptionPane。WARNING_MESSAGE; message="请输出数字!!!"; owMessageDialog(f, message,title,type); return; } } int sz=Integer。
      parseInt(zhi);//将去取出的字符串转换为整型的 if(sz>20){ type=JOptionPane。INFORMATION_MESSAGE; message="你输入的数字大于20!!!"; } if(sz==20){ type=JOptionPane。
      INFORMATION_MESSAGE; message="你输入的数字等于20!!!"; } if(sz<20){ type=JOptionPane。
      INFORMATION_MESSAGE; message="你输入的数字小于20!!!"; } owMessageDialog(f, message,title,type); } } public static void main(String[]args){ new PanDuan(); }}如满意别忘加点分啊,哈哈!!!!!!。

    t***

    2008-11-10 21:05:00

其他答案

    2008-11-10 16:07:00
  •   //C。javaimport javax。swing。*;import  t。*;import  t。event。*;public class C extends JDialog{ public static void main(String[] args) {new C()。
      setVisible(true);} public C(){ tDefaultCloseOperation(JDialog。DISPOSE_ON_CLOSE); tSize(200,80); tLocationRelativeTo(null); n = new JTextField();add(n);b=new JButton("GO"); tPreferredSize(new Dimension(1,23));add(b,"South"); dActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JOpti owMessageDialog( is,getMsg());//根据输入的内容显示相关的提示 tText(""); }}); } private String getMsg(){ String s = ""; if( tText()。
      trim()。isEmpty())s="请输入数字"; try{ int a = rseInt( tText()。
      trim()); s="你输入的数";s+=a>x?"大于 ":a<x?"小于 ":"等于 "; s+=x; }catch(Exception e){s="只能输入数字";} return s; } private JTextField n; private int x=20; private JButton b;}。

    缘***

    2008-11-10 16:07:00

  • 2008-11-10 12:31:00
  • <html><head><title>表单<title><script language=javascript>{aa( lue);for(a=1;a<=1;a>=100);if(a==20)elsealert("这个数等于20");elsealert("这个数大于20"); elsealert("这个数小于20");}</script></head><body><form><input type="text"name="a"value=""><br><input type="button"name="b"value="提交" onclick="aa()"></form></body></html>

    m***

    2008-11-10 12:31:00

  • 2008-11-10 12:22:00
  •   //完全按照你的要求来的 简单清楚明了import  t。event。*;import java。util。*;import javax。swing。
      *;public class Test extends JFrame implements ActionListener{ private JPanel pan; private JTextField tf; private JButton but; Test(){ tBounds(200, 200, 200, 200); pan = new JPanel(); tf = new JTextField(10); but = new JButton("确定"); dActionListener(this); d(tf); d(but); tContentPane(pan); tVisible(true); } public static void main(String args[]){ new Test(); } public void actionPerformed(ActionEvent e) { if( tSource()==but){ try { int i = rseInt( tText()); if(i==20){ owMessageDialog(this, "关系是:=20"); }else if(i>20){ owMessageDialog(this, "关系是:>20"); }else if(i<20){ owMessageDialog(this, "关系是:<20"); } } catch (Exception ee) { owMessageDialog(this, "输入错误"); } } }}。

    h***

    2008-11-10 12:22:00

类似问题

换一换
  • 互联网 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):