Java Code Examples for java.awt.Component#move()

The following examples show how to use java.awt.Component#move() . 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: ProfilerTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
Component getRenderer(TableCellRenderer renderer, int row, int column, boolean sized) {
        isCustomRendering = true;
        try {
            Component comp = prepareRenderer(renderer, row, column);
//            comp.setSize(comp.getPreferredSize().width, getRowHeight());
            if (sized) {
                comp.setSize(comp.getPreferredSize().width, getRowHeight());
                if (!isLeadingAlign(comp)) {
                    TableColumnModel m = getColumnModel();
                    int x = -comp.getWidth();
                    int c = m.getColumn(column).getWidth();
                    int _column = convertColumnIndexToModel(column);
                    if (isScrollableColumn(_column)) {
                        x += Math.max(c, getColumnPreferredWidth(_column));
                    } else {
                        x += c;
                    }
                    comp.move(x - m.getColumnMargin(), 0);
                }
            }
            
            return comp;
        } finally {
            isCustomRendering = false;
        }
    }
 
Example 2
Source File: ProfilerTable.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
Component getRenderer(TableCellRenderer renderer, int row, int column, boolean sized) {
        isCustomRendering = true;
        try {
            Component comp = prepareRenderer(renderer, row, column);
//            comp.setSize(comp.getPreferredSize().width, getRowHeight());
            if (sized) {
                comp.setSize(comp.getPreferredSize().width, getRowHeight());
                if (!isLeadingAlign(comp)) {
                    TableColumnModel m = getColumnModel();
                    int x = -comp.getWidth();
                    int c = m.getColumn(column).getWidth();
                    int _column = convertColumnIndexToModel(column);
                    if (isScrollableColumn(_column)) {
                        x += Math.max(c, getColumnPreferredWidth(_column));
                    } else {
                        x += c;
                    }
                    comp.move(x - m.getColumnMargin(), 0);
                }
            }
            
            return comp;
        } finally {
            isCustomRendering = false;
        }
    }
 
Example 3
Source File: ProfilerTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    
    boolean cEnabled = c.isEnabled();
    if (!cEnabled) c.setForeground(UIManager.getColor("TextField.inactiveForeground")); // NOI18N
    
    boolean isSelected = isCellSelected(row, column);
    
    if (isSelected && isEnabled()) {
        boolean focusOwner = !shadeUnfocusedSelection || super.isFocusOwner();
        if (cEnabled) c.setForeground(focusOwner ? getSelectionForeground() : UIUtils.getUnfocusedSelectionForeground());
        c.setBackground(focusOwner ? getSelectionBackground() : UIUtils.getUnfocusedSelectionBackground());
    } else if (!isEnabled()) {
        if (cEnabled) c.setForeground(UIManager.getColor("TextField.inactiveForeground")); // NOI18N
        c.setBackground(UIManager.getColor("TextField.inactiveBackground")); // NOI18N
    } else {
        if (cEnabled) c.setForeground(getForeground());
        c.setBackground(background(row, column));
    }
    
    c.move(0, 0);
    
    int col = convertColumnIndexToModel(column);        
    if (!isCustomRendering() && isScrollableColumn(col)) {
        int prefWidth = getColumnPreferredWidth(col);
        return getScrollableRenderer(c, col, prefWidth);
    } else {
        return c;
    }
}
 
Example 4
Source File: ProfilerTable.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    
    boolean cEnabled = c.isEnabled();
    if (!cEnabled) c.setForeground(UIManager.getColor("TextField.inactiveForeground")); // NOI18N
    
    boolean isSelected = isCellSelected(row, column);
    
    if (isSelected && isEnabled()) {
        boolean focusOwner = !shadeUnfocusedSelection || super.isFocusOwner();
        if (cEnabled) c.setForeground(focusOwner ? getSelectionForeground() : UIUtils.getUnfocusedSelectionForeground());
        c.setBackground(focusOwner ? getSelectionBackground() : UIUtils.getUnfocusedSelectionBackground());
    } else if (!isEnabled()) {
        if (cEnabled) c.setForeground(UIManager.getColor("TextField.inactiveForeground")); // NOI18N
        c.setBackground(UIManager.getColor("TextField.inactiveBackground")); // NOI18N
    } else {
        if (cEnabled) c.setForeground(getForeground());
        c.setBackground(background(row, column));
    }
    
    c.move(0, 0);
    
    int col = convertColumnIndexToModel(column);        
    if (!isCustomRendering() && isScrollableColumn(col)) {
        int prefWidth = getColumnPreferredWidth(col);
        return getScrollableRenderer(c, col, prefWidth);
    } else {
        return c;
    }
}