Java Code Examples for javax.swing.JTable#setSelectionMode()

The following examples show how to use javax.swing.JTable#setSelectionMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListSalePane.java    From OpERP with MIT License 6 votes vote down vote up
public ListSalePane() {
	pane = new JPanel();
	pane.setLayout(new MigLayout("fill"));
	table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {
				Sale sale = tableModel.getRow(table.getSelectedRow());

				saleController.showDetails(sale);

			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.add(scrollPane, "grow");
}
 
Example 2
Source File: InventoryDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private JTable createInventoryTable(WorldObjectContainer inventory, ImageInfoReader imageInfoReader) {
	JTable inventoryTable = JTableFactory.createJTable(new InventoryModel(inventory));
	
	inventoryTable.setDefaultRenderer(ImageIds.class, new InventoryItemImageRenderer(imageInfoReader));
	inventoryTable.getColumnModel().getColumn(1).setCellRenderer(new InventoryItemRenderer());
	inventoryTable.getColumnModel().getColumn(2).setCellRenderer(new InventoryItemRenderer());
	inventoryTable.getColumnModel().getColumn(3).setCellRenderer(new InventoryItemRenderer());
	
	
	inventoryTable.setRowHeight(50);
	inventoryTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	inventoryTable.getColumnModel().getColumn(0).setPreferredWidth(50);
	inventoryTable.getColumnModel().getColumn(1).setPreferredWidth(245);
	inventoryTable.getColumnModel().getColumn(2).setPreferredWidth(66);
	inventoryTable.getColumnModel().getColumn(3).setPreferredWidth(61);
	inventoryTable.getTableHeader().setReorderingAllowed(false);
	
	inventoryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	inventoryTable.setAutoCreateRowSorter(true);
	
	return inventoryTable;
}
 
Example 3
Source File: ListCustomerPane.java    From OpERP with MIT License 6 votes vote down vote up
public ListCustomerPane() {
	pane = new JPanel();
	pane.setLayout(new MigLayout("fill"));
	table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {
				Customer customer = tableModel.getRow(table
						.getSelectedRow());

				customerController.showDetails(customer);

			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.add(scrollPane, "grow");
}
 
Example 4
Source File: ListEmployeePane.java    From OpERP with MIT License 6 votes vote down vote up
public ListEmployeePane() {
	pane = new JPanel();
	pane.setLayout(new MigLayout("fill"));
	table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {
				Employee employee = tableModel.getRow(table
						.getSelectedRow());

				employeeController.showDetails(employee);

			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.add(scrollPane, "grow");
}
 
Example 5
Source File: ListProductPane.java    From OpERP with MIT License 6 votes vote down vote up
public ListProductPane() {
	pane = new JPanel(new MigLayout("fill"));

	table = new JTable();
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {

				Product product = tableModel.getRow(table.getSelectedRow());

				productDetailsPane.show(product, getPane());
			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	pane.add(scrollPane, "grow");
}
 
Example 6
Source File: TableUtils.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static void setupTable(JTable table, int selectionModel, TableModel model, MouseListener mouseListener,
                              int... colWidth) {
  table.setFillsViewportHeight(true);
  table.setFont(StyleConstants.FONT_MONOSPACE_LARGE);
  table.setRowHeight(StyleConstants.TABLE_ROW_HEIGHT_DEFAULT);
  table.setShowHorizontalLines(true);
  table.setShowVerticalLines(false);
  table.setGridColor(Color.lightGray);
  table.getColumnModel().setColumnMargin(StyleConstants.TABLE_COLUMN_MARGIN_DEFAULT);
  table.setRowMargin(StyleConstants.TABLE_ROW_MARGIN_DEFAULT);
  table.setSelectionMode(selectionModel);
  if (model != null) {
    table.setModel(model);
  } else {
    table.setModel(new DefaultTableModel());
  }
  if (mouseListener != null) {
    table.removeMouseListener(mouseListener);
    table.addMouseListener(mouseListener);
  }
  for (int i = 0; i < colWidth.length; i++) {
    table.getColumnModel().getColumn(i).setMinWidth(colWidth[i]);
    table.getColumnModel().getColumn(i).setMaxWidth(colWidth[i]);
  }
}
 
Example 7
Source File: QFixMessengerFrame.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void initBottomPanel()
{
	MessagesTableModel messagesTableModel = new MessagesTableModel();

	messagesTable = new JTable(messagesTableModel);
	messagesTable.getColumnModel().getColumn(0).setPreferredWidth(90);
	messagesTable.getColumnModel().getColumn(1).setPreferredWidth(5);
	messagesTable.getColumnModel().getColumn(2).setPreferredWidth(75);
	messagesTable.getColumnModel().getColumn(3).setPreferredWidth(5);
	messagesTable.getColumnModel().getColumn(4).setPreferredWidth(510);

	messagesTable.setDefaultRenderer(String.class,
			new MessagesTableCellRender());
	messagesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	messagesTable.addMouseListener(new MessagesTableMouseListener(this));

	messenger.getApplication().addMessageListener(messagesTableModel);

	bottomPanelScrollPane = new JScrollPane(messagesTable);
	bottomPanelScrollPane.setPreferredSize(new Dimension(
			bottomPanelScrollPane.getPreferredSize().width, 120));
	bottomPanelScrollPane.getViewport().add(messagesTable);
	add(bottomPanelScrollPane, BorderLayout.SOUTH);
}
 
Example 8
Source File: MaianaImportPanel.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
public void setTopicMapsList() {
    if(getApiKey() != null) {
        try {
            JSONObject list = MaianaUtils.listAvailableTopicMaps(getApiEndPoint(), getApiKey());
            if(list.has("msg")) {
                WandoraOptionPane.showMessageDialog(window, list.getString("msg"), "API says", WandoraOptionPane.WARNING_MESSAGE);
                //System.out.println("REPLY:"+list.toString());
            }

            if(list.has("data")) {
                mapTable = new JTable();
                mapTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                if(list != null) {
                    JSONArray datas = list.getJSONArray("data");
                    TopicMapsTableModel myModel = new TopicMapsTableModel(datas);
                    mapTable.setModel(myModel);
                    mapTable.setRowSorter(new TableRowSorter(myModel));

                    mapTable.setColumnSelectionAllowed(false);
                    mapTable.setRowSelectionAllowed(true);
                    mapTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    
                    TableColumn column = null;
                    for (int i=0; i < mapTable.getColumnCount(); i++) {
                        column = mapTable.getColumnModel().getColumn(i);
                        column.setPreferredWidth(myModel.getColumnWidth(i));
                    }
                    tableScrollPane.setViewportView(mapTable);
                }
            }
        }
        catch(Exception e) {
            Wandora.getWandora().displayException("Exception '"+e.getMessage()+"' occurred while getting the list of topic maps.", e);
        }
    }


}
 
Example 9
Source File: RegistrationExplorerPanel.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public void initComponent( final ViewRegistrations viewRegistrations )
{
	tableModel = new RegistrationTableModel( viewRegistrations, this );

	table = new JTable();
	table.setModel( tableModel );
	table.setSurrendersFocusOnKeystroke( true );
	table.setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION );
	
	final DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( JLabel.CENTER );
	
	// center all columns
	for ( int column = 0; column < tableModel.getColumnCount(); ++column )
		table.getColumnModel().getColumn( column ).setCellRenderer( centerRenderer );

	table.setPreferredScrollableViewportSize( new Dimension( 1020, 300 ) );
	table.getColumnModel().getColumn( 0 ).setPreferredWidth( 300 );
	for ( int i = 1; i < table.getColumnCount(); ++i )
		table.getColumnModel().getColumn( i ).setPreferredWidth( 100 );
	final Font f = table.getFont();
	
	table.setFont( new Font( f.getName(), f.getStyle(), 11 ) );
	
	this.setLayout( new BorderLayout() );
	this.label = new JLabel( "View Description --- " );
	this.add( label, BorderLayout.NORTH );
	this.add( new JScrollPane( table ), BorderLayout.CENTER );
	
	addPopupMenu( table );
}
 
Example 10
Source File: PortMapperView.java    From portmapper with GNU General Public License v3.0 5 votes vote down vote up
private JComponent getMappingsPanel() {
    // Mappings panel

    final ActionMap actionMap = this.getContext().getActionMap(this.getClass(), this);

    tableModel = new PortMappingsTableModel(app);
    mappingsTable = new JTable(tableModel);
    mappingsTable.setAutoCreateRowSorter(true);
    mappingsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    mappingsTable.setSize(new Dimension(400, 100));
    mappingsTable.getSelectionModel().addListSelectionListener(
            e -> firePropertyChange(PROPERTY_MAPPING_SELECTED, false, isMappingSelected()));

    final JScrollPane mappingsTabelPane = new JScrollPane();
    mappingsTabelPane.setViewportView(mappingsTable);

    final JPanel mappingsPanel = new JPanel(new MigLayout("", "[fill,grow]", "[grow,fill][]"));
    mappingsPanel.setName("port_mappings");
    final Border panelBorder = BorderFactory
            .createTitledBorder(app.getResourceMap().getString("mainFrame.port_mappings.title"));
    mappingsPanel.setBorder(panelBorder);
    mappingsPanel.add(mappingsTabelPane, "height 100::, span 2, wrap");

    mappingsPanel.add(new JButton(actionMap.get(ACTION_REMOVE_MAPPINGS)), "");
    mappingsPanel.add(new JButton(actionMap.get(ACTION_UPDATE_PORT_MAPPINGS)), "wrap");
    return mappingsPanel;
}
 
Example 11
Source File: SBOLInputDialog.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel initMainPanel() 
{
	//Get information for main design layout and load them up
	List<TopLevel> topLevelObjs = new ArrayList<TopLevel>();
	if(showRootDefs.isSelected() && showCompDefs.isSelected())
	{
		topLevelObjs.addAll(sbolDesigns.getRootComponentDefinitions());
	}
	if(showRootDefs.isSelected() && showModDefs.isSelected())
	{
		topLevelObjs.addAll(sbolDesigns.getRootModuleDefinitions());
	}

	//Show an a list of designs user can choose from
	TopLevelTableModel tableModel = new TopLevelTableModel(topLevelObjs);
	
	JPanel panel = createTablePanel(tableModel, "Select Design(s) (" + tableModel.getRowCount() + ")");
	
	table = (JTable) panel.getClientProperty("table");
	table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	tableLabel = (JLabel) panel.getClientProperty("label");
	
	updateTable();

	return panel;
}
 
Example 12
Source File: ElementsTableComponent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public ElementsTableComponent() {

    super(new BorderLayout());

    elementsTableModel = new ElementsTableModel();

    elementsTable = new JTable(elementsTableModel);
    elementsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    elementsTable.setRowSelectionAllowed(true);
    elementsTable.setColumnSelectionAllowed(false);
    elementsTable.setDefaultRenderer(Object.class, new ComponentCellRenderer(smallFont));
    elementsTable.getTableHeader().setReorderingAllowed(false);

    elementsTable.getTableHeader().setResizingAllowed(false);
    elementsTable.setPreferredScrollableViewportSize(new Dimension(200, 80));

    JScrollPane elementsScroll = new JScrollPane(elementsTable);
    add(elementsScroll, BorderLayout.CENTER);

    // Add buttons
    JPanel buttonsPanel = new JPanel();
    BoxLayout buttonsPanelLayout = new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS);
    buttonsPanel.setLayout(buttonsPanelLayout);
    addElementButton = GUIUtils.addButton(buttonsPanel, "Add", null, this);
    removeElementButton = GUIUtils.addButton(buttonsPanel, "Remove", null, this);
    add(buttonsPanel, BorderLayout.EAST);

    this.setPreferredSize(new Dimension(300, 100));

  }
 
Example 13
Source File: ConfigDialog.java    From dkpro-jwpl with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the JTable for displaying the input archives.
 */
private void createItemTable()
{
	itemTable = new JTable(controller.getConfigErrors());
	itemTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	itemScrollPane = new JScrollPane(itemTable);
	itemScrollPane.setBounds(10, 10, 470, 180);

	this.add(itemScrollPane);
}
 
Example 14
Source File: ParameterEditorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected Component createContentPane()
{
  innerTableCellEditor = new TagListTableCellEditor();
  outerTableCellEditor = new TagListTableCellEditor();

  parameterMappingTable = new JTable(new ParameterMappingTableModel());
  parameterMappingTable.getColumnModel().getColumn(0).setCellEditor(innerTableCellEditor);
  parameterMappingTable.getColumnModel().getColumn(1).setCellEditor(outerTableCellEditor);
  parameterMappingTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  final RemoveParameterAction removeParameterAction = new RemoveParameterAction();
  parameterMappingTable.getSelectionModel().addListSelectionListener(removeParameterAction);

  final JPanel parameterMappingButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
  parameterMappingButtonPanel.add(new BorderlessButton(new AddParameterAction()));
  parameterMappingButtonPanel.add(new BorderlessButton(new RemoveParameterAction()));

  final JPanel parameterMappingPanel = new JPanel(new BorderLayout());
  parameterMappingPanel.setBorder(BorderFactory.createTitledBorder(Messages.getString("ParameterEditorDialog.ParameterBox")));
  parameterMappingPanel.add(new JScrollPane(parameterMappingTable), BorderLayout.CENTER);
  parameterMappingPanel.add(parameterMappingButtonPanel, BorderLayout.NORTH);

  final JPanel contentPane = new JPanel();
  contentPane.setLayout(new GridLayout(1, 2, 5, 5));
  contentPane.add(parameterMappingPanel);
  return contentPane;
}
 
Example 15
Source File: PerfMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
private JTable createGrid() {
    grid = new JTable();
    createTableModel();
    grid.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    grid.setMinimumSize(new Dimension(200, 100));

    grid.getColumnModel().getColumn(0).setPreferredWidth(170);
    grid.getColumnModel().getColumn(1).setPreferredWidth(80);
    grid.getColumnModel().getColumn(2).setPreferredWidth(120);
    grid.getColumnModel().getColumn(3).setPreferredWidth(500);

    return grid;
}
 
Example 16
Source File: VerifierSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void createResultsPanel() {
    resultPanel = new JPanel();
    resultPanel.setLayout(new BorderLayout());
    resultPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black),
            _archiveName));
    
    // 508 compliance
    resultPanel.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Panel"));  // NOI18N
    resultPanel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_panel")); // NOI18N
    
    // set up result table
    tableModel = new DefaultTableModel(columnNames, 0);
    table = new JTable(tableModel) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer,
                int rowIndex, int vColIndex) {
            Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent)c;
                jc.setToolTipText((String)getValueAt(rowIndex, vColIndex));
            }
            return c;
        }
    };

    // 508 for JTable
    table.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Table"));    // NOI18N
    table.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_table_of_items"));//NOI18N
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableScrollPane = new JScrollPane(table);
    Object [] row = {NbBundle.getMessage(VerifierSupport.class,"Wait"),NbBundle.getMessage(VerifierSupport.class,"Running_Verifier_Tool..."),NbBundle.getMessage(VerifierSupport.class,"Running...") };  // NOI18N
    tableModel.addRow(row);
    //table.sizeColumnsToFit(0);
    // 508 for JScrollPane
    tableScrollPane.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane"));    // NOI18N
    tableScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(VerifierSupport.class,"ScrollArea"));   // NOI18N
    sizeTableColumns();
    // make the cells uneditable
    JTextField field = new JTextField();
    // 508 for JTextField
    field.getAccessibleContext().setAccessibleName(
            NbBundle.getMessage(VerifierSupport.class,"Text_Field"));   // NOI18N
    field.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_field")); // NOI18N
    table.setDefaultEditor(Object.class, new DefaultCellEditor(field) {
        @Override
        public boolean isCellEditable(EventObject anEvent) {
            return false;
        }
    });
    // add action listener to table to show details
    tableSelectionListener =  new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e){
            if (!e.getValueIsAdjusting()){
                if(table.getSelectionModel().isSelectedIndex(e.getLastIndex())){
                    setDetailText( table.getModel().getValueAt(e.getLastIndex(),1)+
                            "\n"+table.getModel().getValueAt(e.getLastIndex(),2));//NOI18N
                }else if(table.getSelectionModel().isSelectedIndex(e.getFirstIndex())){
                    setDetailText(table.getModel().getValueAt(e.getFirstIndex(),1)+
                            "\n"+table.getModel().getValueAt(e.getFirstIndex(),2));//NOI18N
                }
            }
        }
    };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);
    
    // create detail text area
    detailText = new JTextArea(4,50);
    // 508 for JTextArea
    detailText.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Text_Area"));   // NOI18N
    detailText.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_area"));//NOI18N
    detailText.setEditable(false);
    textScrollPane = new JScrollPane(detailText);
    // 508 for JScrollPane
    textScrollPane.getAccessibleContext().setAccessibleName(  NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane"));    // NOI18N
    textScrollPane.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"ScrollListPane"));//NOI18N
    textScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), NbBundle.getMessage(VerifierSupport.class,"Detail:")));// NOI18N
    
    //add the components to the panel
    createControlPanel();
    
    //Create a split pane with the two scroll panes in it.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
            tableScrollPane, textScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);
    
    //Provide minimum sizes for the two components in the split pane
    Dimension minimumSize = new Dimension(100, 50);
    tableScrollPane.setMinimumSize(minimumSize);
    textScrollPane.setMinimumSize(minimumSize);
    
    resultPanel.add("North", controlPanel); //NOI18N
    resultPanel.add("Center", splitPane);   // NOI18N
}
 
Example 17
Source File: PhpFrameworksPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    frameworksScrollPane = new JScrollPane();
    frameworksTable = new JTable();
    descriptionLabel = new JLabel();
    separator = new JSeparator();
    configPanel = new JPanel();

    setFocusTraversalPolicy(null);

    frameworksTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    frameworksTable.setShowHorizontalLines(false);
    frameworksTable.setShowVerticalLines(false);
    frameworksTable.setTableHeader(null);
    frameworksScrollPane.setViewportView(frameworksTable);
    frameworksTable.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.frameworksTable.AccessibleContext.accessibleName")); // NOI18N
    frameworksTable.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.frameworksTable.AccessibleContext.accessibleDescription")); // NOI18N

    descriptionLabel.setText("DUMMY"); // NOI18N

    configPanel.setLayout(new BorderLayout());

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addComponent(separator, GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
        .addGroup(layout.createSequentialGroup()
            .addComponent(descriptionLabel)
            .addContainerGap())
        .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
        .addComponent(frameworksScrollPane, GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(frameworksScrollPane, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(separator, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(descriptionLabel)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))
    );

    frameworksScrollPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.frameworksScrollPane.AccessibleContext.accessibleName")); // NOI18N
    frameworksScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.frameworksScrollPane.AccessibleContext.accessibleDescription")); // NOI18N
    descriptionLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.descriptionLabel.AccessibleContext.accessibleName")); // NOI18N
    configPanel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.configPanel.AccessibleContext.accessibleName")); // NOI18N
    configPanel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.configPanel.AccessibleContext.accessibleDescription")); // NOI18N

    getAccessibleContext().setAccessibleName(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.AccessibleContext.accessibleName")); // NOI18N
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PhpFrameworksPanelVisual.class, "PhpFrameworksPanelVisual.AccessibleContext.accessibleDescription")); // NOI18N
}
 
Example 18
Source File: TableDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
protected void initComponents() {
    setLayout(new BorderLayout());

    controlPanel = createControlPanel();
    add(controlPanel, BorderLayout.NORTH);

    //<snip>Create JTable
    oscarTable = new JTable(oscarModel);
    //</snip>

    //</snip>Set JTable display properties
    oscarTable.setColumnModel(createColumnModel());
    oscarTable.setAutoCreateRowSorter(true);
    oscarTable.setRowHeight(26);
    oscarTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    oscarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    oscarTable.setIntercellSpacing(new Dimension(0, 0));
    //</snip>

    //<snip>Initialize preferred size for table's viewable area
    Dimension viewSize = new Dimension();
    viewSize.width = oscarTable.getColumnModel().getTotalColumnWidth();
    viewSize.height = 10 * oscarTable.getRowHeight();
    oscarTable.setPreferredScrollableViewportSize(viewSize);
    //</snip>

    //<snip>Customize height and alignment of table header
    JTableHeader header = oscarTable.getTableHeader();
    header.setPreferredSize(new Dimension(30, 26));
    TableCellRenderer headerRenderer = header.getDefaultRenderer();
    if (headerRenderer instanceof JLabel) {
        ((JLabel) headerRenderer).setHorizontalAlignment(JLabel.CENTER);
    }
    //</snip>

    LuckScrollPane scrollpane = new LuckScrollPane(oscarTable);
    dataPanel = new Stacker(scrollpane);
    add(dataPanel, BorderLayout.CENTER);

    add(createStatusBar(), BorderLayout.SOUTH);

}
 
