?? statusbar.java
字號:
import java.awt.*;import java.awt.event.*;/** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */public class StatusBar extends Panel { final Color BAKCOLOR=new Color(80,123,166); TFrame m_tFrame; Button button1 = new Button(); TextArea textArea1 = new TextArea("",3,0,TextArea.SCROLLBARS_NONE); TextField textField1 = new TextField(); Label label1 = new Label(); public StatusBar(TFrame tframe) { m_tFrame=tframe; try { jbInit(); myInit(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { Frame f=new Frame(); StatusBar statusBar1 = new StatusBar(new TFrame()); f.add(statusBar1); f.show(); } private void myInit() { this.setBackground(BAKCOLOR); textArea1.setBackground(BAKCOLOR); textField1.setBackground(BAKCOLOR); } private void jbInit() throws Exception { label1.setText("請輸入現(xiàn)在要發(fā)送的消息"); label1.setBounds(new Rectangle(11, 71, 133, 18)); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); button1.setBackground(SystemColor.menu); button1.setLabel("發(fā)送"); button1.setBounds(new Rectangle(632, 68, 75, 29)); this.setLayout(null); textArea1.setRows(3); textArea1.setBounds(new Rectangle(25, 6, 732, 57)); textField1.setBounds(new Rectangle(157, 71, 460, 22)); textField1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(KeyEvent e) { textField1_keyPressed(e); } }); this.setBackground(SystemColor.menu); this.add(textArea1, null); this.add(label1, null); this.add(button1, null); this.add(textField1, null); } void button1_actionPerformed(ActionEvent e) { String str=textField1.getText().trim(); textArea1.append(str+"\n"); sendStr("Talk:"+str); } void textField1_keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_ENTER) { String str=textField1.getText().trim(); textArea1.append(str+"\n"); sendStr("Talk:"+str); } } public void appendStr(String str) { textArea1.append(str); } public void sendStr(String str) { m_tFrame.sendStr(str); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -