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

📄 sysconfig.java

📁 java swing 开发代码
💻 JAVA
字号:
// SysConfig.java// A demonstration of the JTabbedPane class for displaying and manipulating// configuration information. The BoxLayout class is used to layout the// first tab quickly.//package	jswing.ch11;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class SysConfig extends JFrame {  JTabbedPane config = new JTabbedPane();    public SysConfig() {    super("JTabbedPane & BoxLayout Demonstration");    setSize(500,300);    setDefaultCloseOperation(EXIT_ON_CLOSE);    JPanel configPane = new JPanel();    configPane.setLayout(new BoxLayout(configPane, BoxLayout.Y_AXIS));    JTextArea question = new JTextArea("Which of the following options\n" +                                       "do you have installed?");    // Ok, now configure the textarea to show up properly inside the box.    // This is part of the "high art" of Swing...    question.setEditable(false);    question.setMaximumSize(new Dimension(300,50));    question.setAlignmentX(0.0f);    question.setBackground(configPane.getBackground());    JCheckBox audioCB = new JCheckBox("Sound Card", true);    JCheckBox nicCB = new JCheckBox("Ethernet Card", true);    JCheckBox tvCB = new JCheckBox("Video Out", false);    configPane.add(Box.createVerticalGlue());    configPane.add(question);    configPane.add(audioCB);    configPane.add(nicCB);    configPane.add(tvCB);    configPane.add(Box.createVerticalGlue());    JLabel audioPane = new JLabel("Audio stuff");    JLabel nicPane = new JLabel("Networking stuff");    JLabel tvPane = new JLabel("Video stuff");    JLabel helpPane = new JLabel("Help information");    audioCB.addItemListener(new TabManager(audioPane));    nicCB.addItemListener(new TabManager(nicPane));    tvCB.addItemListener(new TabManager(tvPane));    config.addTab("System", null, configPane, "Choose Installed Options");    config.addTab("Audio", null, audioPane, "Audio system configuration");    config.addTab("Networking", null, nicPane, "Networking configuration");    config.addTab("Video", null, tvPane, "Video system configuration");    config.addTab("Help", null, helpPane, "How Do I...");    getContentPane().add(config, BorderLayout.CENTER);  }  class TabManager implements ItemListener {    Component tab;    public TabManager(Component tabToManage) {      tab = tabToManage;    }    public void itemStateChanged(ItemEvent ie) {      int index = config.indexOfComponent(tab);      if (index != -1) {        config.setEnabledAt(index, ie.getStateChange() == ItemEvent.SELECTED);      }      SysConfig.this.repaint();    }  }  public static void main(String args[]) {    SysConfig sc = new SysConfig();    sc.setVisible(true);  }}

⌨️ 快捷键说明

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