📄 inputframe.java
字号:
package com.king4solomon.homework.compiler.pvm;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.king4solomon.homework.compiler.gui.*;
@SuppressWarnings("serial")
public class InputFrame extends JFrame implements ActionListener {
public InputFrame(String type) {
super("Input a "+type);
/**
* 用于获取屏幕尺寸以规定默认的显示位置
*/
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
setSize(300, 100);
setLocation(screenSize.width / 3, screenSize.height / 3);
JPanel pane = new JPanel();
input.setPreferredSize(new Dimension(260, 20));
JPanel pane1 = new JPanel();
pane1.setSize(20, 20);
JPanel pane2 = new JPanel();
pane2.setSize(20, 20);
pane.add(input, BorderLayout.CENTER);
pane.add(button, BorderLayout.SOUTH);
pane.add(pane1, BorderLayout.EAST);
pane.add(pane2, BorderLayout.WEST);
button.addActionListener(this);
add(pane);
setVisible(true);
}
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(button)) {
buf = input.getText();
input.setText("");
if (Interpreter.isDebug)
HandoutFrame.tb10.setEnabled(true);
thr.resume();
dispose();
}
}
public static String getValue() {
return input.getText();
}
public static void setThread(Thread t) {
thr = t;
}
public String buf = new String();
public static Thread thr;
public static JTextArea input = new JTextArea();
public static JButton button = new JButton("Input");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -