?? ch9_35.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ch9_35 extends JFrame implements ActionListener
{
JTextArea jt;
JButton b1,b2,b3,b4;
public ch9_35()
{
setBounds(20,20,500,300);
getContentPane().setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String [] args)
{
ch9_35 f=new ch9_35();
f.getContentPane().setLayout(null);
f.jt=new JTextArea("fsdfasdfasdf");
f.jt.setBounds(20,20,100,80);
f.b1=new JButton("getText");
f.b1.setBounds(20,110,100,40);
f.b2=new JButton("select()");
f.b2.setBounds(130,110,100,40);
f.b3=new JButton("selectall");
f.b3.setBounds(230,110,100,40);
f.b4=new JButton("setEditable");
f.b4.setBounds(20,150,100,40);
f.b1.addActionListener(f);
f.b2.addActionListener(f);
f.b3.addActionListener(f);
f.b4.addActionListener(f);
f.getContentPane().add(f.jt);
f.getContentPane().add(f.b1);
f.getContentPane().add(f.b2);
f.getContentPane().add(f.b3);
f.getContentPane().add(f.b4);
f.show();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
System.out.println(jt.getSelectedText());
System.out.println(jt.getText());
}
if(e.getSource()==b2)
{
jt.select(2,6);
}
if(e.getSource()==b3)
{
jt.selectAll();
}
if(e.getSource()==b4)
{
jt.setText("你好");
jt.setEditable(false);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -