?? statusbar.java
字號:
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;/** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */public class StatusBar extends JPanel { final Color BAKCOLOR=new Color(80,123,166); TFrame m_tFrame; JButton button1 = new JButton(); JTextArea textArea1 = new JTextArea("",3,0); JTextField textField1 = new JTextField(); JLabel label1 = new JLabel(); Border border1; 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 { border1 = BorderFactory.createMatteBorder(1,1,1,1,Color.white); label1.setBackground(new Color(80, 123, 166)); label1.setForeground(SystemColor.menu); label1.setText("請輸入現在要發送的消息"); label1.setBounds(new Rectangle(12, 71, 143, 18)); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); button1.setForeground(SystemColor.menu); button1.setBorder(border1); button1.setBackground(new Color(80, 123, 166)); button1.setLabel("發送"); button1.setBounds(new Rectangle(640, 68, 75, 29)); this.setLayout(null); textArea1.setRows(3); textArea1.setBorder(BorderFactory.createLineBorder(Color.white)); textArea1.setBounds(new Rectangle(13, 7, 732, 57)); textField1.setBorder(BorderFactory.createLineBorder(Color.white)); textField1.setBounds(new Rectangle(169, 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(button1, null); this.add(textField1, null); this.add(label1, 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 + -