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

📄 configdialog.java

📁 jxta_src_2.41b jxta 2.41b 最新版源码 from www.jxta.org
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *  Panel implementing paged tabs.     **/    static class PagesPanel extends Panel implements ActionListener {        private final CardLayout layout;        private final Panel pages;        private final Panel buttons;                public PagesPanel() {            super(new BorderLayout());            layout = new CardLayout();            pages = new Panel(layout);            buttons = new Panel(new FlowLayout(FlowLayout.LEFT, 0, 0));                        add(pages, BorderLayout.CENTER);            add(buttons, BorderLayout.NORTH);        }                /**         *  {@inheritDoc}         **/        public void actionPerformed(ActionEvent e) {            layout.show(pages, e.getActionCommand());        }                public PanelGBL addPage(String buttonName, String comment) {            BorderPanelGBL p = new BorderPanelGBL(buttonName, comment, BorderPanelGBL.RAISED);                        pages.add(p, buttonName);            Button b = new Button(buttonName);                        buttons.add(b);            b.addActionListener(this);            return p;        }                public void showPage(String pageName) {            layout.show(pages, pageName);        }    }            /**     *  Allows for entry of a host address and port number. Besides the host     *  address and port number text fields there are two optional features:     *     *  <p/><ul>     *      <li>A checkbox with annotation to enable/disable the control.</li>     *      <li>A label for the address.</li>     *  </ul>     **/    static class HostPortPanel extends Panel implements ItemListener {                private final Checkbox  useMe;                private Label addressLabel = null;                private final TextField host;        private final TextField port;                HostPortPanel(String checkLabel, String addrLabel, String defaultHost, String defaultPort, boolean defaultState) {                        super(new GridBagLayout());                        useMe = new Checkbox(checkLabel, defaultState);            host = new TextField(defaultHost, 25);            port = new TextField(defaultPort, 6);                        GridBagConstraints constraints = new GridBagConstraints();                        constraints.weightx = 1.0;            constraints.weighty = 1.0;                        constraints.gridx = 0;            constraints.gridy = 0;            constraints.gridwidth = (null == addrLabel) ? 2 : 3;            constraints.anchor = GridBagConstraints.FIRST_LINE_START;                        if (null != checkLabel) {                add(useMe, constraints);                // if check label and addr label then use 2 lines.                if (null != addrLabel) {                    constraints.gridy++;                    constraints.gridx = 0;                    constraints.anchor = GridBagConstraints.LAST_LINE_START;                } else {                    constraints.gridx++;                    constraints.gridx = GridBagConstraints.RELATIVE;                }            }                        if (null != addrLabel) {                constraints.gridwidth = 1;                addressLabel = new Label(addrLabel, Label.RIGHT);                add(addressLabel, constraints);            }                        constraints.gridx = GridBagConstraints.RELATIVE;                        add(host, constraints);            add(port, constraints);                        setState(defaultState);            useMe.addItemListener(this);        }                /**         *  {@inheritDoc}         **/        public void itemStateChanged(ItemEvent e) {            setState(useMe.getState());        }                /**         *  {@inheritDoc}         **/        public boolean getState() {            return useMe.getState() && isEnabled();        }                /**         *  {@inheritDoc}         **/        public void setEnabled(boolean enabling) {            super.setEnabled(enabling);                        useMe.setEnabled(enabling);                        if (null != addressLabel) {                addressLabel.setEnabled(useMe.getState());            }                        host.setEnabled(useMe.getState());            port.setEnabled(useMe.getState());        }                /**         *  {@inheritDoc}         **/        public void setState(boolean state) {            useMe.setState(state); // sometimes redundant but not always.                        if (null != addressLabel) {                addressLabel.setEnabled(state);            }                        host.setEnabled(state);            port.setEnabled(state);        }                /**         *  Returns the value of the host field         **/        public String getHost() {            return host.getText().trim();        }                /**         *  Returns the value of the port field         **/        public String getPort() {            return port.getText().trim();        }    }            /**     *  A list of URIs     **/    static class HostListPanel extends Panel implements ActionListener {                private final String purpose;        private final TextField host;        private final TextField port;        private final java.awt.List list;        private final Label listLabel;                private final Button insert;        private final Button remove;                public HostListPanel(String purpose, String lstLabel, boolean defaultState, boolean showPort) {                        super(new GridBagLayout());            this.purpose = purpose;                        host = new TextField("", showPort ? 25 : 30);            if (showPort) {                port = new TextField("", 5);            } else {                port = null;            }            insert = new Button("+");            remove = new Button("-");                        list = new java.awt.List(2, true);            listLabel = new Label(lstLabel);                        GridBagConstraints c1 = new GridBagConstraints();                        c1.gridx = 0;            c1.gridy = 0;            c1.anchor = GridBagConstraints.FIRST_LINE_START;            c1.fill = GridBagConstraints.NONE;            add(listLabel, c1);                        c1.gridx = 0;            c1.gridy++;            if (!showPort) {                c1.gridwidth = 2;            }            c1.weightx = 2.0;            c1.anchor = GridBagConstraints.LINE_START;            c1.fill = GridBagConstraints.HORIZONTAL;            add(host, c1);                        if (showPort) {                c1.weightx = 0.0;                c1.gridx = 1;                c1.anchor = GridBagConstraints.LINE_END;                c1.fill = GridBagConstraints.NONE;                add(port, c1);            }                        c1.gridx = 0;            c1.gridy++;            c1.gridwidth = 1;            c1.weightx = 2.0;            c1.anchor = GridBagConstraints.LAST_LINE_START;            c1.fill = GridBagConstraints.HORIZONTAL;            add(list, c1);                        Panel p2 = new Panel(new GridLayout(2, 1, 1, 1));                        p2.add(insert);            p2.add(remove);                        c1.gridx++;            c1.weightx = 0.0;            c1.anchor = GridBagConstraints.LAST_LINE_END;            c1.fill = GridBagConstraints.NONE;            c1.insets = new Insets(0, 4, 0, 1);            add(p2, c1);                        host.addActionListener(this);            insert.addActionListener(this);            remove.addActionListener(this);            list.addActionListener(this);                        setEnabled(defaultState);        }                /**         *  {@inheritDoc}         **/        public void setEnabled(boolean state) {            super.setEnabled(state);                        listLabel.setEnabled(state);            host.setEnabled(state);            if (null != port) {                port.setEnabled(state);            }            list.setEnabled(state);            insert.setEnabled(state);            remove.setEnabled(state);        }                /**         *  {@inheritDoc}         **/        public boolean isEnabled() {            return listLabel.isEnabled();        }                /**         *  {@inheritDoc}         **/        public void actionPerformed(ActionEvent e) {            if ((insert == e.getSource()) || (host == e.getSource())) {                StringBuffer addHost = new StringBuffer(host.getText());                                if (null != port) {                    String portText = port.getText().trim();                                        if (portText.length() > 0) {                        // if( !verifyPort( "Host port", portText, false ) ) {                        // return;                        // }                        addHost.append(':');                        addHost.append(portText);                    }                }                                if (addItem(addHost.toString())) {                    host.setText("");                    host.setCaretPosition(0);                    if (null != port) {                        port.setText("");                        port.setCaretPosition(0);                    }                }                                return;            }                        if (e.getSource() == remove) {                int[] sel = list.getSelectedIndexes();                int i = sel.length;                                while (i-- > 0) {                    list.remove(sel[i]);                }                                return;            }                        // double click on a host in the list            if (e.getSource() == list) {                String cmd = e.getActionCommand();                                if (null != port) {                    int colonAt = cmd.lastIndexOf(':');                    String newHost = cmd.substring(0, colonAt);                    String newPort = cmd.substring(colonAt + 1);                                        host.setText(newHost);                    host.setCaretPosition(newHost.length());                    port.setText(newPort);                    port.setCaretPosition(newHost.length());                } else {                    host.setText(cmd);                    host.setCaretPosition(cmd.length());                }                                return;            }        }                public boolean addItem(String item) {            String hostURI = item.trim();                        if( 0 == hostURI.trim().length() ) {                return false;            }                        try {                URI uri = new URI( hostURI );            } catch( URISyntaxException failed ) {                return false;            }                        try {                while (true) {                    try {                        list.remove(hostURI);                    } catch (IllegalArgumentException notThere) {                        break;                    }                }                                list.add(hostURI);            } catch (Exception e) {                return false;            }                        return true;        }                public String getPurpose() {            return purpose;        }                public String[] getItems() {            return list.getItems();        }    }            /**     *  An interface and port selection panel.     **/    static class IfAddrPanel extends Panel implements ItemListener {        private final Checkbox manual;        

⌨️ 快捷键说明

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