java类与对象明星,明星档案的
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
import java.awt.*;import java.awt.event.*;import javax.swing.*;
public class yuanxueliang extends JFrame implements ActionListener, KeyListener, ItemListener, MouseListener{private JTextField zhanghao;private JPasswordField password;private JTextArea file;private JLabel ID;private JLabel MM;private JButton denglu,b1,b2;final String z="1";final String m="1";private JComboBox combox;private JLabel label;private String name[]={"angelbaby","潘瑋柏","林依晨","周杰倫"};private String names[][] ={{"1/angelbaby1.gif", "1/angelbaby2.gif","1/angelbaby3.gif"},{"1/潘瑋柏1.gif","1/潘瑋柏2.gif","1/潘瑋柏3.gif"},{"1/林依晨1.gif","1/林依晨2.gif","1/林依晨3.gif"},{"1/周杰倫1.gif","1/周杰倫2.gif","1/周杰倫3.gif"}};private int i = 0;private int j = 0;private Icon icons[] ={ new ImageIcon(names[i][j]),new ImageIcon(names[i+1][j]),new ImageIcon(names[i+2][j] ),new ImageIcon( names[3][i] ) };//登錄界面設置public yuanxueliang(){//登陸界面的構造方法setTitle("登陸界面");setLayout(null);setSize(300,200);setResizable(false);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);zhanghao = new JTextField("");password = new JPasswordField("");ID = new JLabel("賬號:");MM = new JLabel("密碼:");denglu = new JButton("登錄");//password.addKeyListener(this);denglu.addActionListener(this);//設置各組件在登錄窗口的位置ID.setBounds(30,50,80,20);MM.setBounds(30,90,80,20);zhanghao.setBounds(70, 50, 150, 20);password.setBounds(70, 90, 150, 20); denglu.setBounds(100,130,80,30);
//把組件添加到登錄窗口add(zhanghao);add(MM);add(password);add(ID);add(denglu);setVisible(true);}//按鈕的監聽器public void actionPerformed(ActionEvent e) {if(z.equals(zhanghao.getText()) &&m.equals(password.getText())) {
JFrame frame2 = new JFrame("明星簡歷表");//檔案界面設置frame2.setLayout(null);frame2.setSize(600,500);frame2.setResizable(false);frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);b1=new JButton("上一頁");b2 = new JButton("下一頁");file = new JTextArea(10,10);//設置文本域combox = new JComboBox( name );combox.setMaximumRowCount( 5);combox.addItemListener(this);label = new JLabel(icons[0]);b1.addActionListener(new TV());//設置各組件的位置b1.setBounds(300,200,100,20);b2.setBounds(430,200,100,20);label.setBounds(330,40,180,150);combox.setBounds(100,150,100,20);file.setBounds(50,250,500,200);file.setLineWrap(true);//把各組件添加到檔案窗口frame2.add(b1);frame2.add(b2);frame2.add(label);frame2.add(combox);frame2.add(file);
frame2.setLocationRelativeTo(null);frame2.setVisible(true);
} else {JOptionPane.showMessageDialog(null, "對不起,你輸入的帳號或密碼有誤,請重新輸入", "提示", JOptionPane.ERROR_MESSAGE);zhanghao.setText("");password.setText("");}}public void itemStateChanged( ItemEvent e ){label.setIcon(icons[combox.getSelectedIndex()]) ;} class TV implements ActionListener{public void actionPerformed(ActionEvent e) {}} /*public void keyPressed(KeyEvent e){if (e.getKeyCode() == KeyEvent.VK_ENTER ){if(z.equals(zhanghao.getText()) &&m.equals(password.getText())) {
JFrame frame2 = new JFrame("明星簡歷表");//檔案界面設置frame2.setLayout(null);frame2.setSize(600,500);frame2.setResizable(false);frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);JButton b1=new JButton("上一頁");JButton b2 = new JButton("下一頁");JTextArea file = new JTextArea(10,10);//設置文本域Choice c = new Choice(); //添加列表框c.add("angelbaby");c.add("潘瑋柏");c.add("林依晨");c.add("周杰倫");c.add("蔡依林");c.add("羅志祥");
//設置各組件的位置b1.setBounds(300,200,100,20);b2.setBounds(430,200,100,20);c.setBounds(100,150,100,20);file.setBounds(50,250,500,200);
//把各組件添加到檔案窗口frame2.add(b1);frame2.add(b2);frame2.add(c);frame2.add(file);
frame2.setLocationRelativeTo(null);frame2.setVisible(true);
} else {JOptionPane.showMessageDialog(null, "對不起,你輸入的帳號或密碼有誤,請重新輸入", "提示", JOptionPane.ERROR_MESSAGE);zhanghao.setText("");password.setText("");}}}*/public static void main(String args[]){// 實例化對象yuanxueliang f =new yuanxueliang();
}}
總結
以上是生活随笔為你收集整理的java类与对象明星,明星档案的的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么理解js监听浏览器后退事件
- 下一篇: GPT已长出眼睛耳朵 周鸿祎:人工智能将