Example 19
Source File: VerifierSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void createResultsPanel() {
    resultPanel = new JPanel();
    resultPanel.setLayout(new BorderLayout());
    resultPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black),
            _archiveName));
    
    // 508 compliance
    resultPanel.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Panel"));  // NOI18N
    resultPanel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_panel")); // NOI18N
    
    // set up result table
    tableModel = new DefaultTableModel(columnNames, 0);
    table = new JTable(tableModel) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer,
                int rowIndex, int vColIndex) {
            Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent)c;
                jc.setToolTipText((String)getValueAt(rowIndex, vColIndex));
            }
            return c;
        }
    };

    // 508 for JTable
    table.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Table"));    // NOI18N
    table.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_table_of_items"));//NOI18N
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableScrollPane = new JScrollPane(table);
    Object [] row = {NbBundle.getMessage(VerifierSupport.class,"Wait"),NbBundle.getMessage(VerifierSupport.class,"Running_Verifier_Tool..."),NbBundle.getMessage(VerifierSupport.class,"Running...") };  // NOI18N
    tableModel.addRow(row);
    //table.sizeColumnsToFit(0);
    // 508 for JScrollPane
    tableScrollPane.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane"));    // NOI18N
    tableScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(VerifierSupport.class,"ScrollArea"));   // NOI18N
    sizeTableColumns();
    // make the cells uneditable
    JTextField field = new JTextField();
    // 508 for JTextField
    field.getAccessibleContext().setAccessibleName(
            NbBundle.getMessage(VerifierSupport.class,"Text_Field"));   // NOI18N
    field.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_field")); // NOI18N
    table.setDefaultEditor(Object.class, new DefaultCellEditor(field) {
        @Override
        public boolean isCellEditable(EventObject anEvent) {
            return false;
        }
    });
    // add action listener to table to show details
    tableSelectionListener =  new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e){
            if (!e.getValueIsAdjusting()){
                if(table.getSelectionModel().isSelectedIndex(e.getLastIndex())){
                    setDetailText( table.getModel().getValueAt(e.getLastIndex(),1)+
                            "\n"+table.getModel().getValueAt(e.getLastIndex(),2));//NOI18N
                }else if(table.getSelectionModel().isSelectedIndex(e.getFirstIndex())){
                    setDetailText(table.getModel().getValueAt(e.getFirstIndex(),1)+
                            "\n"+table.getModel().getValueAt(e.getFirstIndex(),2));//NOI18N
                }
            }
        }
    };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);
    
    // create detail text area
    detailText = new JTextArea(4,50);
    // 508 for JTextArea
    detailText.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Text_Area"));   // NOI18N
    detailText.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_area"));//NOI18N
    detailText.setEditable(false);
    textScrollPane = new JScrollPane(detailText);
    // 508 for JScrollPane
    textScrollPane.getAccessibleContext().setAccessibleName(  NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane"));    // NOI18N
    textScrollPane.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"ScrollListPane"));//NOI18N
    textScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), NbBundle.getMessage(VerifierSupport.class,"Detail:")));// NOI18N
    
    //add the components to the panel
    createControlPanel();
    
    //Create a split pane with the two scroll panes in it.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
            tableScrollPane, textScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);
    
    //Provide minimum sizes for the two components in the split pane
    Dimension minimumSize = new Dimension(100, 50);
    tableScrollPane.setMinimumSize(minimumSize);
    textScrollPane.setMinimumSize(minimumSize);
    
    resultPanel.add("North", controlPanel); //NOI18N
    resultPanel.add("Center", splitPane);   // NOI18N
}
 
