javax.swing.plaf.TableUI Java Examples

The following examples show how to use javax.swing.plaf.TableUI. 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: TabTableUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static boolean isHover( JTable table, int row, int column ) {
    TableUI ui = table.getUI();
    if( !(ui instanceof TabTableUI) )
        return false;

    TabTableUI tabUI = (TabTableUI) ui;
    return tabUI.hoverRow == row && tabUI.hoverColumn == column;
}
 
Example #2
Source File: JTableOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTable.getUI()} through queue
 */
public TableUI getUI() {
    return (runMapping(new MapAction<TableUI>("getUI") {
        @Override
        public TableUI map() {
            return ((JTable) getSource()).getUI();
        }
    }));
}
 
Example #3
Source File: JTableOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTable.setUI(TableUI)} through queue
 */
public void setUI(final TableUI tableUI) {
    runMapping(new MapVoidAction("setUI") {
        @Override
        public void map() {
            ((JTable) getSource()).setUI(tableUI);
        }
    });
}
 
Example #4
Source File: SubstanceDefaultTableCellRenderer.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
        this.setForeground(table.getSelectionForeground());
    } else {
        this.setForeground(table.getForeground());
    }
    SubstanceStripingUtils.applyStripedBackground(table, row, this);

    this.setSelected(((value != null) && ((Boolean) value).booleanValue()));
    this.setEnabled(table.isEnabled());

    TableUI tableUI = table.getUI();
    if (tableUI instanceof SubstanceTableUI) {
        SubstanceTableUI ui = (SubstanceTableUI) tableUI;

        // Recompute the focus indication to prevent flicker - JTable
        // registers a listener on selection changes and repaints the
        // relevant cell before our listener (in TableUI) gets the
        // chance to start the fade sequence. The result is that the
        // first frame uses full opacity, and the next frame starts the
        // fade sequence. So, we use the UI delegate to compute the
        // focus indication.
        hasFocus = ui.isFocusedCell(row, column);

        TableCellId cellFocusId = new TableCellId(row, column);

        StateTransitionTracker stateTransitionTracker = ui
                .getStateTransitionTracker(cellFocusId);
        if (hasFocus || (stateTransitionTracker != null)) {
            SubstanceTableCellBorder border = new SubstanceTableCellBorder(
                    new Insets(0, 0, 0, 0), ui, cellFocusId);
            if (stateTransitionTracker != null) {
                border.setAlpha(stateTransitionTracker.getFocusStrength(hasFocus));
            }
            this.setBorder(border);
        } else {
            this.setBorder(BooleanRenderer.noFocusBorder);
        }
    } else {
        if (hasFocus) {
            this.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
        } else {
            this.setBorder(BooleanRenderer.noFocusBorder);
        }
    }

    this.setOpaque(false);

    return this;
}
 
Example #5
Source File: SheetTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setUI(TableUI ui) {
    super.setUI(ui);
    renderer = null;
    sheetCellEditor = null;
}
 
Example #6
Source File: BaseTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setUI(TableUI ui) {
    needCalcRowHeight = true;
    inSetUI = true;
    super.setUI(ui);
    inSetUI = false;
}
 
Example #7
Source File: TabTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setUI( TableUI ui ) {
    super.setUI( new TabTableUI() );
}
 
Example #8
Source File: TaskListTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setUI( TableUI ui ) {
    super.setUI( new TaskListTableUI() );
    setTableHeader( createDefaultTableHeader() );
}
 
Example #9
Source File: PropertyEditorTable.java    From workcraft with MIT License 4 votes vote down vote up
@Override
public void setUI(TableUI ui) {
    // Forbid changing UI
}
 
Example #10
Source File: PropertyTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setUI(TableUI ui) {
  super.setUI(ui);

  // Customize action and input maps
  ActionMap actionMap = getActionMap();

  setFocusTraversalKeys(
    KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
    KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
  setFocusTraversalKeys(
    KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
    KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));

  InputMap focusedInputMap = getInputMap(JComponent.WHEN_FOCUSED);
  InputMap ancestorInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

  actionMap.put("selectPreviousRow", new MySelectNextPreviousRowAction(false));
  actionMap.put("selectNextRow", new MySelectNextPreviousRowAction(true));

  actionMap.put("startEditing", new MyStartEditingAction());
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "startEditing");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));

  actionMap.put("smartEnter", new MyEnterAction());
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "smartEnter");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));

  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
  ancestorInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");

  actionMap.put("restoreDefault", new MyRestoreDefaultAction());
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "restoreDefault");
  ancestorInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "restoreDefault");
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "restoreDefault");
  ancestorInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "restoreDefault");

  actionMap.put("expandCurrent", new MyExpandCurrentAction(true, false));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), "expandCurrent");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0));

  actionMap.put("expandCurrentRight", new MyExpandCurrentAction(true, true));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "expandCurrentRight");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0), "expandCurrentRight");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0));

  actionMap.put("collapseCurrent", new MyExpandCurrentAction(false, false));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0), "collapseCurrent");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0));

  actionMap.put("collapseCurrentLeft", new MyExpandCurrentAction(false, true));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "collapseCurrentLeft");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0));
  focusedInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0), "collapseCurrentLeft");
  ancestorInputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0));
}