tool.java
来自「Usefull sample codes for Java. Containt 」· Java 代码 · 共 41 行
JAVA
41 行
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tool extends JFrame {
public Tool() {
super("Tool");
setSize(370, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// build toolbar buttons
ImageIcon image1 = new ImageIcon("newfile.gif");
JButton button1 = new JButton(image1);
ImageIcon image2 = new ImageIcon("openfile.gif");
JButton button2 = new JButton(image2);
ImageIcon image3 = new ImageIcon("savefile.gif");
JButton button3 = new JButton(image3);
// build toolbar
JToolBar bar = new JToolBar();
bar.add(button1);
bar.add(button2);
bar.add(button3);
// build text area
JTextArea edit = new JTextArea(8, 40);
JScrollPane scroll = new JScrollPane(edit);
// create frame
BorderLayout border = new BorderLayout();
setLayout(border);
add("North", bar);
add("Center", scroll);
setVisible(true);
}
public static void main(String[] arguments) {
Tool frame = new Tool();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?