📄 mybutton.java
字号:
/*
* Created on Mar 25, 2005
*
* TODO add a coordinate to a JLabel as a button, to mark the location of this button
*/
package view;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import model.Location;
import javax.swing.JLabel;
/**
* @author mqqqvpppm
*
* TODO add a coordinate to a JLabel as a button, to mark the location of this
* button
*/
public class MyButton extends JLabel {
private Location location;
public Location getMyLocation() {
return location;
}
MyButton(Location aLocation) {
super();
this.location = aLocation;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
Graphics2D g2 = (Graphics2D) g;
g2.drawImage(image, 0, 0, getWidth(), getHeight(), null);
}
}
public void draw(Image image){
this.image = image;
repaint();
}
MyButton(int x, int y) {
super();
location = new Location(x, y);
}
private Image image;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -