Package javax.swing

Examples of javax.swing.ListSelectionModel


            topHalf.add( listContainer );

            //Create JList for items, add to scroll pane and then add to parent
            // container
            JList list = new JList( items );
            ListSelectionModel listSelectionModel = list.getSelectionModel();
            listSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            //handler adds item to shopping cart
            list.addMouseListener( new ListSelectionHandler() );
            JScrollPane listPane = new JScrollPane( list );
            listContainer.add( listPane );

            JPanel tableContainer = new JPanel( new GridLayout( 1,
                                                                1 ) );
            tableContainer.setBorder( BorderFactory.createTitledBorder( "Table" ) );
            topHalf.add( tableContainer );

            //Container that displays table showing items in cart
            tableModel = new TableModel();
            JTable table = new JTable( tableModel );
            //handler removes item to shopping cart
            table.addMouseListener( new TableSelectionHandler() );
            ListSelectionModel tableSelectionModel = table.getSelectionModel();
            tableSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            TableColumnModel tableColumnModel = table.getColumnModel();
            //notice we have a custom renderer for each column as both columns
            // point to the same underlying object
            tableColumnModel.getColumn( 0 ).setCellRenderer( new NameRenderer() );
            tableColumnModel.getColumn( 1 ).setCellRenderer( new PriceRenderer() );
View Full Code Here


    TableModel _server_model = m_model.getServerTableModel();
    m_server_table = new JTable(_server_model);
    m_server_table.addMouseListener(m_handler);

    ListSelectionModel _selection_model = m_server_table.getSelectionModel();
    _selection_model.addListSelectionListener(m_handler);

    TableColumn _host_col = m_server_table.getColumnModel().getColumn(1);
    _host_col.setCellEditor(new ImRTableCellEditor(m_model.getHostSelector()));

    m_server_view = new JScrollPane(m_server_table);
View Full Code Here

            topHalf.add( listContainer );

            //Create JList for items, add to scroll pane and then add to parent
            // container
            JList list = new JList( items );
            ListSelectionModel listSelectionModel = list.getSelectionModel();
            listSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            //handler adds item to shopping cart
            list.addMouseListener( new ListSelectionHandler() );
            JScrollPane listPane = new JScrollPane( list );
            listContainer.add( listPane );

            JPanel tableContainer = new JPanel( new GridLayout( 1,
                                                                1 ) );
            tableContainer.setBorder( BorderFactory.createTitledBorder( "Table" ) );
            topHalf.add( tableContainer );

            //Container that displays table showing items in cart
            tableModel = new TableModel();
            JTable table = new JTable( tableModel );
            //handler removes item to shopping cart
            table.addMouseListener( new TableSelectionHandler() );
            ListSelectionModel tableSelectionModel = table.getSelectionModel();
            tableSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            TableColumnModel tableColumnModel = table.getColumnModel();
            //notice we have a custom renderer for each column as both columns
            // point to the same underlying object
            tableColumnModel.getColumn( 0 ).setCellRenderer( new NameRenderer() );
            tableColumnModel.getColumn( 1 ).setCellRenderer( new PriceRenderer() );
View Full Code Here

   */
  private void testColumnSelectionAllowed(TestHarness harness)
  {
    JTable table = createTestTable();
    table.setColumnSelectionAllowed(true);
    ListSelectionModel selModel = table.getColumnModel().getSelectionModel();
    // Select column#1 in the selection model.
    selModel.setSelectionInterval(1, 1);
    harness.check(table.isColumnSelected(1), true);
  }
View Full Code Here

   */
  private void testColumnSelectionNotAllowed(TestHarness harness)
  {
    JTable table = createTestTable();
    table.setColumnSelectionAllowed(false);
    ListSelectionModel selModel = table.getColumnModel().getSelectionModel();
    // Select column#1 in the selection model.
    selModel.setSelectionInterval(1, 1);
    harness.check(table.isColumnSelected(1), true);
  }
View Full Code Here

   */
  private void testSelectionModel(TestHarness harness)
  {
    harness.checkPoint("selectionModel");
    JTable table = new JTable();
    ListSelectionModel m1 = table.getSelectionModel();
    m1.addSelectionInterval(1, 1);
    harness.check(m1.isSelectedIndex(1), true);
    table.setModel(new DefaultTableModel());
    harness.check(table.getSelectionModel() == m1);
    harness.check(m1.isSelectedIndex(1), false);
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("createDefaultSelectionModel()");
    MyJTable t = new MyJTable();
    ListSelectionModel m = t.createDefaultSelectionModel();
    harness.check(m instanceof DefaultListSelectionModel);
    harness.check(m.isSelectionEmpty());
    harness.check(m.getSelectionMode(),
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  }
View Full Code Here

   */
  private void testRowSelectionAllowed(TestHarness harness)
  {
    JTable table = createTestTable();
    table.setRowSelectionAllowed(true);
    ListSelectionModel selModel = table.getSelectionModel();
    // Select row#1 in the selection model.
    selModel.setSelectionInterval(1, 1);
    harness.check(table.isRowSelected(1), true);
  }
View Full Code Here

   */
  private void testRowSelectionNotAllowed(TestHarness harness)
  {
    JTable table = createTestTable();
    table.setRowSelectionAllowed(false);
    ListSelectionModel selModel = table.getSelectionModel();
    // Select row#1 in the selection model.
    selModel.setSelectionInterval(1, 1);
    harness.check(table.isRowSelected(1), true);
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    DefaultTableColumnModel m1 = new DefaultTableColumnModel();
    ListSelectionModel lsm = new DefaultListSelectionModel();
    m1.setSelectionModel(lsm);
    harness.check(m1.getSelectionModel(), lsm);
  }
View Full Code Here

TOP

Related Classes of javax.swing.ListSelectionModel

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.