📄 wrc.java.txt
字号:
TestFrame.java //显示空的窗口
import javax.swing.JFrame;
public class TestFrame extends JFrame {
/**
* @param args
*/
public static void main(String[] args) {
TestFrame tf=new TestFrame();
tf.setTitle("testframe");
tf.setSize(400,300);
tf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tf.setLocationRelativeTo(null);
tf.setVisible(true);
}
}
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel; //加按钮
public class TestFrame extends JFrame {
/**
* @param args
*/
public TestFrame()
{
JPanel jp = new JPanel();
JButton jb = new JButton("OK");
JButton jb1 = new JButton("CANCEL");
jp.add(jb);
jp.add(jb1);
this.getContentPane().add(jp);
}
public static void main(String[] args) {
TestFrame tf=new TestFrame();
tf.setTitle("testframe");
tf.setSize(400,300);
tf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tf.setLocationRelativeTo(null);
tf.setVisible(true);
}
}
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField; //再加彩色信息
public class TestFrame extends JFrame {
/**
* @param args
*/
public TestFrame()
{
JPanel jp = new JPanel();
JButton jb = new JButton("OK");
JButton jb1 = new JButton("CANCEL");
jp.add(jb);
jp.add(jb1);
this.getContentPane().add(jp);
JTextField jt=new JTextField("Hello World!");
jp.add(jt);
jt.setForeground(new Color(222,2,2));
}
public static void main(String[] args) {
TestFrame tf=new TestFrame();
tf.setTitle("testframe");
tf.setSize(400,300);
tf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tf.setLocationRelativeTo(null);
tf.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -