⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 telephone.java

📁 这个是学习网络编程的好好文档! 里面有一些老师发给的学习jsp的课件!
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;

class Telephone extends JFrame
{
  public Telephone()
  {
    super("Telephone GUI Demo");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    initSpeakerPanel();
    initKeyPanel();
    initMicphonePanel();
    
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(speakerPanel,BorderLayout.NORTH);
    pane.add(keyPanel,BorderLayout.CENTER);
    pane.add(micphonePanel,BorderLayout.SOUTH);
    
    pack();
    setVisible(true);
  }

  private void initSpeakerPanel()
  {
    speakerPanel = new JPanel();
    speakerPanel.setLayout(new BorderLayout());
    JLabel label = new JLabel("Speaker: ");
    label.setFont(font);
    speakerPanel.add(label,BorderLayout.NORTH);
    speakerArea = new JTextArea(5,15);
    speakerPanel.add(speakerArea,BorderLayout.CENTER);
  }
  
  private void initKeyPanel()
  {
    String keyLabels = "123456789*0#";
    keyPanel = new JPanel();
    keyPanel.setLayout(new GridLayout(4,3));
    for(int i=0;i<keyLabels.length();i++)
    {
      String label = keyLabels.substring(i,i+1);
      JButton b = new JButton(label);
      b.setFont(font);
      //b.addActionListener(...);  
      keyPanel.add(b);
    }
  }

  private void initMicphonePanel()
  {
    micphonePanel = new JPanel();
    micphonePanel.setLayout(new BorderLayout());
    JLabel label = new JLabel("Micphone: ");
    label.setFont(font);
    micphonePanel.add(label,BorderLayout.NORTH);
    micphoneArea = new JTextArea(5,15);
    micphonePanel.add(micphoneArea,BorderLayout.CENTER);

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    speechButton = new JButton("Speech");
    speechButton.setFont(font);
    //speechButton.addActionListener(...);
    hangupButton = new JButton("Hangup");
    hangupButton.setFont(font);
    //hangupButton.addActionListener(...);
    buttonPanel.add(speechButton);
    buttonPanel.add(hangupButton);
    
    micphonePanel.add(buttonPanel,BorderLayout.SOUTH);
  }
    
  private JPanel speakerPanel;
  private JTextArea speakerArea;
  
  private JPanel keyPanel;
  private JPanel micphonePanel;
  private JTextArea micphoneArea;
  
  private JPanel buttonPanel;
  private JButton speechButton;
  private JButton hangupButton;
  
  private Font font = new Font("Dialog",Font.BOLD,18);
}

class tester
{
  public static void main(String[] args)
  {
    new Telephone();
  }
}    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -