📄 statusbar.java~44~
字号:
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.setText("请输入现在要发送的消息"); label1.setForeground(SystemColor.menu); label1.setBounds(new Rectangle(11, 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(632, 68, 75, 29)); this.setLayout(null); textArea1.setRows(3); textArea1.setBorder(BorderFactory.createLineBorder(Color.white)); textArea1.setBounds(new Rectangle(1, 5, 732, 57)); textField1.setBorder(BorderFactory.createLineBorder(Color.white)); 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(label1, null); this.add(button1, null); this.add(textField1, null); this.add(textArea1, 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 + -