房天下 > 房天下问答 > 业主生活 > 其他
  • 谁能帮我编译一个Java程序 基于swing图形用户界面?

    也没什么具体的要求,就是老师安排的设计作业,要求自己设计,但是又要求不能雷同,我们现在学的东西非常浅显,所以拜托能不能给一个简单的,有不容易雷同的答案,不过一定要是基于swing的图形用户界面,谢谢啦

    提问者:wen198111

    发布于2010-09-29

共1个回答
  • 寒流飘过海 丨Lv 0
    import java.awt.event.MouseEvent;import java.awt.event.MouseMotionListener;import javax.swing.JButton;import javax.swing.JFrame;public class BuTest implements MouseMotionListener{ JFrame jf=new JFrame("在按钮上移动的文字"); JButton[] button=new JButton[9]; int mount=0; public void init(){ jf.setLayout(null); jf.setSize(650, 100); jf.setResizable(false); jf.setLocationRelativeTo(null); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); initButton(); } public void initButton(){ int x=10,y=10; for(int i=0;i<button.length;i++){ button[i]=new JButton(); button[mount].setText("点我"); button[i].setBounds(x, y, 60, 30); jf.add(button[i]); button[i].addMouseMotionListener(this); x+=70; } jf.setVisible(true); } public static void main(String arg[]) { new BuTest().init(); } public void mouseDragged(MouseEvent e) { } public void mouseMoved(MouseEvent e) { if(e.getSource()==button[mount]){ button[mount].setText(""); if(mount!=8){ mount++; }else{ mount=0; } button[mount].setText("点我"); } }}
    +1 2010-09-29 举报
热门人气推荐
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。