Example 20
Source File: ReqTabPanel.java    From rest-client with Apache License 2.0 4 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param  name
* @return void 
* @throws
 */
private void init(String name)
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, 0));

    List<String> colNames = new ArrayList<String>();
    colNames.add(name);
    colNames.add(RESTConst.VALUE);

    tabMdl = new TabModel(colNames);
    tab = new JTable(tabMdl);
    tab.setFillsViewportHeight(true);
    tab.setAutoCreateRowSorter(false);
    tab.getTableHeader().setReorderingAllowed(false);
    tab.addMouseListener(ma);
    tab.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    miRmSel = new JMenuItem(RESTConst.RM_SEL);
    miRmSel.setName(RESTConst.RM_SEL);
    miRmSel.addActionListener(this);

    miRmAll = new JMenuItem(RESTConst.RM_ALL);
    miRmAll.setName(RESTConst.RM_ALL);
    miRmAll.addActionListener(this);

    pm = new JPopupMenu();
    pm.add(miRmSel);
    pm.add(miRmAll);
    
    txtFldKey = new JTextField(RESTConst.FIELD_SIZE);
    txtFldVal = new JTextField(RESTConst.FIELD_SIZE);

    lblKey = new JLabel(RESTConst.KEY + ":");
    lblVal = new JLabel(RESTConst.VALUE + ":");

    iconAdd = UIUtil.getIcon(RESTConst.ICON_ADD);
    iconDel = UIUtil.getIcon(RESTConst.ICON_DEL);

    btnAdd = new JButton(iconAdd);
    btnAdd.setName(RESTConst.ADD);
    btnAdd.setToolTipText(RESTConst.ADD + " " + name);
    btnAdd.addActionListener(this);

    btnDel = new JButton(iconDel);
    btnDel.setName(RESTConst.DELETE);
    btnDel.setToolTipText(RESTConst.DELETE + " " + name);
    btnDel.addActionListener(this);

    JPanel pnlNorth = new JPanel();
    pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
    pnlNorth.add(lblKey);
    pnlNorth.add(txtFldKey);
    pnlNorth.add(lblVal);
    pnlNorth.add(txtFldVal);
    pnlNorth.add(btnAdd);
    pnlNorth.add(btnDel);

    this.add(pnlNorth, BorderLayout.NORTH);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JScrollPane spHdr = new JScrollPane(tab);
    pnlCenter.add(spHdr);

    this.add(pnlCenter, BorderLayout.CENTER);
}