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

📄 datatransferpreferencespanel.java

📁 网站即时通讯系统
💻 JAVA
字号:
package com.valhalla.jbother.preferences;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.util.Locale;import java.util.ResourceBundle;import javax.swing.BorderFactory;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import com.valhalla.gui.MJTextField;import com.valhalla.settings.Settings;import com.valhalla.settings.TempSettings;/** * Created by luke on Feb 2, 2005 5:36:43 PM *//** * preferences panel for file transfer-related settings. */public class DataTransferPreferencesPanel extends JPanel implements        PreferencesPanel {    private static String fId = "$Id$";    private ResourceBundle resources = ResourceBundle.getBundle(            "JBotherBundle", Locale.getDefault());    private GridBagLayout grid = new GridBagLayout();    private GridBagConstraints c = new GridBagConstraints();    private JLabel dataPortLabel = new JLabel(resources.getString("dataPort")            + ":");    private JLabel dataInterfaceLabel = new JLabel(resources            .getString("dataInterface")            + ":");    private MJTextField dataPortTF = new MJTextField(5);    private MJTextField dataInterfaceTF = new MJTextField(15);    public DataTransferPreferencesPanel(PreferencesDialog dialog) {        dataPortLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));        dataInterfaceLabel.setBorder(BorderFactory                .createEmptyBorder(0, 5, 0, 5));        setBorder(BorderFactory.createTitledBorder(resources                .getString("dataTransfer")));        setLayout(grid);        c.gridx = 0;        c.gridy = 0;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        c.gridwidth = 1;        // port        c.weightx = 0.0;        grid.setConstraints(dataPortLabel, c);        add(dataPortLabel);        c.gridx++;        grid.setConstraints(dataPortTF, c);        add(dataPortTF);        // interface        c.gridwidth = 1;        c.fill = GridBagConstraints.HORIZONTAL;        c.gridx = 0;        c.gridy++;        grid.setConstraints(dataInterfaceLabel, c);        add(dataInterfaceLabel);        c.gridx = 1;        c.gridy = 1;        grid.setConstraints(dataInterfaceTF, c);        add(dataInterfaceTF);        c.gridx = 2;        c.gridy = 2;        c.weightx = 1.0;        c.weighty = 1.0;        c.gridwidth = 2;        JLabel emptyLabel = new JLabel("");        grid.setConstraints(emptyLabel, c);        add(emptyLabel);        loadSettings();    }    public TempSettings getSettings() {        TempSettings mySettings = new TempSettings();        String portNumberStr = dataPortTF.getText();        try {            int port = Integer.parseInt(portNumberStr);        } catch (NumberFormatException e) {            portNumberStr = resources.getString("dataPortDefault");            JOptionPane optionPane = new JOptionPane(                    "Wrong portnumber, reverting to default",                    JOptionPane.INFORMATION_MESSAGE);            optionPane.createDialog(this, "Warning");        }        mySettings.setProperty("dataPort", portNumberStr);        // @todo: better parsing of interface        String iface = ((dataInterfaceTF.getText().trim().length() == 0) ? "127.0.0.1"                : dataInterfaceTF.getText().trim());        mySettings.setProperty("dataInterface", iface);        return mySettings;    }    private void loadSettings() {        dataPortTF.setText(Settings.getInstance().getProperty("dataPort"));        dataInterfaceTF.setText(Settings.getInstance().getProperty(                "dataInterface"));    }}

⌨️ 快捷键说明

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