嘿12一中
嘿12一中
关注数: 44
粉丝数: 39
发帖数: 1,362
关注贴吧数: 36
大四学长毕业了,要考雅思的👇进来 大四本来打算考雅思,后来因为个人原因没有进行,以下是雅迪真题4-9,10、11两册送我其他同学了。因为现在要退寝了,书没用过,全新的,不想直接卖了。想给有需要的人好好利用,故有需要的下面留言微信或qq或手机号,先到先得,免费赠送!
乔二哥,被解雇了嘛😭😭
看看今天火箭的表现吧,我熊明天也要打出今天的气势啊。。。。。
求大神啊啊啊啊啊啊啊啊啊啊 求帮助!!!!!! import java.awt.*; import javax.swing.*; import java.awt.event.*; public class SignalMainClass extends JFrame implements KeyListener,ActionListener,WindowListener { Person person[]=new Person[20]; JButton left,right,above,below; JButton restart=new JButton("重新开始"); public SignalMainClass() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); init(); setBounds(100,100,600,600); addWindowListener(this); setVisible(true); //validate(); }//1 public void init() { setLayout(null); add(restart); restart.addActionListener(this); restart.setBounds(180,400,120,25); for(int k=0;k<11;k++) { person[k]=new Person(k); person[k].addKeyListener(this); add(person[k]); } person[0].setBounds(54,54,100,100); person[1].setBounds(154,54,100,100); person[2].setBounds(254,54,100,100); person[3].setBounds(354,54,100,100); person[4].setBounds(54,154,100,100); person[5].setBounds(154,154,100,100); person[6].setBounds(254,154,100,100); person[7].setBounds(354,154,100,100); person[8].setBounds(54,254,100,100); person[9].setBounds(154,254,100,100); person[10].setBounds(254,254,100,100); left=new JButton();right=new JButton(); above=new JButton();below=new JButton(); add(left);add(right);add(above);add(below); left.setBounds(49,49,5,310);right.setBounds(454,49,5,310); above.setBounds(49,49,405,5);below.setBounds(54,354,405,5); //validate(); }//2 public void keyTyped(KeyEvent e){};//3 public void keyReleased(KeyEvent e){};//4 public void keyPressed(KeyEvent e){ Person man=(Person)e.getSource(); if(e.getKeyCode()==KeyEvent.VK_DOWN) { go(man,0);//表示向下 } if(e.getKeyCode()==KeyEvent.VK_UP) { go(man,1);//表示想上 } if(e.getKeyCode()==KeyEvent.VK_LEFT) { go(man,2);//表示向左 } if(e.getKeyCode()==KeyEvent.VK_RIGHT) { go(man,3);//表示向右 } }//5 public void mousePressed(MouseEvent e) { Person man=(Person)e.getSource(); int x=-1,y=-1; x=e.getX(); y=e.getY(); int w=man.getBounds().width; int h=man.getBounds().height; if(y>h/2) { go(man,0); } if(y<h/2) { go(man,1); } if(x<w/2) { go(man,2); } if(x>w/2) { go(man,3); } }//6 public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void go(Person man,int direction) { boolean move=true; Rectangle manRect=man.getBounds(); int x=man.getBounds().x;//得到x的值 int y=man.getBounds().y;//得到y的值坐标 if (direction==0) //决定方向 y=y+100; else if(direction==1) y=y-100; else if(direction==2) x=x-100; else if(direction==3) x=x+100; manRect.setLocation(x,y); for(int k=0;k<11;k++) { Rectangle personRect=person[k].getBounds(); if((manRect.intersects(personRect))&&(man.number!=k)) { move=false; } } if((manRect.getBounds().x+manRect.getBounds().width-100)>=400){ move=false; } if((manRect.getBounds().y+manRect.getBounds().height-100)>=300){ move=false; } if(manRect.getBounds().y<=5){ move=false; } if(manRect.getBounds().x<=5){ move=false; } if(move==true) { man.setLocation(x,y); } int x1=person[0].getBounds().x; int y1=person[0].getBounds().y; } public void actionPerformed(ActionEvent e) { dispose(); new SignalMainClass(); } public static void main(String args[]) { SignalMainClass fr=new SignalMainClass(); } public void windowClosing(WindowEvent e){ int a=JOptionPane.showConfirmDialog(null,"确定要关闭吗?","问题",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE); if(a==JOptionPane.YES_OPTION) { //System.exit(0); dispose(); } if(a==JOptionPane.NO_OPTION) { return; } } public void windowClosed(WindowEvent e){ } public void windowOpened(WindowEvent e){ } public void windowIconified(WindowEvent e){ } public void windowDeiconified(WindowEvent e){ } public void windowActivated(WindowEvent e){ } public void windowDeactivated(WindowEvent e){ } } import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Person extends JButton implements FocusListener { int number; Color c=new Color(255,245,170); Person(int number) { setBackground(c); this.number=number; c=getBackground(); //setFont(new Font()) addFocusListener(this); } public void focusGained(FocusEvent e) { setBackground(Color.red); } public void focusLost(FocusEvent e) { setBackground(c); } } public class MainClass { public static void main(String args[]) { new SignalMainClass(); } } 这三个程序 是一个整体 我本来想做一个拼图游戏 移动什么的都没问题了 但是不知道怎样把图片加在按钮上 因为按钮用的是person类还有数组,求大神指教啊
1
下一页