📄 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("请输入现在要发送的消息"); 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("发送"); 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); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -