2、新建一个gui界面,打开闭扮它所对应的m文件,找到哗源里面有function
pushbutton1_Callbackd一行
3、将轿芦灶所有的子程序复制到这一行下面,生成GUI文件,运行即可
看看下面:改动比岩逗较大import javax.swing.*
import java.awt.*
import java.awt.event.MouseEvent
import java.awt.event.MouseListener
public class CatchButtonGameV1 extends JFrame implements MouseListener{
JButton[] button= new JButton[9]
public CatchButtonGameV1 (){
GridLayout grid= new GridLayout(3,3)
setTitle("Catch me if you can!")
setLayout(grid)
for(int i=0i<9i++){
button[i]=new JButton()
add(button[i])
button[i].addMouseListener(this)
}
button[8].setText("Click me"枣州)
setVisible(true)
pack()
}
public void mouseEntered(MouseEvent e){
for(int i=0i<9i++){
if(e.getSource()==button[i])
button[i].setText(i+"凳枣蔽")
}
}
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
for(int i=0i<9i++){
if(e.getSource()==button[i])
button[i].setText("")
}
}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {
}
public static void main(String args[]){
CatchButtonGameV1 frame=new CatchButtonGameV1()
}
}
% 利用档差首java控件,改变图标。行数庆派handles.output = hObject
javaFrame = get(hObject, 'JavaFrame')
javaFrame.setFigureIcon(javax.swing.ImageIcon('logo.jpg'))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)