Java 类javax.swing.ListSelectionModel 实例源码

项目:myster    文件:JMCList.java   
public void setSelectionInterval(int index0, int index1) {
    clearSelection();
    if (selectionMode == ListSelectionModel.SINGLE_SELECTION) {
        modifySelectionInterval(index0, index1, true);
    } else {
        modifySelectionInterval(index1, index1, true);
    }
    fireValueChanged();
}
项目:litiengine    文件:JCheckBoxList.java   
public JCheckBoxList() {
  setCellRenderer(new CellRenderer());
  addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      int index = locationToIndex(e.getPoint());
      if (index != -1) {
        JCheckBox checkbox = getModel().getElementAt(index);

        if (e.getPoint().x < checkbox.getHorizontalTextPosition()) {

          checkbox.setSelected(!checkbox.isSelected());
        }
        repaint();
      }
    }
  });
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
项目:DeutschSim    文件:QubitTable.java   
public QubitTable(final int row_height) {
    setFont(new Font("Tahoma", Font.PLAIN, 12));
    setRowHeight(row_height);
    setFocusable(false);
    setRowSelectionAllowed(false);
    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    setTableHeader(null);
    setModel(new DefaultTableModel(new Object[][] {{"|0>"}}, new String[] {""}));

    update_col_width();

    qubits = "0";
}
项目:incubator-netbeans    文件:AntNavigatorPanel.java   
public JComponent getComponent() {
    if (panel == null) {
        final ListView view = new ListView();
        view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
            // Make sure action context works correctly:
            {
                setLayout(new BorderLayout());
                add(view, BorderLayout.CENTER);
            }
            public ExplorerManager getExplorerManager() {
                return manager;
            }
            @Override
            public boolean requestFocusInWindow() {
                return view.requestFocusInWindow();
            }
            public Lookup getLookup() {
                return lookup;
            }
        }
        panel = new Panel();
    }
    return panel;
}
项目:zencash-swing-wallet-ui    文件:AddressBookPanel.java   
private JScrollPane buildTablePanel() {
      table = new JTable(new AddressBookTableModel(),new DefaultTableColumnModel());
      TableColumn nameColumn = new TableColumn(0);
      TableColumn addressColumn = new TableColumn(1);
      table.addColumn(nameColumn);
      table.addColumn(addressColumn);
      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // one at a time
      table.getSelectionModel().addListSelectionListener(new AddressListSelectionListener());
      table.addMouseListener(new AddressMouseListener());

      // TODO: isolate in utility
TableCellRenderer renderer = table.getCellRenderer(0, 0);
Component comp = renderer.getTableCellRendererComponent(table, "123", false, false, 0, 0);
table.setRowHeight(new Double(comp.getPreferredSize().getHeight()).intValue() + 2);

      JScrollPane scrollPane = new JScrollPane(table);
      return scrollPane;
  }
