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

The following examples show how to use javax.swing.JTable#getDropLocation() . 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: MapRuleRender.java    From finalspeed-91yun with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	Color fg = null;
	Color bg = null;
	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null
			&& !dropLocation.isInsertRow()
			&& !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row
			&& dropLocation.getColumn() == column) {

		fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
		bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");
		isSelected = true;
	}
	if (isSelected) {
		setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
	} else {
		setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
	}
	MapRule rule=(MapRule)value;
	update(rule,table,row);
	return this;
}
 
Example 2
Source File: SwingRenderer.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void updateComponentSelectedState(JComponent c, boolean isSelected, JTable table, int row, int column, boolean hasFocus) {
    Color fg = null;
    Color bg = null;

    JTable.DropLocation dropLocation = table.getDropLocation();
    if (dropLocation != null
            && !dropLocation.isInsertRow()
            && !dropLocation.isInsertColumn()
            && dropLocation.getRow() == row
            && dropLocation.getColumn() == column) {

        isSelected = true;
    }

    if (isSelected) {
        c.setForeground(fg == null ? table.getSelectionForeground() : fg);
        c.setBackground(bg == null ? table.getSelectionBackground() : bg);
    } else {
        Color background = unselectedBackground != null
                                ? unselectedBackground
                                : table.getBackground();
        c.setForeground(unselectedForeground != null
                                ? unselectedForeground
                                : table.getForeground());
        c.setBackground(background);
    }

    c.setFont(table.getFont());
}
 
Example 3
Source File: MapRuleRender.java    From xtunnel with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {

	Color fg = null;
	Color bg = null;

	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null
			&& !dropLocation.isInsertRow()
			&& !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row
			&& dropLocation.getColumn() == column) {

		fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
		bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");

		isSelected = true;
	}

	if (isSelected) {
		setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
	} else {
		setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
	}

	MapRule rule=(MapRule)value;
	update(rule,table,row);
	return this;
}
 
Example 4
Source File: EncryptBackActionCellRenderer.java    From pgptool with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {

	if (table == null) {
		return this;
	}

	lbl.setFont(table.getFont().deriveFont(Font.BOLD));

	Color fg = null;
	Color bg = null;

	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null && !dropLocation.isInsertRow() && !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row && dropLocation.getColumn() == column) {
		fg = UIManager.getColor("Table.dropCellForeground");
		bg = UIManager.getColor("Table.dropCellBackground");
		isSelected = true;
	}

	if (isSelected) {
		super.setForeground(fg == null ? table.getSelectionForeground() : fg);
		super.setBackground(bg == null ? table.getSelectionBackground() : bg);
	} else {
		Color background = unselectedBackground != null ? unselectedBackground : table.getBackground();
		if (background == null || background instanceof javax.swing.plaf.UIResource) {
			Color alternateColor = UIManager.getColor("Table.alternateRowColor");
			if (alternateColor != null && row % 2 != 0) {
				background = alternateColor;
			}
		}
		super.setForeground(unselectedForeground != null ? unselectedForeground : table.getForeground());
		super.setBackground(background);
	}

	setFont(table.getFont());

	if (hasFocus) {
		Border border = null;
		if (isSelected) {
			border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
		}
		if (border == null) {
			border = UIManager.getBorder("Table.focusCellHighlightBorder");
		}
		setBorder(border);

		if (!isSelected && table.isCellEditable(row, column)) {
			Color col;
			col = UIManager.getColor("Table.focusCellForeground");
			if (col != null) {
				super.setForeground(col);
			}
			col = UIManager.getColor("Table.focusCellBackground");
			if (col != null) {
				super.setBackground(col);
			}
		}
	} else {
		setBorder(getNoFocusBorder());
	}

	return this;
}