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

The following examples show how to use javax.swing.JTable#setRowSelectionAllowed() . 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: JSFConfigurationPanelVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initJsfComponentTableVisualProperties(JTable table) {
    table.setRowSelectionAllowed(true);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    table.setTableHeader(null);

    table.setRowHeight(jsfComponentsTable.getRowHeight() + 4);
    table.setIntercellSpacing(new java.awt.Dimension(0, 0));
    // set the color of the table's JViewport
    table.getParent().setBackground(table.getBackground());
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);

    table.getColumnModel().getColumn(0).setMaxWidth(30);
    if (!panel.isMaven()) {
        table.getColumnModel().getColumn(2).setMaxWidth(100);
    }

}
 
Example 2
Source File: InstancesInfoPanel.java    From hprof-tools with MIT License 6 votes vote down vote up
public InstancesInfoPanel(@Nonnull MemoryDump data, @Nonnull List<Instance> instances) {
    super(new BorderLayout());

    // Instances table
    instancesTable = new JTable();
    instancesTable.setAutoCreateRowSorter(true);
    instancesTable.setRowSelectionAllowed(true);
    instancesTable.addMouseListener(instanceSelectionListener);
    JScrollPane dataTableScrollPane = new JScrollPane(instancesTable);

    // Instance details table
    detailsTable = new JTable();
    detailsTable.setRowSelectionAllowed(true);
    JScrollPane detailsScrollPane = new JScrollPane(detailsTable);

    // Split pane dividing the instance details and the instances table
    JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, detailsScrollPane, dataTableScrollPane);
    splitter.setDividerLocation(300);
    add(splitter, BorderLayout.CENTER);

    ClassProvider clsProvider = new ClassProvider(data);
    InstanceProvider instanceProvider = new InstanceProvider(data);
    presenter = new InstancesInfoPresenterImpl(this, instances, clsProvider, instanceProvider);
    showInstanceDetails(Collections.emptyMap());
}
 
Example 3
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 4
Source File: JSTestDriverCustomizerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initTableVisualProperties(JTable table) {
    table.setRowSelectionAllowed(true);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setTableHeader(null);
    table.setRowHeight(jBrowsersTable.getRowHeight() + 4);        
    table.setIntercellSpacing(new java.awt.Dimension(0, 0));        
    // set the color of the table's JViewport
    table.getParent().setBackground(table.getBackground());
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.getColumnModel().getColumn(0).setMaxWidth(30);
}
 
Example 5
Source File: LanguageTableModel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void initializeTable(JTable table)
{
	table.setCellSelectionEnabled(false);
	table.setRowSelectionAllowed(false);
	table.setColumnSelectionAllowed(false);
	table.setFocusable(false);
	table.setRowHeight(21);
	table.getTableHeader().setReorderingAllowed(false);
}
 
Example 6
Source File: TableUtils.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static void setEnabled(JTable table, boolean enabled) {
  table.setEnabled(enabled);
  if (enabled) {
    table.setRowSelectionAllowed(true);
    table.setForeground(Color.black);
    table.setBackground(Color.white);
  } else {
    table.setRowSelectionAllowed(false);
    table.setForeground(Color.gray);
    table.setBackground(Color.lightGray);
  }
}
 
Example 7
Source File: TaskProgressTable.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 */
public TaskProgressTable() {

  super(new BorderLayout());

  add(new JLabel("Tasks in progress..."), BorderLayout.NORTH);

  TaskControllerImpl taskController = (TaskControllerImpl) MZmineCore.getTaskController();

  taskTable = new JTable(taskController.getTaskQueue());
  taskTable.setCellSelectionEnabled(false);
  taskTable.setColumnSelectionAllowed(false);
  taskTable.setRowSelectionAllowed(true);
  taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  taskTable.setDefaultRenderer(JComponent.class, new ComponentCellRenderer());
  taskTable.getTableHeader().setReorderingAllowed(false);

  JScrollPane jJobScroll = new JScrollPane(taskTable);
  add(jJobScroll, BorderLayout.CENTER);

  // Create popup menu and items
  popupMenu = new JPopupMenu();

  priorityMenu = new JMenu("Set priority...");
  highPriorityMenuItem = GUIUtils.addMenuItem(priorityMenu, "High", this);
  normalPriorityMenuItem = GUIUtils.addMenuItem(priorityMenu, "Normal", this);
  popupMenu.add(priorityMenu);

  cancelTaskMenuItem = GUIUtils.addMenuItem(popupMenu, "Cancel task", this);
  cancelAllMenuItem = GUIUtils.addMenuItem(popupMenu, "Cancel all tasks", this);

  // Addd popup menu to the task table
  taskTable.setComponentPopupMenu(popupMenu);

  // Set the width for first column (task description)
  taskTable.getColumnModel().getColumn(0).setPreferredWidth(350);

  jJobScroll.setPreferredSize(new Dimension(600, 120));

}
 
Example 8
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane createVariablesTable(final String labelName) {
    variablesTable = new JTable();
    variablesTable.setName(labelName);
    variablesTable.setRowSelectionAllowed(true);
    bindingCtx.bind("variables", new VariablesTableAdapter(variablesTable));
    bindingCtx.bindEnabledState("variables", false, "updateMode", true);
    variablesTable.addMouseListener(createExpressionEditorMouseListener(variablesTable, false));

    final JTableHeader tableHeader = variablesTable.getTableHeader();
    tableHeader.setName(labelName);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(true);

    final TableColumnModel columnModel = variablesTable.getColumnModel();
    columnModel.setColumnSelectionAllowed(false);

    final TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(100);
    nameColumn.setCellRenderer(new TCR());

    final TableColumn expressionColumn = columnModel.getColumn(1);
    expressionColumn.setPreferredWidth(400);
    expressionColumn.setCellRenderer(new TCR());
    final ExprEditor exprEditor = new ExprEditor(false);
    expressionColumn.setCellEditor(exprEditor);
    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            exprEditor.button.setEnabled(enabled);
        }
    });

    final JScrollPane scrollPane = new JScrollPane(variablesTable);
    scrollPane.setName(labelName);
    scrollPane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 150));

    return scrollPane;
}
 
Example 9
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 10
Source File: SettlementTable.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void init(JTable t) {

		t.setRowSelectionAllowed(true);
		setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		setGridColor(java.awt.Color.WHITE);

		header = getTableHeader();
		header.setFont(new Font("Dialog", Font.BOLD, 12));
		header.setBackground(BACK_COLOR);//new java.awt.Color(229,171,0));//.orange);//(0, 167, 212));
		header.setForeground(FORE_COLOR);//java.awt.Color.white); 

		//configEditor.getSettlementScrollPane().setViewportView(this);

		// Create combo box for editing template column in settlement table.
		TableColumn templateColumn = getColumnModel().getColumn(COLUMN_TEMPLATE);
		JComboBoxMW<String> templateCB = new JComboBoxMW<String>();
		SettlementConfig settlementConfig = simulationConfig.getSettlementConfiguration();
		Iterator<SettlementTemplate> i = settlementConfig.getSettlementTemplates().iterator();
		while (i.hasNext()) {
			templateCB.addItem(i.next().getTemplateName());
		}

		templateColumn.setCellEditor(new DefaultCellEditor(templateCB));

		editor = getCellEditor();

		// 2015-10-03 Added the edit button
		Action editAction = new javax.swing.AbstractAction() {
		    public void actionPerformed(ActionEvent e){
		        JTable settlementTable = (JTable)e.getSource();
		        int modelRow = Integer.valueOf( e.getActionCommand() );
		        ((SettlementTableModel)settlementTable.getModel()).editMSD(modelRow);
		        settlementTableModel.editMSD(modelRow);
		    }};
		//ButtonColumn buttonColumn = new ButtonColumn(this, editAction, COLUMN_EDIT_MSD);
		//buttonColumn.setMnemonic(KeyEvent.VK_E);

		// 2015-10-03 Determines proper width for each column and center aligns each cell content
        adjustColumn();

	    //CheckBoxRenderer checkBoxRenderer = new CheckBoxRenderer();
	    //getColumnModel().getColumn(COLUMN_HAS_MSD).setCellRenderer(checkBoxRenderer);

	}
 
Example 11
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JScrollPane createConditionsTable(final String labelName) {
    conditionsTable = new JTable() {
        private static final long serialVersionUID = 1L;

        @Override
        public Class getColumnClass(int column) {
            if (column == 2) {
                return Boolean.class;
            } else {
                return super.getColumnClass(column);
            }
        }
    };
    conditionsTable.setName(labelName);
    conditionsTable.setRowSelectionAllowed(true);
    bindingCtx.bind("conditions", new ConditionsTableAdapter(conditionsTable));
    bindingCtx.bindEnabledState("conditions", false, "updateMode", true);
    conditionsTable.addMouseListener(createExpressionEditorMouseListener(conditionsTable, true));

    final JTableHeader tableHeader = conditionsTable.getTableHeader();
    tableHeader.setName(labelName);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(true);

    final TableColumnModel columnModel = conditionsTable.getColumnModel();
    columnModel.setColumnSelectionAllowed(false);

    final TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(100);
    nameColumn.setCellRenderer(new TCR());

    final TableColumn expressionColumn = columnModel.getColumn(1);
    expressionColumn.setPreferredWidth(360);
    expressionColumn.setCellRenderer(new TCR());
    final ExprEditor cellEditor = new ExprEditor(true);
    expressionColumn.setCellEditor(cellEditor);
    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            cellEditor.button.setEnabled(enabled);
        }
    });


    final TableColumn outputColumn = columnModel.getColumn(2);
    outputColumn.setPreferredWidth(40);

    final JScrollPane pane = new JScrollPane(conditionsTable);
    pane.setName(labelName);
    pane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 80));

    return pane;
}
 
Example 12
Source File: PixelExtractionParametersForm.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JComponent[] createCoordinatesComponents() {
    Product selectedProduct = appContext.getSelectedProduct();
    if (selectedProduct != null) {
        final PlacemarkGroup pinGroup = selectedProduct.getPinGroup();
        for (int i = 0; i < pinGroup.getNodeCount(); i++) {
            coordinateTableModel.addPlacemark(pinGroup.get(i));
        }
    }

    JTable coordinateTable = new JTable(coordinateTableModel);
    coordinateTable.setName("coordinateTable");
    coordinateTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    coordinateTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    coordinateTable.setRowSelectionAllowed(true);
    coordinateTable.getTableHeader().setReorderingAllowed(false);
    coordinateTable.setDefaultRenderer(Double.class, new DecimalTableCellRenderer(new DecimalFormat("0.0000")));
    coordinateTable.setPreferredScrollableViewportSize(new Dimension(250, 100));
    coordinateTable.getColumnModel().getColumn(1).setCellEditor(new DecimalCellEditor(-90, 90));
    coordinateTable.getColumnModel().getColumn(2).setCellEditor(new DecimalCellEditor(-180, 180));

    final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ISO 8601
    final DateFormat timeFormat = ProductData.UTC.createDateFormat("HH:mm:ss"); // ISO 8601
    DateTimePickerCellEditor cellEditor = new DateTimePickerCellEditor(dateFormat, timeFormat);
    cellEditor.setClickCountToStart(1);
    coordinateTable.getColumnModel().getColumn(3).setCellEditor(cellEditor);
    coordinateTable.getColumnModel().getColumn(3).setPreferredWidth(200);
    final DateCellRenderer dateCellRenderer = new DateCellRenderer(dateFormat);
    dateCellRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
    coordinateTable.getColumnModel().getColumn(3).setCellRenderer(dateCellRenderer);
    final JScrollPane rasterScrollPane = new JScrollPane(coordinateTable);

    final AbstractButton addButton = ToolButtonFactory.createButton(ADD_ICON, false);
    addButton.addActionListener(new AddPopupListener());
    final AbstractButton removeButton = ToolButtonFactory.createButton(REMOVE_ICON, false);
    removeButton.addActionListener(new RemovePlacemarksListener(coordinateTable, coordinateTableModel));
    final JPanel buttonPanel = new JPanel();
    final BoxLayout layout = new BoxLayout(buttonPanel, BoxLayout.Y_AXIS);
    buttonPanel.setLayout(layout);
    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    return new JComponent[]{rasterScrollPane, buttonPanel};
}
 
Example 13
Source File: ScreenInfoPanel.java    From hprof-tools with MIT License 4 votes vote down vote up
public ScreenInfoPanel(@Nonnull final TabbedInfoWindow mainWindow, @Nonnull List<Screen> screens) {
    super(new BorderLayout());

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem item = new JMenuItem("Inspect View");
    item.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            mainWindow.showInstancesListTab(rightClickedViewed.getClassName(), Collections.singletonList(rightClickedViewed.getInstance()));
        }
    });
    popupMenu.add(item);

    imagePanel = new ImagePanel();
    viewTree = new JTree(new DefaultMutableTreeNode("Loading..."));
    viewTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    viewTree.addTreeSelectionListener(this);
    viewTree.addMouseListener(new PopupListener(popupMenu));
    JScrollPane treeScroller = new JScrollPane(viewTree);

    rootPicker = new JComboBox(new Vector<Object>(screens));
    rootPicker.addItemListener(this);

    JPanel settingsPanel = new JPanel(new GridLayout(1, 2));
    showBoundsBox = new JCheckBox("Show layout bounds", true);
    showBoundsBox.addItemListener(this);
    forceAlpha = new JCheckBox("Force alpha", true);
    forceAlpha.addItemListener(this);
    settingsPanel.add(showBoundsBox);
    settingsPanel.add(forceAlpha);
    settingsPanel.setBorder(new EmptyBorder(10, 0, 0, 0));

    infoTable = new JTable();
    infoTable.setRowSelectionAllowed(false);
    infoTable.setColumnSelectionAllowed(false);
    infoTable.setCellSelectionEnabled(false);
    infoTable.setShowGrid(true);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    bottomPanel.add(infoTable, BorderLayout.CENTER);
    bottomPanel.add(infoTable.getTableHeader(), BorderLayout.NORTH);
    bottomPanel.add(settingsPanel, BorderLayout.SOUTH);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(rootPicker, BorderLayout.NORTH);
    leftPanel.add(treeScroller, BorderLayout.CENTER);
    leftPanel.add(bottomPanel, BorderLayout.SOUTH);

    // Split pane for the tree and image views
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(imagePanel);
    add(splitPane, BorderLayout.CENTER);
    selectedScreen = screens.get(0);
    update();
}
 
Example 14
Source File: ProjectParametersSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {

    panelParameterValues = new JPanel(new BorderLayout());
    scrollParameterValues = new JScrollPane();
    tablemodelParameterValues =
        new ParameterTableModel(new RawDataFile[0], new Hashtable<UserParameter<?, ?>, Object[]>());
    tableParameterValues = new JTable(tablemodelParameterValues);
    tableParameterValues.setColumnSelectionAllowed(true);
    tableParameterValues.setRowSelectionAllowed(false);
    scrollParameterValues.setViewportView(tableParameterValues);
    scrollParameterValues.setMinimumSize(new Dimension(100, 100));
    scrollParameterValues.setPreferredSize(new Dimension(100, 100));
    panelRemoveParameterButton = new JPanel(new FlowLayout(FlowLayout.LEFT));
    buttonAddParameter = new JButton("Add new parameter");
    buttonAddParameter.addActionListener(this);
    buttonImportParameters = new JButton("Import parameters and values...");
    buttonImportParameters.addActionListener(this);
    buttonRemoveParameter = new JButton("Remove selected parameter");
    buttonRemoveParameter.addActionListener(this);

    panelRemoveParameterButton.add(buttonAddParameter);
    panelRemoveParameterButton.add(buttonImportParameters);
    panelRemoveParameterButton.add(buttonRemoveParameter);

    panelParameterValues.add(scrollParameterValues, BorderLayout.CENTER);
    panelParameterValues.add(panelRemoveParameterButton, BorderLayout.SOUTH);
    panelParameterValues.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    panelOKCancelButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    buttonOK = new JButton("OK");
    buttonOK.addActionListener(this);
    buttonCancel = new JButton("Cancel");
    buttonCancel.addActionListener(this);
    panelOKCancelButtons.add(buttonOK);
    panelOKCancelButtons.add(buttonCancel);

    setLayout(new BorderLayout());

    add(panelParameterValues, BorderLayout.CENTER);
    add(panelOKCancelButtons, BorderLayout.SOUTH);

    pack();
  }
 
Example 15
Source File: PlacemarkManagerTopComponent.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
    setLayout(new BorderLayout());
    placemarkTable = new JTable(placemarkTableModel);
    placemarkTable.setRowSorter(new TableRowSorter<>(placemarkTableModel));
    placemarkTable.setName("placemarkTable");
    placemarkTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    placemarkTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    placemarkTable.setRowSelectionAllowed(true);
    // IMPORTANT: We set ReorderingAllowed=false, because we export the
    // table model AS IS to a flat text file.
    placemarkTable.getTableHeader().setReorderingAllowed(false);

    ToolTipSetter toolTipSetter = new ToolTipSetter();
    placemarkTable.addMouseMotionListener(toolTipSetter);
    placemarkTable.addMouseListener(toolTipSetter);
    placemarkTable.addMouseListener(new PopupListener());
    placemarkTable.getSelectionModel().addListSelectionListener(new PlacemarkTableSelectionHandler());
    updateTableModel();

    final TableColumnModel columnModel = placemarkTable.getColumnModel();
    columnModel.addColumnModelListener(new ColumnModelListener());

    JScrollPane tableScrollPane = new JScrollPane(placemarkTable);
    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.add(tableScrollPane, BorderLayout.CENTER);

    buttonPane = new PlacemarkManagerButtons(this);

    JPanel content = new JPanel(new BorderLayout(4, 4));
    content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    content.add(BorderLayout.CENTER, mainPane);
    content.add(BorderLayout.EAST, buttonPane);
    Component southExtension = getSouthExtension();
    if (southExtension != null) {
        content.add(BorderLayout.SOUTH, southExtension);
    }
    content.setPreferredSize(new Dimension(420, 200));

    setCurrentView(snapApp.getSelectedProductSceneView());
    setProduct(snapApp.getSelectedProduct(VIEW));
    snapApp.getSelectionSupport(ProductSceneView.class).addHandler(new ProductSceneViewSelectionChangeHandler());
    snapApp.getProductManager().addListener(new ProductRemovedListener());
    updateUIState();
    add(content, BorderLayout.CENTER);
}
 
Example 16
Source File: FinishedStudyListPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor
 * 
 * @param scienceWindow the science window.
 */
FinishedStudyListPanel(ScienceWindow scienceWindow) {
	// Use JPanel constructor.
	super();

	this.scienceWindow = scienceWindow;

	setLayout(new BorderLayout());

	JLabel titleLabel = new JLabel(Msg.getString("FinishedStudyListPanel.finishedScientificStudies"), //$NON-NLS-1$
			JLabel.CENTER);
	add(titleLabel, BorderLayout.NORTH);

	// Create list scroll pane.
	listScrollPane = new JScrollPane();
	listScrollPane.setBorder(new MarsPanelBorder());
	listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	add(listScrollPane, BorderLayout.CENTER);

	// Create study table model.
	studyTableModel = new StudyTableModel();

	// Create study table.
	studyTable = new JTable(studyTableModel);
	studyTable.setPreferredScrollableViewportSize(new Dimension(500, 200));
	studyTable.setCellSelectionEnabled(false);
	studyTable.setRowSelectionAllowed(true);
	studyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	studyTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent event) {
			if (event.getValueIsAdjusting()) {
				int row = studyTable.getSelectedRow();
				if (row >= 0) {
					ScientificStudy selectedStudy = studyTableModel.getStudy(row);
					if (selectedStudy != null)
						setSelectedScientificStudy(selectedStudy);
				}
			}
		}
	});
	studyTable.getColumnModel().getColumn(0).setPreferredWidth(40);
	studyTable.getColumnModel().getColumn(1).setPreferredWidth(7);
	studyTable.getColumnModel().getColumn(2).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	
	studyTable.setAutoCreateRowSorter(true);

	TableStyle.setTableStyle(studyTable);

	listScrollPane.setViewportView(studyTable);
}
 
Example 17
Source File: OngoingStudyListPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param scienceWindow the science window.
 */
public OngoingStudyListPanel(ScienceWindow scienceWindow) {
	// Use JPanel constructor.
	super();

	this.scienceWindow = scienceWindow;

	setLayout(new BorderLayout());

	// Create title label.
	JLabel titleLabel = new JLabel(Msg.getString("OngoingStudyListPanel.ongoingScientificStudies"), JLabel.CENTER); //$NON-NLS-1$
	add(titleLabel, BorderLayout.NORTH);

	// Create list scroll pane.
	listScrollPane = new JScrollPane();
	listScrollPane.setBorder(new MarsPanelBorder());
	listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	add(listScrollPane, BorderLayout.CENTER);

	// Create study table model.
	studyTableModel = new StudyTableModel();

	// Create study table.
	studyTable = new JTable(studyTableModel);
	studyTable.setPreferredScrollableViewportSize(new Dimension(500, 200));
	studyTable.setCellSelectionEnabled(false);
	studyTable.setRowSelectionAllowed(true);
	studyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	studyTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent event) {
			if (event.getValueIsAdjusting()) {
				int row = studyTable.getSelectedRow();
				if (row >= 0) {
					ScientificStudy selectedStudy = studyTableModel.getStudy(row);
					if (selectedStudy != null) setSelectedScientificStudy(selectedStudy);
				}
			}
		}
	});
	studyTable.getColumnModel().getColumn(0).setPreferredWidth(40);
	studyTable.getColumnModel().getColumn(1).setPreferredWidth(7);
	studyTable.getColumnModel().getColumn(2).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	
	studyTable.setAutoCreateRowSorter(true);
	
	TableStyle.setTableStyle(studyTable);
	
	listScrollPane.setViewportView(studyTable);
}
 
Example 18
Source File: Main_CustomersFrame.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
public Main_CustomersFrame() {

        this.setAutoscrolls(true);
        this.setMinimumSize(new Dimension(800, 600));
        /*make it default size of frame maximized */
        this.setMaximumSize(new Dimension(1000, 900));
        this.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
        setLayout(new BorderLayout(0, 0));

        bean = LocaleBean.getInstance();
        loggingEngine = LoggingEngine.getInstance();
        componentOrientation = new ChangeComponentOrientation();
        componentOrientation.setThePanel(this);

        searchPanel.setDoubleBuffered(false);
        searchPanel.setAutoscrolls(true);
        add(searchPanel, BorderLayout.NORTH);
        searchPanel.setPreferredSize(new Dimension(10, 30));

        lblTableFilter = new JLabel("Type to search : ");
        lblTableFilter.setForeground(new Color(178, 34, 34));
        lblTableFilter.setSize(new Dimension(130, 25));
        lblTableFilter.setPreferredSize(new Dimension(130, 22));
        lblTableFilter.setHorizontalTextPosition(SwingConstants.CENTER);
        lblTableFilter.setAutoscrolls(true);
        lblTableFilter.setHorizontalAlignment(SwingConstants.LEFT);
        lblTableFilter.setFont(new Font("Dialog", Font.BOLD, 15));

        searchFilterField = new JTextField();
        searchFilterField.setDragEnabled(true);
        searchFilterField.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(0, 191, 255), null, null, null));
        searchFilterField.setPreferredSize(new Dimension(200, 22));
        searchFilterField.setIgnoreRepaint(true);
        searchFilterField.setColumns(10);
        searchFilterField.setFont(new Font("Dialog", Font.BOLD, 13));
        searchFilterField.setHorizontalAlignment(SwingConstants.LEFT);
        GroupLayout gl_searchPanel = new GroupLayout(searchPanel);
        gl_searchPanel.setHorizontalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(ComponentPlacement.RELATED)
                                .addComponent(searchFilterField, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                                .addGap(118))
        );
        gl_searchPanel.setVerticalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addGap(5)
                                .addGroup(gl_searchPanel.createParallelGroup(Alignment.BASELINE)
                                        .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(searchFilterField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                .addContainerGap())
        );
        searchPanel.setLayout(gl_searchPanel);

        searchFilterField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {

                final String searchedWord = searchFilterField.getText();
                filter(searchedWord);

            }
        });

        scrollPane = new JScrollPane();
        add(scrollPane);

        //populate main table model with custom method
        populateMainTable(model);

        customerTable = new JTable(model);
        customerTable.setFillsViewportHeight(true);
        customerTable.setRowSelectionAllowed(true);

        THR.setHorizontalAlignment(SwingConstants.CENTER);

        customerTable.setDefaultRenderer(Object.class, renderer);
        customerTable.getTableHeader().setDefaultRenderer(THR);
        customerTable.setFont(new Font("Dialog", Font.PLAIN, 14));
        customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        customerTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        customerTable.setBackground(new Color(245, 245, 245));
        customerTable.addMouseListener(openCustomerListener());
        scrollPane.setViewportView(customerTable);

        //change component orientation with locale.
        if (bean.getLocale().toString().equals("ar_IQ")) {
            componentOrientation.changeOrientationOfJPanelToRight();
        } else {
            componentOrientation.changeOrientationOfJPanelToLeft();
        }
        //inject action event to Customers detail window to save all changes
        custWindow.setActionListener(saveChanges());
        this.setVisible(true);
    }
 