项目:incubator-netbeans    文件:JTableSelectionModelEditor.java   
@Override
public Node storeToXML(Document doc) {
    Object value = getValue();
    int selectionMode = -1;
    Object[] values = getEnumerationValues();
    if (values[4].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_SELECTION;
    } else if (values[7].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_INTERVAL_SELECTION;
    } else if (values[10].equals(value)) {
        selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
    }
    org.w3c.dom.Element el = null;
    el = doc.createElement(XML_TABLE_SELECTION_MODEL);
    el.setAttribute(ATTR_SELECTION_MODE, Integer.toString(selectionMode));
    return el;
}
项目:jmt    文件:ExactTable.java   
public void copyAnchorToSelection() {
    if ((getSelectedRowCount() == 0) && (getSelectedColumnCount() == 0)) {
        return;
    }
    if (dataModel instanceof ExactTableModel) {
        stopEditing();
        int rowFrom = selectionModel.getMinSelectionIndex();
        int rowTo = selectionModel.getMaxSelectionIndex();
        ListSelectionModel csm = columnModel.getSelectionModel();
        int colFrom = csm.getMinSelectionIndex();
        int colTo = csm.getMaxSelectionIndex();

        int anchorRow = selectionModel.getAnchorSelectionIndex();
        int anchorCol = csm.getAnchorSelectionIndex();

        ((ExactTableModel) dataModel).copyCellToArea(anchorRow, anchorCol, rowFrom, rowTo, colFrom, colTo);
        updateRows(rowFrom, rowTo);
        requestFocus();
    }
}
项目:routerapp    文件:OpenGraphDialog.java   
private JList<String> makeList(final String[][] items, int visibleRows, Container parent) {
    JList<String> list = new JList<>(new AbstractListModel<String>()    {
        /**
         * 
         */
        private static final long serialVersionUID = 6510576197401709714L;

        public String getElementAt(int i) {
            return items[i][0];             
        }

        public int getSize() {
            return items.length;
        }
    });

    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setVisibleRowCount(visibleRows);
    parent.add(new JScrollPane(list));
    return list;
}
项目:incubator-netbeans    文件:ListView.java   
public void run() {
    boolean multisel = (list.getSelectionMode() != ListSelectionModel.SINGLE_SELECTION);
    int i = (multisel ? list.getLeadSelectionIndex() : list.getSelectedIndex());

    if (i < 0) {
        return;
    }

    Point p = list.indexToLocation(i);

    if (p == null) {
        return;
    }

    createPopup(p.x, p.y, false);
}
项目:incubator-netbeans    文件:OutlineView.java   
/** 
 * Check if selection of the nodes could break
 * the selection mode set in the ListSelectionModel.
 * @param nodes the nodes for selection
 * @return true if the selection mode is broken
 */
private boolean isSelectionModeBroken(Node[] nodes) {

    // if nodes are empty or single then everthing is ok
    // or if discontiguous selection then everthing ok
    if (nodes.length <= 1 || outline.getSelectionModel().getSelectionMode() == 
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
        return false;
    }

    // if many nodes

    // breaks single selection mode
    if (outline.getSelectionModel().getSelectionMode() == 
        ListSelectionModel.SINGLE_SELECTION) {
        return true;
    }

    // check the contiguous selection mode

    // check selection's rows

    // all is ok
    return false;
}
项目:incubator-netbeans    文件:CategoryList.java   
/**
 * Constructor.
 */
CategoryList( Category category, PalettePanel palettePanel ) {
    this.category = category;
    this.palettePanel = palettePanel;
    if( isGTK || isNimbus ) {
        setBackground( new Color( UIManager.getColor("Tree.background").getRGB() ) );//NOI18N
        setOpaque(true);
    } else {
        if( "Aqua".equals(UIManager.getLookAndFeel().getID()) )
            setBackground(UIManager.getColor("NbExplorerView.background"));
        else
            setBackground(UIManager.getColor ("Panel.background"));
    }
    setBorder (new EmptyBorder (0, 0, 0, 0));
    setVisibleRowCount (0);
    setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
    setCellRenderer (getItemRenderer ());
    setLayoutOrientation( HORIZONTAL_WRAP );
    getAccessibleContext().setAccessibleName( category.getDisplayName() );
    getAccessibleContext().setAccessibleDescription( category.getShortDescription() );

    initActions();
}
项目:incubator-netbeans    文件:SelectInstallationPanel.java   
@NbBundle.Messages({
    "MSG_Detecting_Wait=Detecting installations, please wait..."
})
private void initList() {
    installationList.setListData(new Object[]{
        Bundle.MSG_Detecting_Wait()
    });
    installationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    installationList.setEnabled(false);

    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            final List<Installation> installations =
                    InstallationManager.detectAllInstallations();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    updateListForDetectedInstallations(installations);
                }
            });
        }
    });
}
项目:marathonv5    文件:RTableTest.java   
public void selectRows() throws Throwable {
    final JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            table.setRowSelectionAllowed(true);
            table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            table.addRowSelectionInterval(1, 1);
            table.addRowSelectionInterval(3, 3);
            table.addColumnSelectionInterval(0, 0);
            RTable rTable = new RTable(table, null, null, lr);
            rTable.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("rows:[1,3],columns:[First Name]", call.getState());
}
项目:Equella    文件:HarvesterProfileTool.java   
public PluginDialog()
{
    listModel = new DefaultListModel();

    list = new JList();
    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    for( String name : plugins.keySet() )
    {
        listModel.addElement(name);
    }

    setLayout(new BorderLayout());
    add(new JScrollPane(list));
}
项目:incubator-netbeans    文件:ErrorNavigatorProviderImpl.java   
public JComponent getComponent() {
    if (panel == null) {
        final BeanTreeView view = new BeanTreeView();
        view.setRootVisible(false);
        view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
            // Make sure action context works correctly:
            private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap());
            {
                setLayout(new BorderLayout());
                add(view, BorderLayout.CENTER);
            }
            public ExplorerManager getExplorerManager() {
                return manager;
            }
            public Lookup getLookup() {
                return lookup;
            }
        }
        panel = new Panel();
    }
    return panel;
}
项目:Equella    文件:SearchTool.java   
public PluginDialog()
{
    listModel = new DefaultListModel();

    list = new JList();
    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    for( String name : plugins.keySet() )
    {
        listModel.addElement(name);
    }

    setLayout(new BorderLayout());
    add(new JScrollPane(list));
}
项目:incubator-netbeans    文件:FileCompletionPopup.java   
public FileCompletionPopup(JFileChooser chooser, JTextField textField, Vector<File> files) {
    this.list = new JList(files);
    this.textField = textField;
    this.chooser = chooser;
    list.setVisibleRowCount(4);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane jsp = new JScrollPane(list);
    add(jsp);

    list.setFocusable(false);
    jsp.setFocusable(false);
    setFocusable(false);

    list.addFocusListener(new FocusHandler());
    list.addMouseListener(new MouseHandler());
    list.addMouseMotionListener(new MouseHandler());

    textField.addKeyListener(this);
}
项目:s-store    文件:TableListPanel.java   
private void init() {
        this.setLayout(new BorderLayout());
        tableListTable = new JTable(this.tableModel);
        tableListTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        tableListTable.setFillsViewportHeight(false);
        tableListTable.setDragEnabled(false);
        tableListTable.setColumnSelectionAllowed(false);
        tableListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

//        //
//        // Set the column widths
//        //
//        tableListTable.getColumnModel().getColumn(0).setPreferredWidth(40);
//        tableListTable.getColumnModel().getColumn(1).setPreferredWidth(20);
//        tableListTable.getColumnModel().getColumn(3).setPreferredWidth(40);

        JScrollPane scrollPane = new JScrollPane(tableListTable);
        //scrollPane.setPreferredSize(new Dimension(DesignerVisualization.WINDOW_WIDTH, 175));
        //scrollPane.setMaximumSize(this.columnSetTable.getPreferredScrollableViewportSize());
        this.add(scrollPane, BorderLayout.CENTER);
    }
项目:marathonv5    文件:RTableTest.java   
public void selectAllCells() throws Throwable {
    final JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            table.setColumnSelectionAllowed(true);
            table.setRowSelectionAllowed(true);
            table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            table.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            int rowCount = table.getRowCount();
            int colCount = table.getColumnCount();
            table.addRowSelectionInterval(0, rowCount - 1);
            table.addColumnSelectionInterval(0, colCount - 1);
            RTable rTable = new RTable(table, null, null, lr);
            rTable.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("all", call.getState());
}
项目:Equella    文件:BaseEntityWithAddDialogTool.java   
public PluginDialog()
{
    listModel = new DefaultListModel<>();

    list = new JList<>();
    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    for( String name : plugins.keySet() )
    {
        listModel.addElement(name);
    }

    setLayout(new BorderLayout());
    add(new JScrollPane(list));
}
项目:incubator-netbeans    文件:CompletionPopup.java   
public CompletionPopup(Completable completable) {
    this.list = new JList();
    enabledColor = list.getForeground();
    list.setVisibleRowCount(4);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.completable = completable;

    JScrollPane jsp = new JScrollPane(list);
    add(jsp);
    list.setFocusable(false);
    jsp.setFocusable(false);
    setFocusable(false);

    list.addFocusListener(new FocusHandler());
    list.addMouseListener(new MouseHandler());
    list.addMouseMotionListener(new MouseHandler());

    completable.addKeyListener(CompletionPopup.this);
}
项目:code-sentinel    文件:KillAgentGUI.java   
protected void initComponents() {
    services = RunCentralisedMAS.getRunner().getRuntimeServices();
    getContentPane().setLayout(new BorderLayout());

    // Fields
    Vector<String> agNames = new Vector<String>(services.getAgentsNames());
    Collections.sort(agNames);
    lAgs = new JList(agNames);
    lAgs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Current agents", TitledBorder.LEFT, TitledBorder.TOP));
    p.add(lAgs, BorderLayout.CENTER);

    getContentPane().add(p, BorderLayout.CENTER);
    getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
    ok.setText("Kill");
}
项目:jmt    文件:AllBlockingRegionsPanel.java   
/**
 * Constructs a new RegionTable
 */
public RegionTable() {
    super(new RegionTableModel());
    blockRenderer = new BlockingElementRenderer();
    grayRenderer = new GrayCellRenderer();
    delete.setFocusable(false);
    deleteRenderer = new ButtonCellEditor(delete);
    setRowHeight(ROW_HEIGHT);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTableHeader().setReorderingAllowed(false);

    // Sets column size
    getColumnModel().getColumn(0).setPreferredWidth(120);
    getColumnModel().getColumn(1).setPreferredWidth(50);
    getColumnModel().getColumn(2).setMaxWidth(25);
    getColumnModel().getColumn(3).setPreferredWidth(50);
    getColumnModel().getColumn(4).setMaxWidth(25);
    getColumnModel().getColumn(5).setPreferredWidth(50);
    getColumnModel().getColumn(6).setMaxWidth(25);
    getColumnModel().getColumn(7).setMaxWidth(ROW_HEIGHT);
    getColumnModel().setColumnSelectionAllowed(false);
}
项目:rapidminer    文件:OperatorList.java   
/** Creates a new instance of OperatorList */
public OperatorList(boolean horizontalWrap, boolean coloredCellBackgrounds) {
    operatorDialogCellRenderer = new OperatorListCellRenderer(coloredCellBackgrounds);
    if (horizontalWrap) {
        setLayoutOrientation(HORIZONTAL_WRAP);
        setVisibleRowCount(-1);
    }
    setFixedCellHeight(PropertyPanel.VALUE_CELL_EDITOR_HEIGHT);
    setCellRenderer(operatorDialogCellRenderer);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    addMouseListener(this);

    setDragEnabled(true);
    setTransferHandler(new OperatorTransferHandler() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<Operator> getDraggedOperators() {
            return Collections.singletonList(OperatorList.this.getSelectedOperator());
        }
    });
}
项目:rapidminer    文件:ExtendedErrorDialog.java   
public StackTraceList(Throwable t) {
    super(new DefaultListModel());
    setFont(getFont().deriveFont(Font.PLAIN));
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    appendAllStackTraces(t);
    addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (getSelectedIndex() >= 0) {
                if (!(getSelectedValue() instanceof FormattedStackTraceElement)) {
                    editButton.setEnabled(false);
                } else {
                    editButton.setEnabled(true);
                }
            } else {
                editButton.setEnabled(true);
            }
        }
    });
}
项目:Equella    文件:KeyResourcesTab.java   
private JComponent setupSelectedPanel(ChangeDetector changeDetector)
{
    actions.add(upAction);
    actions.add(downAction);
    actions.add(removeAction);

    selectedModel = new MyTableModel();
    selectedTable = createTable(selectedModel);
    selectedTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    selectedTable.addMouseListener(new TablePopupListener(selectedTable, removeAction, upAction, downAction));
    selectedTable.getSelectionModel().addListSelectionListener(new ListSelectionListener()
    {
        @Override
        public void valueChanged(ListSelectionEvent e)
        {
            update();
        }
    });

    JButton up = new JTextlessButton(upAction);
    JButton down = new JTextlessButton(downAction);
    JButton remove = new JButton(removeAction);

    final int width1 = up.getPreferredSize().width;
    final int width2 = remove.getPreferredSize().width;
    final int height1 = up.getPreferredSize().height;
    final int height2 = remove.getPreferredSize().height;
    final int[] rows = {TableLayout.FILL, height1, height1, TableLayout.FILL, height2,};
    final int[] cols = {width1, TableLayout.FILL, width2,};

    JPanel all = new JPanel(new TableLayout(rows, cols));
    all.add(new JScrollPane(selectedTable), new Rectangle(1, 0, 2, 4));
    all.add(up, new Rectangle(0, 1, 1, 1));
    all.add(down, new Rectangle(0, 2, 1, 1));
    all.add(remove, new Rectangle(2, 4, 1, 1));

    changeDetector.watch(selectedModel);

    return all;
}
项目:JavaGraph    文件:TemplateList.java   
private void addListPanel() {
    this.nameSelector = new JList<>();
    this.nameSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.nameSelector.setSelectedIndex(0);
    JScrollPane listScroller = new JScrollPane(this.nameSelector);
    listScroller.setPreferredSize(new Dimension(350, 200));
    add(listScroller);
}
项目:jmt    文件:ForkEditor.java   
public CombTable() {
    setModel(new CombTableModel());
    setDefaultEditor(Object.class, new ExactCellEditor());
    sizeColumns();
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTableHeader().setReorderingAllowed(false);
}
项目:jmt    文件:SemaphoreSectionPanel.java   
public SemaphoreSelectionTable() {
    super();
    setModel(new SemaphoreSelectionTableModel());
    sizeColumns();
    setRowHeight(ROW_HEIGHT);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTableHeader().setReorderingAllowed(false);
}
项目:jmt    文件:ForkEditor.java   
public ForkTable() {
    setModel(new ForkTableModel());
    setDefaultEditor(Object.class, new ExactCellEditor());
    sizeColumns();
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTableHeader().setReorderingAllowed(false);
}
项目:OpenDA    文件:VariationPerParameterTableController.java   
/**
 * setting up the table.
 *
 * @param table JTable to store this.correlationTableModel
 */
private void setupBasicTableProperties(JTable table) {

    table.clearSelection();

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


    TableRenderer cellRenderer = new TableRenderer(new JTextField());

    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(false);
    table.setVisible(true);
    table.setModel(this.variationPerParameterTableModel);

    initColumnSizes(table);
    for (int i = 0; i < table.getColumnCount(); i++) {
        TableColumn column = table.getColumnModel().getColumn(i);
        column.setCellRenderer(cellRenderer);
    }

    TableColumn columnName = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_NAME);
    columnName.setCellEditor(new TextCellEditor());
    TableColumn columnBasicValue = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_BASIC_VALUE);
    columnBasicValue.setCellEditor(new TextCellEditor());

    setupVariationFunctionComboBoxColumn();

    this.variationPerParameterTableModel.fireTableDataChanged();

    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);

    //select first row.
    table.getSelectionModel().setSelectionInterval(0, 0);
}
项目:Luyten4Forge    文件:JFontChooser.java   
public JList<?> getFontSizeList() {
    if (fontSizeList == null) {
        fontSizeList = new JList<Object>(this.fontSizeStrings);
        fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fontSizeList.addListSelectionListener(new ListSelectionHandler(getFontSizeTextField()));
        fontSizeList.setSelectedIndex(0);
        fontSizeList.setFont(DEFAULT_FONT);
        fontSizeList.setFocusable(false);
    }
    return fontSizeList;
}
项目:incubator-netbeans    文件:TreeList.java   
public TreeList(TreeListModel model) {
    super(model);
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setFixedCellHeight(ROW_HEIGHT + INSETS_TOP + INSETS_BOTTOM + 2);
    setCellRenderer(renderer);
    setBackground(ColorManager.getDefault().getDefaultBackground());
    ToolTipManager.sharedInstance().registerComponent(this);
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger() || e.isConsumed()) {
                return;
            }
            int index = locationToIndex(e.getPoint());
            if (index < 0 || index >= getModel().getSize()) {
                return;
            }
            Object value = getModel().getElementAt(index);
            if (value instanceof TreeListNode) {
                TreeListNode node = (TreeListNode) value;

                if (null != node && !node.isExpandable()) {
                    ActionListener al = node.getDefaultAction();
                    if (null != al) {
                        al.actionPerformed(new ActionEvent(e.getSource(), e.getID(), e.paramString()));
                    }
                } else if (null != node && node.isExpandable()) {
                    if (!node.isLoaded()) {
                        return;
                    }
                    node.setExpanded(!node.isExpanded());
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:PlatformComponentFactory.java   
/**
 * Returns <code>JList</code> initialized with {@link NbPlatformListModel}
 * which contains all NetBeans platform.
 */
public static JList getNbPlatformsList() {
    JList plafList = new JList(new NbPlatformListModel());
    plafList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    plafList.setCellRenderer(new NbPlatformListRenderer());
    return plafList;
}
项目:QN-ACTR-Release    文件:AllBlockingRegionsPanel.java   
/**
 * Initialize all components of this panel
 */
private void initComponents() {
    setLayout(new BorderLayout(5, 5));
    this.setBorder(new EmptyBorder(20, 20, 20, 20));
    // Builds upper panel
    JPanel upperPanel = new JPanel(new BorderLayout());
    JLabel description = new JLabel(BLOCKING_DESCRIPTION);
    upperPanel.add(description, BorderLayout.CENTER);

    //build upper right corner of the main panel
    JPanel upRightPanel = new JPanel(new BorderLayout());
    addRegion = new JButton("Add Region");
    addRegion.setMinimumSize(DIM_BUTTON_S);
    upRightPanel.add(addRegion, BorderLayout.CENTER);
    upperPanel.add(upRightPanel, BorderLayout.EAST);

    //build spinner panel
    JPanel spinnerPanel = new JPanel();
    JLabel spinnerDescrLabel = new JLabel("Regions:");
    regionsNumSpinner = new JSpinner();
    regionsNumSpinner.setPreferredSize(DIM_BUTTON_XS);
    spinnerPanel.add(spinnerDescrLabel);
    spinnerPanel.add(regionsNumSpinner);
    upRightPanel.add(spinnerPanel, BorderLayout.SOUTH);

    add(upperPanel, BorderLayout.NORTH);

    // Creates blocking regions list
    regions = new RegionTable();
    regions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane jsp = new JScrollPane(regions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(220, 200));
    add(jsp, BorderLayout.WEST);
    update();
}
项目:jmt    文件:FuzzyInfoClustering.java   
private JScrollPane getUpperTable() {
    clusteringFinalTable = new JTable(new clustDetModel(infos.numElem, infos.percent));
    clusteringFinalTable.setSelectionBackground(new Color(83, 126, 126));
    clusteringFinalTable.setSelectionForeground(Color.BLACK);
    clusteringFinalTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    return new JScrollPane(clusteringFinalTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
项目:incubator-netbeans    文件:SpringXMLConfigGroupVisual.java   
/** Creates new form SpringXMLConfigGroupVisual */
public SpringXMLConfigGroupVisual(List<ConfigFileGroup> configFileGroups) {
    initComponents();
    groupsTable.getParent().setBackground(groupsTable.getBackground());
    groupsTable.setModel(new ConfigGroupSelectionTableModel(configFileGroups));
    groupsTable.getColumnModel().getColumn(0).setMaxWidth(0);
    groupsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
项目:incubator-netbeans    文件:SpringXMLConfigNamespacesVisual.java   
public SpringXMLConfigNamespacesVisual() {
        initComponents();
        // set the color of the table's JViewport
        includesTable.getParent().setBackground(includesTable.getBackground());
        TableColumn col1 = includesTable.getColumnModel().getColumn(0);
        col1.setMaxWidth(0);
        includesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        includesTable.revalidate();
//        springLibrary = SpringUtilities.findSpringLibrary();
    }
项目:jmt    文件:AllStationsParametersPanel.java   
private void initComponents() {
    setLayout(new BorderLayout(5, 5));
    this.setBorder(new EmptyBorder(20, 20, 20, 20));
    //classesList = new JList(new StationsListModel());
    stationsList = new JList();
    stationsList.setListData(stationData.getStationKeys());
    stationsList.setCellRenderer(new StationElementRenderer());
    stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
    JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(140, 200));
    add(panelDescription, BorderLayout.NORTH);
    add(jsp, BorderLayout.WEST);
    stationsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            updateParsPane();
        }
    });
}
项目:jmt    文件:StationsPanel.java   
public void setModel(StationTableModel tabMod) {
    super.setModel(tabMod);
    sizeColumnsAndRows();
    setRowHeight(ROW_HEIGHT);
    setDefaultRenderer(String.class, new DisabledCellRenderer());
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTableHeader().setReorderingAllowed(false);
}