Java Code Examples for javax.swing.table.TableColumn#setCellRenderer()

The following examples show how to use javax.swing.table.TableColumn#setCellRenderer() . 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: TableAligner.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Installs alignment decorators in the table column at {@code colViewIndex}.
 *
 * @param table a table.
 * @param colViewIndex the index of the column in the table <i>view</i>.
 * @param alignment one of the following constants:
 *        <ul>
 *        <li>{@link SwingConstants#LEFT}</li>
 *        <li>{@link SwingConstants#CENTER} (the default for image-only labels)</li>
 *        <li>{@link SwingConstants#RIGHT}</li>
 *        <li>{@link SwingConstants#LEADING} (the default for text-only labels)</li>
 *        <li>{@link SwingConstants#TRAILING}</li>
 *        </ul>
 */
public static void installInOneColumn(JTable table, int colViewIndex, int alignment) {
  TableColumn tableColumn = table.getColumnModel().getColumn(colViewIndex);

  TableCellRenderer headerRenderer = tableColumn.getHeaderRenderer();
  if (headerRenderer == null) {
    headerRenderer = table.getTableHeader().getDefaultRenderer();
  }
  if (!(headerRenderer instanceof RendererAlignmentDecorator)) { // Don't install a redundant decorator.
    tableColumn.setHeaderRenderer(new RendererAlignmentDecorator(headerRenderer, alignment));
  }

  TableCellRenderer cellRenderer = tableColumn.getCellRenderer();
  if (cellRenderer == null) {
    cellRenderer = table.getDefaultRenderer(table.getColumnClass(colViewIndex));
  }
  if (!(cellRenderer instanceof RendererAlignmentDecorator)) { // Don't install a redundant decorator.
    tableColumn.setCellRenderer(new RendererAlignmentDecorator(cellRenderer, alignment));
  }
}
 
Example 2
Source File: LogTable.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public LogTable(final JTextArea detailTextArea) {

      init();

      _detailTextArea = detailTextArea;

      setModel(new FilteredLogTableModel());

      final Enumeration columns = getColumnModel().getColumns();
      int i = 0;
      while (columns.hasMoreElements()) {
         final TableColumn col = (TableColumn) columns.nextElement();
         col.setCellRenderer(new LogTableRowRenderer());
         col.setPreferredWidth(_colWidths[i]);

         _tableColumns[i] = col;
         i++;
      }

      final ListSelectionModel rowSM = getSelectionModel();
      rowSM.addListSelectionListener(new LogTableListSelectionListener(this));

      //setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
   }
 
Example 3
Source File: ResamplingUtils.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public static void setUpDownsamplingColumn(JTable table,
                                            TableColumn downsamplingColumn, String defaultDownsampling) {
    //Set up the editor for the downsampling
    JComboBox comboBox = new JComboBox();
    for ( String alias : (Set<String>) GPF.getDefaultInstance().getDownsamplerSpiRegistry().getAliases()) {
        comboBox.addItem(alias);
    }

    if(defaultDownsampling != null) {
        comboBox.setSelectedItem(defaultDownsampling);
    }
    downsamplingColumn.setCellEditor(new DefaultCellEditor(comboBox));

    DefaultTableCellRenderer renderer =
            new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    downsamplingColumn.setCellRenderer(renderer);
}
 
Example 4
Source File: RowNumberTable.java    From beast-mcmc with GNU Lesser General Public License v2.1 6 votes vote down vote up
public RowNumberTable(JTable table) {
	main = table;
	main.addPropertyChangeListener(this);

	setFocusable(false);
	setAutoCreateColumnsFromModel(false);
	setModel(main.getModel());
	setSelectionModel(main.getSelectionModel());

	TableColumn column = new TableColumn();
	column.setHeaderValue(" ");
	addColumn(column);
	column.setCellRenderer(new RowNumberRenderer());

	getColumnModel().getColumn(0).setPreferredWidth(50);
	setPreferredScrollableViewportSize(getPreferredSize());
}
 
Example 5
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public void updateUI() {
  // [JDK-6788475] Changing to Nimbus LAF and back doesn't reset look and feel of JTable completely - Java Bug System
  // https://bugs.openjdk.java.net/browse/JDK-6788475
  // XXX: set dummy ColorUIResource
  setSelectionForeground(new ColorUIResource(Color.RED));
  setSelectionBackground(new ColorUIResource(Color.RED));
  setDefaultRenderer(Object.class, null);
  super.updateUI();

  putClientProperty("Table.isFileList", Boolean.TRUE);
  setCellSelectionEnabled(true);
  setIntercellSpacing(new Dimension());
  setShowGrid(false);
  setAutoCreateRowSorter(true);
  setFillsViewportHeight(true);

  TableCellRenderer r = new DefaultTableCellRenderer();
  setDefaultRenderer(Object.class, (table, value, isSelected, hasFocus, row, column) ->
      r.getTableCellRendererComponent(table, value, false, false, row, column));

  TableColumn col = getColumnModel().getColumn(0);
  col.setCellRenderer(new FileNameRenderer(this));
  col.setPreferredWidth(200);
  col = getColumnModel().getColumn(1);
  col.setPreferredWidth(300);
}
 
Example 6
Source File: LogTable.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public LogTable(JTextArea detailTextArea) {
  super();

  init();

  _detailTextArea = detailTextArea;

  setModel(new FilteredLogTableModel());

  Enumeration columns = getColumnModel().getColumns();
  int i = 0;
  while (columns.hasMoreElements()) {
    TableColumn col = (TableColumn) columns.nextElement();
    col.setCellRenderer(new LogTableRowRenderer());
    col.setPreferredWidth(_colWidths[i]);

    _tableColumns[i] = col;
    i++;
  }

  ListSelectionModel rowSM = getSelectionModel();
  rowSM.addListSelectionListener(new LogTableListSelectionListener(this));

  //setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
}
 
Example 7
Source File: DiffTreeTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupColumns() {
    ResourceBundle loc = NbBundle.getBundle(DiffTreeTable.class);
    setPropertyColumns(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path"),
            RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time"),
            RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username"),
            RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message"));
    setPropertyColumnDescription(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path_Desc"));
    setPropertyColumnDescription(RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time_Desc"));
    setPropertyColumnDescription(RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username_Desc"));
    setPropertyColumnDescription(RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message_Desc"));
    TableColumnModel model = getOutline().getColumnModel();
    if (model instanceof ETableColumnModel) {
        ((ETableColumnModel) model).setColumnHidden(model.getColumn(1), true);
    }
    TableColumn column = getOutline().getColumn(loc.getString("LBL_DiffTree_Column_Message"));
    column.setCellRenderer(new MessageRenderer(getOutline().getDefaultRenderer(String.class)));
    setDefaultColumnSizes();
}
 
Example 8
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private MainPanel() {
  super(new BorderLayout());

  String[] columnNames = {"user", "rwx"};
  Object[][] data = {
    {"owner", 7}, {"group", 6}, {"other", 5}
  };
  TableModel model = new DefaultTableModel(data, columnNames) {
    @Override public Class<?> getColumnClass(int column) {
      return getValueAt(0, column).getClass();
    }
  };
  JTable table = new JTable(model) {
    @Override public void updateUI() {
      super.updateUI();
      TableColumn c = getColumnModel().getColumn(1);
      c.setCellRenderer(new CheckBoxesRenderer());
      c.setCellEditor(new CheckBoxesEditor());
    }
  };
  table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

  // if (System.getProperty("java.version").startsWith("1.6.0")) {
  //   // 1.6.0_xx bug? column header click -> edit cancel?
  //   table.getTableHeader().addMouseListener(new MouseAdapter() {
  //     @Override public void mousePressed(MouseEvent e) {
  //       if (table.isEditing()) {
  //         table.getCellEditor().stopCellEditing();
  //       }
  //     }
  //   });
  // }


  add(new JScrollPane(table));
  setPreferredSize(new Dimension(320, 240));
}
 
Example 9
Source File: ObjectivePanel.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
protected void initLayout() {
  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  objectiveModel = new ObjectiveTableModel();
  final JTable table = new JTable(objectiveModel);
  table.getTableHeader().setReorderingAllowed(false);
  final TableColumn column0 = table.getColumnModel().getColumn(0);
  column0.setPreferredWidth(34);
  column0.setWidth(34);
  column0.setMaxWidth(34);
  column0.setCellRenderer(new ColorTableCellRenderer());
  final TableColumn column1 = table.getColumnModel().getColumn(1);
  column1.setCellEditor(new EditorPaneCellEditor());
  column1.setCellRenderer(new EditorPaneTableCellRenderer());
  final JScrollPane scroll = new JScrollPane(table);
  final JButton refresh = new JButton("Refresh Objectives");
  refresh.setAlignmentY(Component.CENTER_ALIGNMENT);
  refresh.addActionListener(
      SwingAction.of(
          "Refresh Objectives",
          e -> {
            objectiveModel.loadData();
            SwingUtilities.invokeLater(table::repaint);
          }));
  add(Box.createVerticalStrut(6));
  add(refresh);
  add(Box.createVerticalStrut(6));
  add(scroll);
}
 
Example 10
Source File: DesktopAbstractTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void refreshCellStyles() {
    for (Column col : columnsOrder) {
        // generated column handles styles himself
        if (!tableModel.isGeneratedColumn(col)) {
            TableColumn tableColumn = getColumn(col);

            // If column is not hidden by security
            if (tableColumn != null) {
                boolean useStyledCells = styleProviders != null && !styleProviders.isEmpty();
                tableColumn.setCellRenderer(useStyledCells ? new StylingCellRenderer() : null);
            }
        }
    }
}
 
Example 11
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private MainPanel() {
  super(new BorderLayout());
  String[] columnNames = {"AAA", "BBB"};
  Object[][] data = {
    {makeOptionPaneDescription("error"), SEE},
    {makeOptionPaneDescription("information"), SEE},
    {makeOptionPaneDescription("question"), SEE},
    {makeOptionPaneDescription("warning"), SEE},
  };
  TableModel model = new DefaultTableModel(data, columnNames) {
    @Override public boolean isCellEditable(int row, int column) {
      return false;
    }
  };
  JTable table = new JTable(model);
  table.setAutoCreateRowSorter(true);
  table.getTableHeader().setReorderingAllowed(false);
  table.setRowSelectionAllowed(true);
  // table.setFocusable(false);
  table.setFillsViewportHeight(true);
  table.setShowVerticalLines(false);
  table.setIntercellSpacing(new Dimension(0, 1));
  table.setRowHeight(56);
  TableCellRenderer renderer = new ColumnSpanningCellRenderer();
  for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
    TableColumn c = table.getColumnModel().getColumn(i);
    c.setCellRenderer(renderer);
    c.setMinWidth(50);
  }
  add(new JScrollPane(table));
  setPreferredSize(new Dimension(320, 240));
}
 
Example 12
Source File: RunPortBindingsVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form RunNetworkVisual
 */
public RunPortBindingsVisual(DockerImageDetail info) {
    initComponents();
    this.info = info;

    addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
    portMappingTable.setModel(model);
    UiUtils.configureRowHeight(portMappingTable);

    TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
    JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
    typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
    typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);

    TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
    portColumn.setCellRenderer(new CellRenderer("<random>", false));

    TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
    JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
    addressCombo.setEditable(true);
    addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
    addressColumn.setCellRenderer(new CellRenderer("<any>", false));
    addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);

    portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            changeSupport.fireChange();
        }
    });
}
 
Example 13
Source File: CheckoutsPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void create(ItemCheckoutStatus[] checkouts) {
	tableModel = new CheckoutsTableModel(checkouts);

	// set up table sorter stuff
	TableSortStateEditor tsse = new TableSortStateEditor();
	tsse.addSortedColumn(CheckoutsTableModel.DATE_COL, SortDirection.DESCENDING);
	tableModel.setTableSortState(tsse.createTableSortState());

	table = new GTable(tableModel);
	JScrollPane sp = new JScrollPane(table);
	table.setPreferredScrollableViewportSize(new Dimension(680, 120));
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	add(sp, BorderLayout.CENTER);

	TableColumnModel columnModel = table.getColumnModel();
	//MyCellRenderer cellRenderer = new MyCellRenderer();

	TableColumn column;

	column = columnModel.getColumn(CheckoutsTableModel.DATE_COL);
	column.setPreferredWidth(120);
	column.setCellRenderer(new GenericDateCellRenderer("Date when file was checked out"));
	columnModel.getColumn(CheckoutsTableModel.VERSION_COL).setPreferredWidth(50);
	columnModel.getColumn(CheckoutsTableModel.USER_COL).setPreferredWidth(80);
	columnModel.getColumn(CheckoutsTableModel.HOST_COL).setPreferredWidth(120);
	columnModel.getColumn(CheckoutsTableModel.PROJECT_NAME_COL).setPreferredWidth(120);
	columnModel.getColumn(CheckoutsTableModel.PROJECT_LOC_COL).setPreferredWidth(180);
}
 
Example 14
Source File: MdbPropertiesPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateTableUI() {
    TableColumnModel columnModel = propertiesTable.getColumnModel();
    columnModel.getColumn(0).setPreferredWidth(180);
    TableColumn columnTwo = columnModel.getColumn(1);
    columnTwo.setPreferredWidth(280);
    columnTwo.setCellEditor(createCellEditor(getActivationConfigProperties()));
    columnTwo.setCellRenderer(new ACPCellRenderer(getActivationConfigProperties()));
    propertiesTable.setSelectionModel(new NullSelectionModel());
}
 
Example 15
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override public void updateUI() {
  super.updateUI();
  removeColumn(getColumnModel().getColumn(3));
  JProgressBar progress = new JProgressBar();
  TableCellRenderer renderer = new DefaultTableCellRenderer();
  TableColumn tc = getColumnModel().getColumn(2);
  tc.setCellRenderer((tbl, value, isSelected, hasFocus, row, column) -> {
    Component c;
    progress.setValue(0);
    if (value instanceof ProgressValue) {
      ProgressValue pv = (ProgressValue) value;
      Integer current = pv.getProgress();
      Integer lengthOfTask = pv.getLengthOfTask();
      if (current < 0) {
        c = renderer.getTableCellRendererComponent(tbl, "Canceled", isSelected, hasFocus, row, column);
      } else if (current < lengthOfTask) {
        // progress.setMaximum(lengthOfTask);
        // progress.setEnabled(true);
        progress.setValue(current * 100 / lengthOfTask);
        progress.setStringPainted(true);
        progress.setString(String.format("%d/%d", current, lengthOfTask));
        c = progress;
      } else {
        c = renderer.getTableCellRendererComponent(tbl, "Done", isSelected, hasFocus, row, column);
      }
    } else {
      c = renderer.getTableCellRendererComponent(tbl, "Waiting...", isSelected, hasFocus, row, column);
    }
    return c;
  });
}
 
Example 16
Source File: BotCWTableModel.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * Configure a column model.
 * 
 * @param table Table for which the column model should be configured.
 */
public void configureColumnModel(JTable table) {
  if (table == null) {
    return;
  }
  TableColumnModel model = table.getColumnModel();
  TableColumn column = null;

  column = model.getColumn(COLUMN_BOT);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setCellRenderer(
      new BooleanIconCellRenderer("commons-approve-icon.png", null));
  column.setHeaderRenderer(
      new IconCellRenderer("commons-nuvola-apps-kcmsystem.png"));

  column = model.getColumn(COLUMN_DESCRIPTION);
  column.setMinWidth(100);

  column = model.getColumn(COLUMN_FIX);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setHeaderRenderer(
      new IconCellRenderer("commons-nuvola-apps-kcmsystem.png"));

  column = model.getColumn(COLUMN_LIST);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setHeaderRenderer(
      new IconCellRenderer("gnome-logviewer.png"));

  column = model.getColumn(COLUMN_NUMBER);
  column.setMinWidth(40);
  column.setPreferredWidth(40);
  column.setMaxWidth(40);

  table.addMouseListener(EventHandler.create(
      MouseListener.class, this, "mouseClicked", "", "mouseClicked"));
}
 
Example 17
Source File: VTImpliedMatchesTableProvider.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private GThreadedTablePanel<ImpliedMatchWrapperRowObject> createImpliedMatchTablePanel() {
	impliedMatchTableModel = new VTImpliedMatchesTableModel(controller);
	GhidraThreadedTablePanel<ImpliedMatchWrapperRowObject> impliedMatchTablePanel =
		new GhidraThreadedTablePanel<>(impliedMatchTableModel);

	impliedMatchesTable = impliedMatchTablePanel.getTable();

	impliedSelectionListener = e -> {
		if (e.getValueIsAdjusting()) {
			return;
		}
		navigateSelectedItem();
		tool.contextChanged(VTImpliedMatchesTableProvider.this);
	};
	ListSelectionModel selectionModel = impliedMatchesTable.getSelectionModel();
	selectionModel.addListSelectionListener(impliedSelectionListener);

	impliedMatchTableModel.addTableModelListener(e -> {
		int filteredCount = impliedMatchTableModel.getRowCount();
		int unfilteredCount = impliedMatchTableModel.getUnfilteredRowCount();

		String sessionName = controller.getVersionTrackingSessionName();
		StringBuffer buffy = new StringBuffer();
		buffy.append("[Session: ").append(sessionName).append("] ");
		buffy.append('-').append(filteredCount).append(" matches");
		if (filteredCount != unfilteredCount) {
			buffy.append(" (of ").append(unfilteredCount).append(')');
		}

		setSubTitle(buffy.toString());
	});

	// setup the renderers
	TableColumnModel columnModel = impliedMatchesTable.getColumnModel();

	int sourceLabelColumnIndex =
		impliedMatchTableModel.getColumnIndex(SourceLabelTableColumn.class);
	TableColumn sourceLabelColumn = columnModel.getColumn(sourceLabelColumnIndex);
	sourceLabelColumn.setCellRenderer(
		new VTSymbolRenderer(controller.getServiceProvider(), impliedMatchesTable));

	int destinationLabelColumnIndex =
		impliedMatchTableModel.getColumnIndex(DestinationLabelTableColumn.class);
	TableColumn destinationLabelColumn = columnModel.getColumn(destinationLabelColumnIndex);
	destinationLabelColumn.setCellRenderer(
		new VTSymbolRenderer(controller.getServiceProvider(), impliedMatchesTable));

	int statusColumnIndex = impliedMatchTableModel.getColumnIndex(StatusTableColumn.class);
	TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
	statusColumn.setCellRenderer(new MatchStatusRenderer());

	// override the default behavior so we see our columns in their preferred size
	Dimension size = impliedMatchesTable.getPreferredScrollableViewportSize();
	Dimension preferredSize = impliedMatchesTable.getPreferredSize();

	// ...account for the scroll bar width
	JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
	Dimension scrollBarSize = scrollBar.getMinimumSize();
	size.width = preferredSize.width + scrollBarSize.width;
	impliedMatchesTable.setPreferredScrollableViewportSize(size);

	return impliedMatchTablePanel;
}
 
Example 18
Source File: StatTableModel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void initializeTable(JTable statsTable)
{
	JTableHeader tableHeader = statsTable.getTableHeader();
	tableHeader.setResizingAllowed(false);
	tableHeader.setReorderingAllowed(false);

	statsTable.setAutoCreateColumnsFromModel(false);
	DefaultTableColumnModel columnModel = new DefaultTableColumnModel();
	{
		TableColumn column =
				Utilities.createTableColumn(ABILITY_NAME, "Ability", new AbilityHeaderCellRenderer(), true);
		column.setIdentifier(ABILITY_COLUMN_ID);
		columnModel.addColumn(column);

		String htmlText = "<html><div align=\"center\">Final<br>Score</div></html>";
		column = Utilities.createTableColumn(FINAL_ABILITY_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText),
			false);
		column.setCellRenderer(new ValueRenderer());
		columnModel.addColumn(column);

		TableCellRenderer renderer = new ModRenderer();
		htmlText = "<html><div align=\"center\">Ability<br>Mod</div></html>";
		column = Utilities.createTableColumn(ABILITY_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false);
		column.setCellRenderer(renderer);
		columnModel.addColumn(column);

		htmlText = "<html><div align=\"center\">Editable<br>Score</div></html>";
		column = Utilities.createTableColumn(EDITABLE_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText),
			false);
		column.setIdentifier(EDITABLE_COLUMN_ID);
		columnModel.addColumn(column);

		htmlText = "<html><div align=\"center\">Race<br>Adj</div></html>";
		column = Utilities.createTableColumn(RACE_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false);
		column.setCellRenderer(renderer);
		columnModel.addColumn(column);

		htmlText = "<html><div align=\"center\">Misc<br>Adj</div></html>";
		column = Utilities.createTableColumn(MISC_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false);
		column.setCellRenderer(renderer);
		columnModel.addColumn(column);
	}
	statsTable.setColumnModel(columnModel);
	statsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	statsTable.setShowVerticalLines(false);
	statsTable.setCellSelectionEnabled(false);
	statsTable.setFocusable(false);
	// XXX this should be calculated relative to font size and the size of a jspinner
	statsTable.setRowHeight(27);
	statsTable.setOpaque(false);
	tableHeader.setFont(FontManipulation.title(statsTable.getFont()));
	FontManipulation.large(statsTable);
}
 
Example 19
Source File: AstrosoftTable.java    From Astrosoft with GNU General Public License v2.0 4 votes vote down vote up
public void setCellRenderer(TableCellRenderer renderer, AstrosoftTableColumn col){
  	TableColumn tc = getColumnModel().getColumn(((AstrosoftTableModel) getModel()).getColumnIndex(col));
tc.setCellRenderer(renderer);
  }
 
Example 20
Source File: ConfigDialog.java    From lizzie with GNU General Public License v3.0 4 votes vote down vote up
private void readDefaultTheme() {
  spnWinrateStrokeWidth.setValue(Lizzie.config.uiConfig.optInt("winrate-stroke-width", 3));
  spnMinimumBlunderBarWidth.setValue(
      Lizzie.config.uiConfig.optInt("minimum-blunder-bar-width", 3));
  spnShadowSize.setValue(Lizzie.config.uiConfig.optInt("shadow-size", 100));
  cmbFontName.setSelectedItem(Lizzie.config.uiConfig.optString("font-name", null));
  cmbUiFontName.setSelectedItem(Lizzie.config.uiConfig.optString("ui-font-name", null));
  cmbWinrateFontName.setSelectedItem(Lizzie.config.uiConfig.optString("winrate-font-name", null));
  txtBackgroundPath.setEnabled(false);
  btnBackgroundPath.setEnabled(false);
  txtBackgroundPath.setText("/assets/background.jpg");
  txtBoardPath.setEnabled(false);
  btnBoardPath.setEnabled(false);
  txtBoardPath.setText("/assets/board.png");
  txtBlackStonePath.setEnabled(false);
  btnBlackStonePath.setEnabled(false);
  txtBlackStonePath.setText("/assets/black0.png");
  txtWhiteStonePath.setEnabled(false);
  btnWhiteStonePath.setEnabled(false);
  txtWhiteStonePath.setText("/assets/white0.png");
  lblWinrateLineColor.setColor(
      Theme.array2Color(Lizzie.config.uiConfig.optJSONArray("winrate-line-color"), Color.green));
  lblWinrateMissLineColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("winrate-miss-line-color"), Color.blue.darker()));
  lblBlunderBarColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("blunder-bar-color"), new Color(255, 0, 0, 150)));
  lblScoreMeanLineColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("scoremean-line-color"), Color.magenta.brighter()));
  setStoneIndicatorType(Lizzie.config.uiConfig.optInt("stone-indicator-type", 1));
  chkShowCommentNodeColor.setSelected(
      Lizzie.config.uiConfig.optBoolean("show-comment-node-color"));
  lblCommentNodeColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("comment-node-color"), Color.BLUE.brighter()));
  lblCommentBackgroundColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("comment-background-color"),
          new Color(0, 0, 0, 200)));
  lblCommentFontColor.setColor(
      Theme.array2Color(Lizzie.config.uiConfig.optJSONArray("comment-font-color"), Color.WHITE));
  txtCommentFontSize.setText(
      String.valueOf(Lizzie.config.uiConfig.optInt("comment-font-size", 3)));
  Theme defTheme = new Theme("");
  tblBlunderNodes.setModel(
      new BlunderNodeTableModel(
          defTheme.blunderWinrateThresholds().orElse(null),
          defTheme.blunderNodeColors().orElse(null),
          columsBlunderNodes));
  TableColumn colorCol = tblBlunderNodes.getColumnModel().getColumn(1);
  colorCol.setCellRenderer(new ColorRenderer(false));
  colorCol.setCellEditor(new ColorEditor(this));
}