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

📄 bsprefsdialog.java

📁 一款即时通讯软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

        JPanel filePanel = new JPanel(new GridBagLayout());

        JLabel label = new JLabel("File (HTTP) server:");
        gbc = new GridBagConstraints();
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        filePanel.add(label, gbc);
        fileServerTextField = new JTextField(fileServer);
        gbc = new GridBagConstraints();
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weightx = 1;
        filePanel.add(fileServerTextField, gbc);

        label = new JLabel("File server upload path:");
        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        filePanel.add(label, gbc);
        fileServerPathTextField = new JTextField(fileServerPath);
        gbc = new GridBagConstraints();
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        filePanel.add(fileServerPathTextField, gbc);

        label = new JLabel("File server port:");
        gbc = new GridBagConstraints();
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.WEST;
        filePanel.add(label, gbc);
        fileServerPortTextField = new JTextField(fileServerPort);
        gbc = new GridBagConstraints();
        gbc.gridy = 5;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        filePanel.add(fileServerPortTextField, gbc);

        label = new JLabel("Proxy server:");
        gbc = new GridBagConstraints();
        gbc.gridy = 6;
        gbc.anchor = GridBagConstraints.WEST;
        filePanel.add(label, gbc);
        proxyTextField = new JTextField(proxy);
        gbc = new GridBagConstraints();
        gbc.gridy = 7;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        filePanel.add(proxyTextField, gbc);

        label = new JLabel("Proxy port:");
        gbc = new GridBagConstraints();
        gbc.gridy = 8;
        gbc.anchor = GridBagConstraints.WEST;
        filePanel.add(label, gbc);
        proxyPortTextField = new JTextField(proxyPort);
        gbc = new GridBagConstraints();
        gbc.gridy = 9;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        filePanel.add(proxyPortTextField, gbc);

        tabbedPane.addTab("Send file", filePanel);
    }


    protected void initViewTab(boolean compactView, boolean onlyOnline,
                               boolean dockWindows, boolean showMsgsWin,
                               boolean forceMsgsIntoChat, boolean autoAway,
                               boolean showStatus, boolean showDebug,
                               boolean scrollTabs, String LAF) {

        GridBagConstraints gbc;

        JPanel viewPanel = new JPanel(new GridBagLayout());

        onlyOnlineCheckBox = new JCheckBox("Show only online users", onlyOnline);
        gbc = new GridBagConstraints();
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(onlyOnlineCheckBox, gbc);

        compactViewCheckBox = new JCheckBox("Use compact 1-menu view", compactView);
        gbc = new GridBagConstraints();
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(compactViewCheckBox, gbc);

        dockWindowsCheckBox = new JCheckBox("Auto-dock new windows", dockWindows);
        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(dockWindowsCheckBox, gbc);

        autoAwayCheckBox = new JCheckBox("Auto-away when screensaver running", autoAway);
        gbc = new GridBagConstraints();
        gbc.gridy = 3;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(autoAwayCheckBox, gbc);

        forceMsgsIntoChatCheckBox = new JCheckBox("Force messages into chat window", forceMsgsIntoChat);
        gbc = new GridBagConstraints();
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(forceMsgsIntoChatCheckBox, gbc);

        showMsgsWinCheckBox = new JCheckBox("Show messages window", showMsgsWin);
        gbc = new GridBagConstraints();
        gbc.gridy = 5;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(showMsgsWinCheckBox, gbc);

        showStatusCheckBox = new JCheckBox("Show status window", showStatus);
        gbc = new GridBagConstraints();
        gbc.gridy = 6;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(showStatusCheckBox, gbc);

        showDebugCheckBox = new JCheckBox("Show debug window", showDebug);
        gbc = new GridBagConstraints();
        gbc.gridy = 7;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(showDebugCheckBox, gbc);

        scrollTabsCheckBox = new JCheckBox("Use 1-row scrolling tabs", scrollTabs);
        gbc = new GridBagConstraints();
        gbc.gridy = 8;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(scrollTabsCheckBox, gbc);

        JLabel label = new JLabel("Look and feel (for change use menu):");
        gbc = new GridBagConstraints();
        gbc.gridy = 9;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(label, gbc);
        LAFTextField = new JTextField(LAF);
        LAFTextField.setEditable(false);
        gbc = new GridBagConstraints();
        gbc.gridy = 10;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        viewPanel.add(LAFTextField, gbc);

        //logoImgPathTextField = new JTextField(mainFrame.logoImgPath);

        tabbedPane.addTab("View", viewPanel);
    }

    protected void initPluginsTab(boolean pluginSimLink,
                                  boolean pluginBuddyFinder) {

        GridBagConstraints gbc;

        JPanel viewPanel = new JPanel(new GridBagLayout());

        JLabel label = new JLabel("Changes to options take effect on restart.");
        gbc = new GridBagConstraints();
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(label, gbc);

        simLinkCheckBox = new JCheckBox("SimLink", pluginSimLink);
        gbc = new GridBagConstraints();
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(simLinkCheckBox, gbc);

        buddyFinderCheckBox = new JCheckBox("BuddyFinder", pluginBuddyFinder);
        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        viewPanel.add(buddyFinderCheckBox, gbc);

        tabbedPane.addTab("Plugins", viewPanel);
    }

    protected void initAlertsTab(boolean autoSelect, String newMsgSoundFileName) {

        GridBagConstraints gbc;

        JPanel alertsPanel = new JPanel(new GridBagLayout());

        autoSelectCheckBox = new JCheckBox("Auto-popup new messages", autoSelect);
        gbc = new GridBagConstraints();
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        alertsPanel.add(autoSelectCheckBox, gbc);

        JLabel label = new JLabel("New message notification sound:");
        gbc = new GridBagConstraints();
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        alertsPanel.add(label, gbc);
        newMsgSoundFileNameTextField = new JTextField(newMsgSoundFileName);
        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weightx = 1;
        alertsPanel.add(newMsgSoundFileNameTextField, gbc);

        tabbedPane.addTab("Alerts", alertsPanel);
    }


    /*protected void initIXTab(String ixPropsPath) {

        GridBagConstraints gbc;

        JPanel ixPanel = new JPanel(new GridBagLayout());

        JLabel label = new JLabel("Default conferencing server:");
        gbc = new GridBagConstraints();
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        ixPanel.add(label, gbc);
        ixPropsTextField = new JTextField(ixPropsPath);
        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weightx = 1;
        ixPanel.add(ixPropsTextField, gbc);

        tabbedPane.addTab("IX panels", ixPanel);
    }*/

    /** Adds preferences tabs (JComponents) with names (Strings) */
    public void addPrefTabs(Vector components, Vector names) {
        int num = (components.size() < names.size())? components.size() : names.size();
        for (int i=0; i < num; i++)
            tabbedPane.addTab((String)names.elementAt(i),
                              (JComponent)components.elementAt(i));
        pack();
        setLocationRelativeTo(mainFrame);
    }

    /** Validates entered values. */
    private void validateFields() {

        if (validateLogin() &&
            validateFile() &&
            validateView() &&
            validateAlerts() &&
            validatePlugins())

            setVisible(false);

        else
            username = null;
    }


    protected boolean validatePlugins()
    {
        pluginSimLink = simLinkCheckBox.isSelected();
        pluginBuddyFinder = buddyFinderCheckBox.isSelected();
        return true;
    }

    protected boolean validateLogin() {

        username = usernameTextField.getText();
        password = new String(passwordField.getPassword());
        resource = resourceTextField.getText();
        server = serverTextField.getText();

        try {
            port = Integer.parseInt(portTextField.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this,
                                          "Port must be a number",
                                          "Error",
                                          JOptionPane.ERROR_MESSAGE);
            return false;
        }

        useSSL = useSSLCheckBox.isSelected();
        priority = ((Integer)priorityComboBox.getSelectedItem()).intValue();
        autoLogin = autoLoginCheckBox.isSelected();

        return true;
    }


    protected boolean validateFile() {

        fileServer = fileServerTextField.getText();
        fileServerPath = fileServerPathTextField.getText();
        fileServerPort = fileServerPortTextField.getText();

        proxy = proxyTextField.getText();
        proxyPort = proxyPortTextField.getText();

        return true;
    }

    protected boolean validateView() {

        compactView = compactViewCheckBox.isSelected();
        onlyOnline = onlyOnlineCheckBox.isSelected();
        forceMsgsIntoChat = forceMsgsIntoChatCheckBox.isSelected();
        autoAway = autoAwayCheckBox.isSelected();
        dockWindows = dockWindowsCheckBox.isSelected();
        showMsgsWin = showMsgsWinCheckBox.isSelected();
        showStatus = showStatusCheckBox.isSelected();
        showDebug = showDebugCheckBox.isSelected();
        scrollTabs = scrollTabsCheckBox.isSelected();
        LAF = LAFTextField.getText();
        //logoImgPath = logoImgPathTextField.getText();

        return true;
    }


    protected boolean validateAlerts() {

        autoSelect = autoSelectCheckBox.isSelected();
        newMsgSoundFileName = newMsgSoundFileNameTextField.getText();

        return true;
    }


    /*protected void validateIXPanels() {

        ixPropsPath = ixPropsTextField.getText();

        return true;
    }*/

}

⌨️ 快捷键说明

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