mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Skin ItemManagers
This commit is contained in:
@@ -84,6 +84,8 @@ import javax.swing.UnsupportedLookAndFeelException;
|
|||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.table.JTableHeader;
|
||||||
|
import javax.swing.table.TableColumnModel;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
@@ -298,6 +300,12 @@ public enum FSkin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set border for component that's temporary
|
||||||
|
//only use if can't use ISkinnedComponent class
|
||||||
|
public static void setTempBorder(JComponent comp, SkinBorder skinBorder) {
|
||||||
|
comp.setBorder(skinBorder.createBorder());
|
||||||
|
}
|
||||||
|
|
||||||
public static abstract class SkinBorder {
|
public static abstract class SkinBorder {
|
||||||
protected abstract Border createBorder();
|
protected abstract Border createBorder();
|
||||||
}
|
}
|
||||||
@@ -2008,7 +2016,7 @@ public enum FSkin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class JTableSkin<T extends JTable> extends JComponentSkin<T> {
|
public static class JTableSkin<T extends JTable> extends JComponentSkin<T> {
|
||||||
private SkinColor selectionForeground, selectionBackground;
|
private SkinColor selectionForeground, selectionBackground, gridColor;
|
||||||
|
|
||||||
protected JTableSkin() {
|
protected JTableSkin() {
|
||||||
}
|
}
|
||||||
@@ -2019,10 +2027,14 @@ public enum FSkin {
|
|||||||
protected void setSelectionBackground(T comp, SkinColor skinColor) { comp.setSelectionBackground(skinColor != null ? skinColor.color : null); this.selectionBackground = skinColor; }
|
protected void setSelectionBackground(T comp, SkinColor skinColor) { comp.setSelectionBackground(skinColor != null ? skinColor.color : null); this.selectionBackground = skinColor; }
|
||||||
protected void resetSelectionBackground() { this.selectionBackground = null; }
|
protected void resetSelectionBackground() { this.selectionBackground = null; }
|
||||||
|
|
||||||
|
protected void setGridColor(T comp, SkinColor skinColor) { comp.setGridColor(skinColor != null ? skinColor.color : null); this.gridColor = skinColor; }
|
||||||
|
protected void resetGridColor() { this.gridColor = null; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void reapply(T comp) {
|
protected void reapply(T comp) {
|
||||||
if (this.selectionForeground != null) { setSelectionForeground(comp, this.selectionForeground); }
|
if (this.selectionForeground != null) { setSelectionForeground(comp, this.selectionForeground); }
|
||||||
if (this.selectionBackground != null) { setSelectionBackground(comp, this.selectionBackground); }
|
if (this.selectionBackground != null) { setSelectionBackground(comp, this.selectionBackground); }
|
||||||
|
if (this.gridColor != null) { setGridColor(comp, this.gridColor); }
|
||||||
super.reapply(comp);
|
super.reapply(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2863,6 +2875,42 @@ public enum FSkin {
|
|||||||
public void setSelectionBackground(SkinColor skinColor) { getSkin().setSelectionBackground(this, skinColor); }
|
public void setSelectionBackground(SkinColor skinColor) { getSkin().setSelectionBackground(this, skinColor); }
|
||||||
@Override public void setSelectionBackground(Color color) { getSkin().resetSelectionBackground(); super.setSelectionBackground(color); }
|
@Override public void setSelectionBackground(Color color) { getSkin().resetSelectionBackground(); super.setSelectionBackground(color); }
|
||||||
|
|
||||||
|
public void setGridColor(SkinColor skinColor) { getSkin().setGridColor(this, skinColor); }
|
||||||
|
@Override public void setGridColor(Color color) { getSkin().resetGridColor(); super.setGridColor(color); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
getSkin().update(this);
|
||||||
|
super.paintComponent(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static class SkinnedTableHeader extends JTableHeader implements ISkinnedComponent<JTableHeader> {
|
||||||
|
private static final long serialVersionUID = -1842620489613307379L;
|
||||||
|
|
||||||
|
private JComponentSkin<JTableHeader> skin;
|
||||||
|
public JComponentSkin<JTableHeader> getSkin() {
|
||||||
|
if (skin == null) { skin = new JComponentSkin<JTableHeader>(); }
|
||||||
|
return skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkinnedTableHeader() { super(); }
|
||||||
|
public SkinnedTableHeader(TableColumnModel columnModel0) { super(columnModel0); }
|
||||||
|
|
||||||
|
public void setForeground(SkinColor skinColor) { getSkin().setForeground(this, skinColor); }
|
||||||
|
@Override public void setForeground(Color color) { getSkin().resetForeground(); super.setForeground(color); }
|
||||||
|
|
||||||
|
public void setBackground(SkinColor skinColor) { getSkin().setBackground(this, skinColor); }
|
||||||
|
@Override public void setBackground(Color color) { getSkin().resetBackground(); super.setBackground(color); }
|
||||||
|
|
||||||
|
public void setFont(SkinFont skinFont) { getSkin().setFont(this, skinFont); }
|
||||||
|
@Override public void setFont(Font font) { getSkin().resetFont(); super.setFont(font); }
|
||||||
|
|
||||||
|
public void setCursor(SkinCursor skinCursor) { getSkin().setCursor(this, skinCursor); }
|
||||||
|
@Override public void setCursor(Cursor cursor) { getSkin().resetCursor(); super.setCursor(cursor); }
|
||||||
|
|
||||||
|
public void setBorder(SkinBorder skinBorder) { getSkin().setBorder(this, skinBorder); }
|
||||||
|
@Override public void setBorder(Border border) { getSkin().resetBorder(); super.setBorder(border); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
getSkin().update(this);
|
getSkin().update(this);
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import java.util.Map.Entry;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -53,6 +52,7 @@ import forge.gui.GuiUtils;
|
|||||||
import forge.gui.toolbox.ContextMenuBuilder;
|
import forge.gui.toolbox.ContextMenuBuilder;
|
||||||
import forge.gui.toolbox.FComboBoxWrapper;
|
import forge.gui.toolbox.FComboBoxWrapper;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
|
import forge.gui.toolbox.FScrollPane;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.gui.toolbox.FSkin.SkinnedCheckBox;
|
import forge.gui.toolbox.FSkin.SkinnedCheckBox;
|
||||||
import forge.gui.toolbox.FSkin.SkinnedPanel;
|
import forge.gui.toolbox.FSkin.SkinnedPanel;
|
||||||
@@ -123,7 +123,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
|
|||||||
|
|
||||||
private final FComboBoxWrapper<ItemView<T>> cbViews = new FComboBoxWrapper<ItemView<T>>();
|
private final FComboBoxWrapper<ItemView<T>> cbViews = new FComboBoxWrapper<ItemView<T>>();
|
||||||
private final ItemListView<T> table;
|
private final ItemListView<T> table;
|
||||||
private final JScrollPane viewScroller;
|
private final FScrollPane viewScroller;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
protected boolean lockFiltering;
|
protected boolean lockFiltering;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
|
|||||||
this.model = new ItemManagerModel<T>(this, genericType0);
|
this.model = new ItemManagerModel<T>(this, genericType0);
|
||||||
this.table = new ItemListView<T>(this, this.model);
|
this.table = new ItemListView<T>(this, this.model);
|
||||||
this.table.setAllowMultipleSelections(false);
|
this.table.setAllowMultipleSelections(false);
|
||||||
this.viewScroller = new JScrollPane(this.table.getComponent());
|
this.viewScroller = new FScrollPane(this.table.getComponent());
|
||||||
this.cbViews.addItem(this.table);
|
this.cbViews.addItem(this.table);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +152,6 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
|
|||||||
|
|
||||||
//build table view
|
//build table view
|
||||||
this.table.initialize();
|
this.table.initialize();
|
||||||
this.viewScroller.setOpaque(false);
|
|
||||||
this.viewScroller.getViewport().setOpaque(false);
|
|
||||||
this.viewScroller.setBorder(null);
|
|
||||||
this.viewScroller.getViewport().setBorder(null);
|
|
||||||
this.viewScroller.getVerticalScrollBar().addAdjustmentListener(new ToolTipListener());
|
this.viewScroller.getVerticalScrollBar().addAdjustmentListener(new ToolTipListener());
|
||||||
this.viewScroller.addComponentListener(new ComponentAdapter() {
|
this.viewScroller.addComponentListener(new ComponentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,10 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
package forge.gui.toolbox.itemmanager.views;
|
package forge.gui.toolbox.itemmanager.views;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
|
||||||
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,9 +34,30 @@ import forge.item.InventoryItem;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ItemCellRenderer extends DefaultTableCellRenderer {
|
public class ItemCellRenderer extends DefaultTableCellRenderer {
|
||||||
|
private static final Border DEFAULT_BORDER = new EmptyBorder(1, 1, 1, 1);
|
||||||
|
|
||||||
public boolean alwaysShowTooltip() {
|
public boolean alwaysShowTooltip() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends InventoryItem> void processMouseEvent(final MouseEvent e, final ItemListView<T> listView, final Object value, final int row, final int column) {
|
public <T extends InventoryItem> void processMouseEvent(final MouseEvent e, final ItemListView<T> listView, final Object value, final int row, final int column) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
|
JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
lbl.setBorder(DEFAULT_BORDER); //prevent selected cell having inner border
|
||||||
|
if (isSelected) {
|
||||||
|
lbl.setBackground(table.getSelectionBackground());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (row % 2 == 0) {
|
||||||
|
lbl.setBackground(table.getBackground());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FSkin.setTempBackground(lbl, ItemListView.ALT_ROW_COLOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lbl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.gui.toolbox.itemmanager.views;
|
package forge.gui.toolbox.itemmanager.views;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -38,11 +37,13 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.TableModelEvent;
|
import javax.swing.event.TableModelEvent;
|
||||||
@@ -56,7 +57,11 @@ import javax.swing.table.TableColumnModel;
|
|||||||
|
|
||||||
import forge.gui.toolbox.FMouseAdapter;
|
import forge.gui.toolbox.FMouseAdapter;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.gui.toolbox.FSkin.SkinBorder;
|
||||||
|
import forge.gui.toolbox.FSkin.SkinColor;
|
||||||
|
import forge.gui.toolbox.FSkin.SkinFont;
|
||||||
import forge.gui.toolbox.FSkin.SkinnedTable;
|
import forge.gui.toolbox.FSkin.SkinnedTable;
|
||||||
|
import forge.gui.toolbox.FSkin.SkinnedTableHeader;
|
||||||
import forge.gui.toolbox.itemmanager.ItemManager;
|
import forge.gui.toolbox.itemmanager.ItemManager;
|
||||||
import forge.gui.toolbox.itemmanager.ItemManagerModel;
|
import forge.gui.toolbox.itemmanager.ItemManagerModel;
|
||||||
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
||||||
@@ -74,6 +79,15 @@ import forge.util.ItemPoolSorter;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
||||||
|
static final SkinColor BACK_COLOR = FSkin.getColor(FSkin.Colors.CLR_THEME2);
|
||||||
|
private static final SkinColor FORE_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT);
|
||||||
|
private static final SkinColor SEL_ACTIVE_COLOR = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
|
||||||
|
private static final SkinColor SEL_INACTIVE_COLOR = FSkin.getColor(FSkin.Colors.CLR_INACTIVE);
|
||||||
|
private static final SkinColor HEADER_BACK_COLOR = BACK_COLOR.getContrastColor(-20);
|
||||||
|
static final SkinColor ALT_ROW_COLOR = BACK_COLOR.getContrastColor(-10);
|
||||||
|
private static final SkinColor GRID_COLOR = BACK_COLOR.getContrastColor(20);
|
||||||
|
private static final SkinBorder HEADER_BORDER = new FSkin.CompoundSkinBorder(new FSkin.MatteSkinBorder(0, 0, 1, 1, GRID_COLOR), new EmptyBorder(0, 1, 0, 0));
|
||||||
|
private static final SkinFont ROW_FONT = FSkin.getFont(12);
|
||||||
private static final int ROW_HEIGHT = 20;
|
private static final int ROW_HEIGHT = 20;
|
||||||
|
|
||||||
private final ItemTable table = new ItemTable();
|
private final ItemTable table = new ItemTable();
|
||||||
@@ -94,25 +108,6 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
this.tableModel = new ItemTableModel(model0);
|
this.tableModel = new ItemTableModel(model0);
|
||||||
|
|
||||||
// use different selection highlight colors for focused vs. unfocused tables
|
// use different selection highlight colors for focused vs. unfocused tables
|
||||||
this.table.setSelectionBackground(FSkin.getColor(FSkin.Colors.CLR_INACTIVE));
|
|
||||||
this.table.setSelectionForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
|
||||||
this.table.addFocusListener(new FocusListener() {
|
|
||||||
@Override
|
|
||||||
public void focusLost(FocusEvent e) {
|
|
||||||
if (!e.isTemporary()) {
|
|
||||||
table.setSelectionBackground(FSkin.getColor(FSkin.Colors.CLR_INACTIVE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void focusGained(FocusEvent e) {
|
|
||||||
table.setSelectionBackground(FSkin.getColor(FSkin.Colors.CLR_ACTIVE));
|
|
||||||
// if nothing selected when we gain focus, select the first row (if exists)
|
|
||||||
if (-1 == getSelectedIndex() && getCount() > 0) {
|
|
||||||
table.setRowSelectionInterval(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.table.addMouseListener(new FMouseAdapter() {
|
this.table.addMouseListener(new FMouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onLeftDoubleClick(MouseEvent e) {
|
public void onLeftDoubleClick(MouseEvent e) {
|
||||||
@@ -126,11 +121,6 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.table.setFont(FSkin.getFont(12));
|
|
||||||
this.table.setBorder((Border)null);
|
|
||||||
this.table.setRowHeight(ROW_HEIGHT);
|
|
||||||
this.table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
|
||||||
|
|
||||||
// prevent tables from intercepting tab focus traversals
|
// prevent tables from intercepting tab focus traversals
|
||||||
this.table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
|
this.table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
|
||||||
this.table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
|
this.table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
|
||||||
@@ -284,9 +274,39 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class ItemTable extends SkinnedTable {
|
public final class ItemTable extends SkinnedTable {
|
||||||
|
private ItemTable() {
|
||||||
|
this.setBackground(BACK_COLOR);
|
||||||
|
this.setForeground(FORE_COLOR);
|
||||||
|
this.setSelectionForeground(FORE_COLOR);
|
||||||
|
this.setSelectionBackground(SEL_INACTIVE_COLOR);
|
||||||
|
this.setGridColor(GRID_COLOR);
|
||||||
|
this.setFont(ROW_FONT);
|
||||||
|
|
||||||
|
this.addFocusListener(new FocusListener() {
|
||||||
|
@Override
|
||||||
|
public void focusGained(FocusEvent e) {
|
||||||
|
setSelectionBackground(SEL_ACTIVE_COLOR);
|
||||||
|
// if nothing selected when we gain focus, select the first row (if exists)
|
||||||
|
if (getSelectedIndex() == -1 && getCount() > 0) {
|
||||||
|
setRowSelectionInterval(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
if (!e.isTemporary()) {
|
||||||
|
setSelectionBackground(SEL_INACTIVE_COLOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setBorder((Border)null);
|
||||||
|
this.setRowHeight(ROW_HEIGHT);
|
||||||
|
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected JTableHeader createDefaultTableHeader() {
|
protected JTableHeader createDefaultTableHeader() {
|
||||||
JTableHeader header = new JTableHeader(columnModel) {
|
SkinnedTableHeader header = new SkinnedTableHeader(columnModel) {
|
||||||
@Override
|
@Override
|
||||||
public String getToolTipText(MouseEvent e) {
|
public String getToolTipText(MouseEvent e) {
|
||||||
int col = columnModel.getColumnIndexAtX(e.getPoint().x);
|
int col = columnModel.getColumnIndexAtX(e.getPoint().x);
|
||||||
@@ -298,9 +318,21 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
return tableColumn.getLongName();
|
return tableColumn.getLongName();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
header.setBorder(null);
|
header.setBorder((Border)null);
|
||||||
header.setBackground(new Color(200, 200, 200));
|
header.setBackground(HEADER_BACK_COLOR);
|
||||||
((DefaultTableCellRenderer)header.getDefaultRenderer()).setHorizontalAlignment(SwingConstants.LEFT);
|
header.setForeground(FORE_COLOR);
|
||||||
|
|
||||||
|
final DefaultTableCellRenderer renderer = ((DefaultTableCellRenderer)header.getDefaultRenderer());
|
||||||
|
header.setDefaultRenderer(new DefaultTableCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table,
|
||||||
|
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
|
JLabel lbl = (JLabel) renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
lbl.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
FSkin.setTempBorder(lbl, HEADER_BORDER);
|
||||||
|
return lbl;
|
||||||
|
}
|
||||||
|
});
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user