mangledbuttondemo.java
来自「java 完全探索的随书源码」· Java 代码 · 共 56 行
JAVA
56 行
// MangledButtonDemo.java
import java.awt.*;
import java.awt.event.*;
class MangledButtonDemo extends Frame
{
MangledButtonDemo (String title)
{
super (title);
addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent e)
{
System.exit (0);
}
});
add (new MangledButton ("OK"));
setSize (200, 100);
setVisible (true);
}
public static void main (String [] args)
{
new MangledButtonDemo ("Mangled Button");
}
}
class MangledButton extends Button
{
MangledButton (String label)
{
super (label);
}
public void paint (Graphics g)
{
g.setColor (Color.red);
int w = getSize ().width - 1;
int h = getSize ().height - 1;
g.drawLine (0, 0, w, 0);
g.drawLine (w, 0, w, h);
g.drawLine (w, h, 0, h);
g.drawLine (0, h, 0, 0);
g.drawLine (0, 0, w, h);
g.drawLine (w, 0, 0, h);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?