Popular Posts
Build an OpenVPN server on android device Preparation An android device, in this case, Sony xperia Z is used Root permission required Linux Deploy for deploy i... javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... netbean shortcut Ctrl + F:尋找 F3:尋找下一個字串 Ctrl + G:跳到第 N 行 Ctrl + H:取代 Tab:增加縮排 Shift + Tab:減少縮排 Ctrl + E:刪除一行 Ctrl + Shift + I:修正 import 項目 Alt + Ent...
Stats
ListSelectionListener & ItemListener
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.DefaultListModel;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class StatusChange extends JFrame {

    public StatusChange() {
        getContentPane().setLayout(new FlowLayout());

        DefaultListModel model = new DefaultListModel();
        JList list = new JList(model);
        model.addElement("one");
        model.addElement("two");
        model.addElement("three");
        model.addElement("four");
        model.addElement("five");
        model.addElement("six");
        model.addElement("seven");
        model.addElement("eight");
        model.addElement("nine");
        list.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                JList list = (JList) e.getSource();

                // execute twice
                System.out.printf("=====%s=====%n", list.getSelectedValue());
                if (list.getValueIsAdjusting()) {
                    // execute once
                    System.out.println(list.getSelectedValue());
                }
            }
        });
        getContentPane().add(new JScrollPane(list));

        JComboBox combo = new JComboBox();
        combo.addItem("one");
        combo.addItem("two");
        combo.addItem("three");
        combo.addItem("four");
        combo.addItem("five");
        combo.addItem("six");
        combo.addItem("seven");
        combo.addItem("eight");
        combo.addItem("nine");

        combo.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                JComboBox combo = (JComboBox) e.getSource();
                // execute twice (occurs on selected & deselected)
                System.out.printf("-----%s-----%n", combo.getSelectedItem());
                if (e.getStateChange() == e.SELECTED) {
                    // execute once
                    System.out.println(combo.getSelectedItem());
                }
            }
        });
        getContentPane().add(combo);

        pack();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screen.width - this.getWidth()) / 2, (screen.height - this.getHeight()) / 2);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new StatusChange();
    }

}
Start JBoss failed on eclipse (timeout)

jboss-4.0.5.GA\server\default\deploy\jbossweb-tomcat55.sar\server.xml
<Connector port="8888" address="${jboss.bind.address}"
 maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
 emptySessionPath="true"
 enableLookups="false" redirectPort="8443" acceptCount="100"
 connectionTimeout="20000" disableUploadTimeout="true"/>
Server port must match with each other. If not matched, eclipse can't detect server status when jboss has been started.