📄 testboxxer.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*class SuperSuper
{
public SuperSuper()
{
System.out.println("SuperSuper Class");
}
}
class Super extends SuperSuper
{
public Super()
{
System.out.println("Super Class");
}
}
class Sub extends Super
{
public Sub()
{
System.out.println("Sub Class");
}
}
*/
/*
public class TestBoxxer extends Frame implements ActionListener
{
private Button quit = new Button("Quit");
private Button click = new Button("Click here");
private TextField text = new TextField(10);
private boolean secondClick = false;
public TestBoxxer()
{
super("Click Example");
setLayout(new FlowLayout());
add(quit);
add(click);
click.addActionListener(this);
quit.addActionListener(this);
add(text);
pack();
show();
quit.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
//dispose();
//System.exit(0);
if (e.getSource() == quit)
System.exit(0);
else if (e.getSource() == click)
{
if (secondClick)
text.setText("first click");
else
text.setText("second click ahha, yeah");
secondClick = !secondClick;
}
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
//Sub c = new Sub();
//Button button = new Button();
//String string = new String();
//Frame myFrame = new Frame("My first frame!");
//myFrame.show();
TestBoxxer mft = new TestBoxxer();
}
}
*/
/*
public class TestBoxxer extends Frame implements ActionListener
{
//TestAreaTest Example
private TextField input = new TextField();
private TextArea output = new TextArea();
private Button add = new Button("Add");
private Button addLn = new Button("Add + Return");
private class WindowCloser extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
public TestBoxxer()
{
super("TestBoxxer");
setup();
add.addActionListener(this);
addLn.addActionListener(this);
addWindowListener(new WindowCloser());
pack();
show();
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == add)
{
output.append(input.getText());
input.setText("");
}
else if (e.getSource() == addLn)
{
output.append("\n" + input.getText());
input.setText("");
}
input.requestFocus();
}
private void setup()
{
Panel top = new Panel();
top.setLayout(new BorderLayout());
top.add("West", add);
top.add("Center", input);
top.add("East", addLn);
setLayout(new BorderLayout());
add("North", top);
add("Center", output);
}
public static void main(String args[])
{
TestBoxxer tb = new TestBoxxer();
}
}
*/
/*
public class TestBoxxer extends Frame implements ActionListener
{
private MenuItem fileNew = new MenuItem("New");
private MenuItem fileOpen = new MenuItem("Open");
private MenuItem fileExit = new MenuItem("Exit");
private MenuItem editCut = new MenuItem("Cut");
private MenuItem editCopy = new MenuItem("Copy");
private MenuItem editPaste = new MenuItem("Paste");
private class WindowCloser extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
public TestBoxxer()
{
super("Menu Test Programe");
Menu file = new Menu("File");
file.add(fileNew); fileNew.setEnabled(true);
file.add(fileOpen); fileOpen.setEnabled(false);
file.addSeparator();
file.add(fileExit); fileExit.setEnabled(true);
Menu edit = new Menu("Edit");
edit.add(editCut); editCut.setEnabled(false);
edit.add(editCopy); editCopy.setEnabled(false);
edit.add(editPaste); editPaste.setEnabled(false);
MenuBar bar = new MenuBar();
bar.add(file);
bar.add(edit);
setMenuBar(bar);
fileExit.addActionListener(this);
setSize(100, 100);
Window wd;
addWindowListener(new WindowCloser());
//pack();
show();
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == fileExit)
System.exit(0);
}
public static void main(String args[])
{
TestBoxxer tb = new TestBoxxer();
tb.setLocationRelativeTo(null);
}
}
*/
/*
class WCenterlization
{
//窗口居中通用方法
public WCenterlization(Frame parent)
{
//---------------------------设置窗口居中-----------------------------
int windowWidth = parent.getWidth(); //获得窗口宽
int windowHeight = parent.getHeight(); //获得窗口高
Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包
Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸
int screenWidth = screenSize.width; //获取屏幕的宽
int screenHeight = screenSize.height; //获取屏幕的高
//设置窗口居中显示
parent.setLocation(screenWidth/2 - windowWidth/2, screenHeight/2 - windowHeight/2);
}
}
*/
class WindowCloser extends WindowAdapter
{
//关闭窗口通用类
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
/*
public class TestBoxxer extends Applet
{
private Button draw = new Button("Draw");
private DrawCanvas drawing = new DrawCanvas();
public void init()
{
Panel buttons = new Panel();
buttons.setLayout(new FlowLayout());
buttons.add(draw);
setLayout(new BorderLayout());
add("North", buttons);
add("Center", drawing);
//WCenterlization wc = new WCenterlization(this);
//setLocationRelativeTo(null);
}
public class DrawCanvas extends Canvas
{
public void paint(Graphics g)
{
for (int i = 12; i < getSize().height; i += 12)
g.drawString("y Location: " + i, 10, i);
}
}
}
*/
/*
public class TestBoxxer extends Frame
{
private static final String[] FONTS =
{"Dialog",
"DialogInput",
"Monospaced",
"Serif",
"SansSerif"
};
private static final String TEXT = "A logica font example";
public TestBoxxer()
{
super("Font Examples");
setSize(700, 400);
show();
addWindowListener(new WindowCloser());
//setLocationRelativeTo(this);
WCenterlization wc = new WCenterlization(this);
}
public void paint(Graphics g)
{
for (int i = 0; i < FONTS.length; i ++)
{
g.setFont(new Font(FONTS[i], Font.PLAIN, 12));
g.drawString(FONTS[i] + "(plain): " + TEXT, 10, 20*i + 40);
}
for (int i = 0; i < FONTS.length; i ++)
{
g.setFont(new Font(FONTS[i], Font.BOLD + Font.ITALIC, 14));
g.drawString(FONTS[i] + "(bold, italics): " + TEXT, 10, 20*i + 180);
}
}
public static void main(String args[])
{
TestBoxxer fe = new TestBoxxer();
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -