Java Code Examples for javax.swing.ListSelectionModel

The following are top voted examples for showing how to use javax.swing.ListSelectionModel. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myster   File: JMCList.java   View source code 6 votes vote down vote up
public void setSelectionInterval(int index0, int index1) {
    clearSelection();
    if (selectionMode == ListSelectionModel.SINGLE_SELECTION) {
        modifySelectionInterval(index0, index1, true);
    } else {
        modifySelectionInterval(index1, index1, true);
    }
    fireValueChanged();
}
 
Example 2
Project: litiengine   File: JCheckBoxList.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: DeutschSim   File: QubitTable.java   View source code 6 votes vote down vote up
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";
}
 
Example 4
Project: incubator-netbeans   File: AntNavigatorPanel.java   View source code 6 votes vote down vote up
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;
}
 
Example 5
Project: zencash-swing-wallet-ui   File: AddressBookPanel.java   View source code 6 votes vote down vote up
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;
  }
 
Example 6
Project: incubator-netbeans   File: JTableSelectionModelEditor.java   View source code 6 votes vote down vote up
@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;
}
 
Example 7
Project: jmt   File: ExactTable.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 8
Project: routerapp   File: OpenGraphDialog.java   View source code 6 votes vote down vote up
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;
}
 
Example 9
Project: incubator-netbeans   File: ListView.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: incubator-netbeans   File: OutlineView.java   View source code 6 votes vote down vote up
/** 
 * 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;
}
 
Example 11
Project: incubator-netbeans   File: CategoryList.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 12
Project: incubator-netbeans   File: SelectInstallationPanel.java   View source code 6 votes vote down vote up
@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);
                }
            });
        }
    });
}
 
Example 13
Project: marathonv5   File: RTableTest.java   View source code 6 votes vote down vote up
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());
}
 
Example 14
Project: Equella   File: HarvesterProfileTool.java   View source code 6 votes vote down vote up
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));
}
 
Example 15
Project: incubator-netbeans   File: ErrorNavigatorProviderImpl.java   View source code 6 votes vote down vote up
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;
}
 
Example 16
Project: Equella   File: SearchTool.java   View source code 6 votes vote down vote up
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));
}
 
Example 17
Project: incubator-netbeans   File: FileCompletionPopup.java   View source code 6 votes vote down vote up
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);
}
 
Example 18
Project: s-store   File: TableListPanel.java   View source code 6 votes vote down vote up
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);
    }
 
Example 19
Project: marathonv5   File: RTableTest.java   View source code 6 votes vote down vote up
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());
}
 
Example 20
Project: Equella   File: BaseEntityWithAddDialogTool.java   View source code 6 votes vote down vote up
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));
}
 
Example 21
Project: incubator-netbeans   File: CompletionPopup.java   View source code 6 votes vote down vote up
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);
}
 
Example 22
Project: 20170612-NotaFIscalEletronica   File: FrameInicial.java   View source code 6 votes vote down vote up
private void construtorTabelaModel(){
		
		Object[] colunas = new String[]{"Numero","Date Emissão","CNPJ/CPF","Razão Social/Nome","Quantidade de Itens","Valor Total"};

		Object[][] dados = new Object[][]{
//		       {"100", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"200", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"300", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"400", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"500", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"}
		};

		model = new DefaultTableModel(dados , colunas ){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		tabela = new JTable();
		tabela.setModel(model);
		tabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		painelTabela = new JScrollPane();
		painelTabela.setViewportView(tabela);
		
//		busca e inserção de notas fiscais do banco na tabela
		this.buscaNf();
		
	}
 
Example 23
Project: code-sentinel   File: KillAgentGUI.java   View source code 6 votes vote down vote up
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");
}
 
Example 24
Project: jmt   File: AllBlockingRegionsPanel.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 25
Project: rapidminer   File: OperatorList.java   View source code 6 votes vote down vote up
/** 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());
		}
	});
}
 
Example 26
Project: rapidminer   File: ExtendedErrorDialog.java   View source code 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example 27
Project: Equella   File: KeyResourcesTab.java   View source code 5 votes vote down vote up
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;
}
 
Example 28
Project: JavaGraph   File: TemplateList.java   View source code 5 votes vote down vote up
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);
}
 
Example 29
Project: jmt   File: ForkEditor.java   View source code 5 votes vote down vote up
public CombTable() {
	setModel(new CombTableModel());
	setDefaultEditor(Object.class, new ExactCellEditor());
	sizeColumns();
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	getTableHeader().setReorderingAllowed(false);
}
 
Example 30
Project: jmt   File: SemaphoreSectionPanel.java   View source code 5 votes vote down vote up
public SemaphoreSelectionTable() {
	super();
	setModel(new SemaphoreSelectionTableModel());
	sizeColumns();
	setRowHeight(ROW_HEIGHT);
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	getTableHeader().setReorderingAllowed(false);
}
 
Example 31
Project: jmt   File: ForkEditor.java   View source code 5 votes vote down vote up
public ForkTable() {
	setModel(new ForkTableModel());
	setDefaultEditor(Object.class, new ExactCellEditor());
	sizeColumns();
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	getTableHeader().setReorderingAllowed(false);
}
 
Example 32
Project: OpenDA   File: VariationPerParameterTableController.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 33
Project: Luyten4Forge   File: JFontChooser.java   View source code 5 votes vote down vote up
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;
}
 
Example 34
Project: incubator-netbeans   File: TreeList.java   View source code 5 votes vote down vote up
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());
                }
            }
        }
    });
}
 
Example 35
Project: incubator-netbeans   File: PlatformComponentFactory.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 36
Project: QN-ACTR-Release   File: AllBlockingRegionsPanel.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 37
Project: jmt   File: FuzzyInfoClustering.java   View source code 5 votes vote down vote up
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);
}
 
Example 38
Project: incubator-netbeans   File: SpringXMLConfigGroupVisual.java   View source code 5 votes vote down vote up
/** 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);
}
 
Example 39
Project: incubator-netbeans   File: SpringXMLConfigNamespacesVisual.java   View source code 5 votes vote down vote up
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();
    }
 
Example 40
Project: jmt   File: AllStationsParametersPanel.java   View source code 5 votes vote down vote up
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();
		}
	});
}