📄 jannebuttontest.java
字号:
/**
* Simple applet to test JanneButton class
*/
import java.awt.*;
import java.awt.image.*;
import java.applet.Applet;
public class JanneButtonTest extends Applet {
public void init() {
// test setting of background
setBackground(new Color(0xEED5B7));
// get the images
Image joe = getImage(getDocumentBase(), "images/joe.gif");
Image left = getImage(getDocumentBase(), "images/left.gif");
// create grid bag
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
//c.gridwidth = 2;
Insets insets = new Insets(2, 2, 4, 2);
c.insets = insets;
//c.ipady = 4;
// create a few buttons
addButton(gridbag, c, "String Button:",
null, "With a Label", false);
addButton(gridbag, c, "Image Button:",
left, "left", false);
addButton(gridbag, c, "Image Button, with String:",
left, "Left", true);
addButton(gridbag, c, "A Larger Image Button:",
joe, "joe", false);
show();
}
public void addButton(GridBagLayout gridbag, GridBagConstraints c,
String labelStr, Image image, String buttonStr,
boolean showLabel)
{
Label label = new Label(labelStr);
JanneButton button;
if (image != null)
button = new JanneButton(image, buttonStr, false, showLabel);
else
button = new JanneButton(buttonStr);
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(label, c);
add(label);
c.anchor = GridBagConstraints.CENTER;
c.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(button, c);
add(button);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -