java图形化界面编程,java编程实现图形界面

1,java编程实现图形界面import java.awt.Container;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;import javax.swing.JButton;public class mi private static String username; private static String password ; private static JTextField []t= new JTextField("账号:",8),new JTextField(10), new JTextField("密码:",8),new JPasswordField(10)}; public static void main (String args[]) JFrame app=new JFrame("账号密码演示程序"); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); app.setSize(280,120); Container c=app.getContentPane(); c.setLayout(new FlowLayout());t[0].setEditable(false); t[2].setEditable(false); for(int i=0;i<4;i++) c.add(t[i]);t[1].setText(""); JButton[]b= c.add(b[0]);c.add(b[1]); app.setLocationRelativeTo(null); app.setVisible(true); b[1].addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)t[1].setText(""); t[3].setText(""); } });// 登录按钮加事件监听器 b[0].addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)username = t[1].getText(); password = t[3].getText(); //判断用户名密码是否正确 if (username.equals("数字") && password.equals("123"))JOptionPane.showMessageDialog(null, "登陆成功!", "消息", JOptionPane.INFORMATION_MESSAGE); } elseJOptionPane.showMessageDialog(null, "用户名或密码错误!", "错误", JOptionPane.ERROR_MESSAGE); } } });} }【java图形化界面编程,java编程实现图形界面】
2,怎么用java编写一个图形界面应用程序其中包含一个按钮当鼠标import java.awt.event.*;import javax.swing.*;public class myclass/*** @param args*/ private JFrame fm=new JFrame(); private JButton bt=new JButton("button1"); myclass()fm.setLayout(null);fm.setDefaultCloseOperation(3);fm.setBounds(300, 200, 450, 300);bt.setBounds(10, 10, 100, 25);bt.addMouseListener(new bt1event());fm.getContentPane().add(bt);fm.show(); } class bt1event implements MouseListenerpublic void mouseClicked(MouseEvent arg0)// TODO 自动生成方法存根}public void mouseEntered(MouseEvent arg0)// TODO 自动生成方法存根bt.setVisible(false);}public void mouseExited(MouseEvent arg0)// TODO 自动生成方法存根bt.setVisible(true);}public void mousePressed(MouseEvent arg0)// TODO 自动生成方法存根}public void mouseReleased(MouseEvent arg0)// TODO 自动生成方法存根}} public static void main(String[] args)// TODO 自动生成方法存根new myclass(); }}import java.awt.BorderLayout;import java.awt.Container;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import javax.swing.JButton;import javax.swing.JFrame;public class FrameTest extends MouseAdapterprivate JFrame frame;private Container c;private JButton jb;public FrameTest()frame = new JFrame();frame.setBounds(200, 300, 200, 300);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setLayout(new BorderLayout());c = frame.getContentPane();jb =new JButton("catch me!");jb.addMouseListener(this);c.add(jb,BorderLayout.NORTH);frame.setVisible(true);}public void mouseEntered(MouseEvent e)jb.setVisible(false);}public void mouseExited(MouseEvent e)jb.setVisible(true);}public static void main(String[] args)FrameTest ft = new FrameTest();}}
3 , JAVA图形界面程序编写我真的是抽风了,手痒了 , 给你写了这段代码,如果楼主、、、嘻嘻 , 追点分给我吧import java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*;public class baidu_9 extends JFrame implements ActionListener static final String OUTPUT="C://Test.txt"; JPanel pnl; JLabel lbl; JTextField txt1,txt2; JButton btnCopy,btnClear,btnOutput,btnColor; public baidu_9()super("百度题目");pnl=new JPanel();this.setContentPane(pnl);pnl.setLayout(null);pnl.setBackground(Color.WHITE);lbl=new JLabel("百度");txt1=new JTextField(10);txt2=new JTextField(10);btnCopy=new JButton("复制");btnCopy.addActionListener(this);btnClear=new JButton("清除");btnClear.addActionListener(this);btnOutput=new JButton("写入");btnOutput.addActionListener(this);btnColor=new JButton("变色");btnColor.addActionListener(this);lbl.setBounds(100, 10, 80, 20);txt1.setBounds(10, 40, 100, 20);txt2.setBounds(120, 40, 100, 20);btnCopy.setBounds(10, 70, 60, 20);btnClear.setBounds(75, 70, 60, 20);btnOutput.setBounds(140, 70, 60, 20);btnColor.setBounds(205, 70, 60, 20);pnl.add(lbl);pnl.add(txt1);pnl.add(txt2);pnl.add(btnCopy);pnl.add(btnClear);pnl.add(btnOutput);pnl.add(btnColor);setSize(300,150);setVisible(true); } public void Copy()txt2.setText(txt1.getText()); } public void Clear()txt1.setText("");txt2.setText("");pnl.setBackground(Color.WHITE); } public void Color()pnl.setBackground(Color.BLACK); } public void Ouput()tryFile fl=new File("C:\\Test.txt");FileWriter fw = new FileWriter(fl);BufferedWriter bw = new BufferedWriter(fw);bw.write(txt1.getText());bw.close();}catch (IOException e)e.printStackTrace();} } public void actionPerformed(ActionEvent e)if(e.getSource()==btnCopy)this.Copy();if(e.getSource()==btnClear)this.Clear();if(e.getSource()==btnColor)this.Color();if(e.getSource()==btnOutput)this.Ouput(); } public static void main(String[] args)new baidu_9(); }}给的分太少了 没人会愿意做的 。。。

    推荐阅读