Example 19
Source File: ContentPanel.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.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    pCentral = new javax.swing.JPanel();
    spTable = new javax.swing.JScrollPane();
    tModules = new JTable () {
        public Component prepareRenderer (TableCellRenderer renderer,
            int rowIndex,
            int vColIndex) {
            Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
            if (c instanceof JComponent && vColIndex != 0) {
                JComponent jc = (JComponent) c;
                jc.setToolTipText (prepareToolTip ((String) getValueAt (rowIndex, vColIndex)));
            }
            return c;
        }
    };

    pCentral.setLayout(new javax.swing.BoxLayout(pCentral, javax.swing.BoxLayout.Y_AXIS));

    tModules.setRowSelectionAllowed(false);
    spTable.setViewportView(tModules);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(pCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
        .addGroup(layout.createSequentialGroup()
            .addComponent(spTable, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(pCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
            .addGap(25, 25, 25)
            .addComponent(spTable, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );
}
 
Example 20
Source File: TransactionsPanel.java    From btdex with GNU General Public License v3.0 4 votes vote down vote up
public TransactionsPanel() {
	super(new BorderLayout());

	table = new JTable(model = new MyTableModel());
	table.setRowHeight(table.getRowHeight()+10);
	table.setRowSelectionAllowed(false);
	table.getTableHeader().setReorderingAllowed(false);
	
	copyIcon = IconFontSwing.buildIcon(Icons.COPY, 12, table.getForeground());
	expIcon = IconFontSwing.buildIcon(Icons.EXPLORER, 12, table.getForeground());

	JScrollPane scrollPane = new JScrollPane(table);
	table.setFillsViewportHeight(true);

	// Center header and all columns
	DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( JLabel.CENTER );
	for (int i = 0; i < table.getColumnCount(); i++) {
		table.getColumnModel().getColumn(i).setCellRenderer( centerRenderer );			
	}
	JTableHeader jtableHeader = table.getTableHeader();
	DefaultTableCellRenderer rend = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer();
	rend.setHorizontalAlignment(JLabel.CENTER);
	jtableHeader.setDefaultRenderer(rend);

	table.setAutoCreateColumnsFromModel(false);

	table.getColumnModel().getColumn(COL_ID).setCellRenderer(OrderBook.BUTTON_RENDERER);
	table.getColumnModel().getColumn(COL_ID).setCellEditor(OrderBook.BUTTON_EDITOR);
	table.getColumnModel().getColumn(COL_ACCOUNT).setCellRenderer(OrderBook.BUTTON_RENDERER);
	table.getColumnModel().getColumn(COL_ACCOUNT).setCellEditor(OrderBook.BUTTON_EDITOR);
	//
	table.getColumnModel().getColumn(COL_ACCOUNT).setPreferredWidth(200);
	table.getColumnModel().getColumn(COL_ID).setPreferredWidth(200);
	table.getColumnModel().getColumn(COL_TIME).setPreferredWidth(120);
	
	statusLabel = new JLabel(" ", JLabel.RIGHT);
	statusLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

	add(statusLabel, BorderLayout.PAGE_START);
	add(scrollPane, BorderLayout.CENTER);
}