Package charvax.swing

Examples of charvax.swing.DefaultListModel


                    BorderLayout.NORTH);

            String[] vehicles = { "Volkswagen", "Rolls-Royce", "Toyota",
                    "Chrysler", "Mercedes Benz", "Bentley", "Bugatti",
                    "Maserati", "Porsche"};
            DefaultListModel model = new DefaultListModel();
            int columns = 0;
            for (int i = 0; i < vehicles.length; i++) {
                model.addElement(vehicles[ i]);
                if (vehicles[ i].length() > columns)
                        columns = vehicles[ i].length();
            }
            model.addListDataListener(this);

            _vehicleList = new JList(model);
            _vehicleList.setVisibleRowCount(5);
            _vehicleList.setColumns(columns);
            _vehicleList.addListSelectionListener(this);
View Full Code Here


            String cmd = e_.getActionCommand();
            if (cmd.equals("Delete")) {
                int[] indices = _vehicleList.getSelectedIndices();
                if (indices.length == 0) return; // there is no selected item

                DefaultListModel model = (DefaultListModel) _vehicleList
                        .getModel();

                // We must remove the last elements first, otherwise
                // (if we remove an element with a low index), the
                // higher indices will be invalid.
                for (int i = indices.length - 1; i >= 0; i--) {
                    model.removeElementAt(indices[ i]);
                }

                // Having deleted some elements from the list, we must
                // ensure that:
                // (a) the first index inside the visible area is >= 0
View Full Code Here

        this.cols = cols;
        this.setSize(new Dimension(cols, rows));

        jlist = new JList();
        jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jlist.setModel(new DefaultListModel());
        jlist.setVisibleRowCount(rows - 2);

        jlist.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent evt) {
                //Object o = list.elementAt(evt.getFirstIndex());
View Full Code Here

TOP

Related Classes of charvax.swing.DefaultListModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.