Remove unused FComboBox properties

This commit is contained in:
drdev
2013-10-27 05:27:51 +00:00
parent 2265687c75
commit 4485e46801
5 changed files with 5 additions and 79 deletions

View File

@@ -45,7 +45,6 @@ public class DecksComboBox extends FComboBox<DeckType> {
private DeckType selectedDeckType = null; private DeckType selectedDeckType = null;
public DecksComboBox() { public DecksComboBox() {
setButtonVisible(true);
FSkin.get(this).setFont(FSkin.getBoldFont(14)); FSkin.get(this).setFont(FSkin.getBoldFont(14));
setTextAlignment(TextAlignment.CENTER); setTextAlignment(TextAlignment.CENTER);
addActionListener(getDeckTypeComboListener()); addActionListener(getDeckTypeComboListener());

View File

@@ -43,7 +43,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
// CTR // CTR
private VSubmenuConstructed() { private VSubmenuConstructed() {
FSkin.get(lblTitle).setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); FSkin.get(lblTitle).setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
cboGamePlayers.setButtonVisible(true);
cboGamePlayers.setTextAlignment(TextAlignment.CENTER); cboGamePlayers.setTextAlignment(TextAlignment.CENTER);
FSkin.get(cboGamePlayers).setFont(FSkin.getBoldFont(16)); FSkin.get(cboGamePlayers).setFont(FSkin.getBoldFont(16));
} }

View File

@@ -1,17 +1,9 @@
package forge.gui.toolbox; package forge.gui.toolbox;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel; import javax.swing.ComboBoxModel;
import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton; import javax.swing.JButton;
@@ -24,13 +16,9 @@ import javax.swing.SwingConstants;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.ComboPopup; import javax.swing.plaf.basic.ComboPopup;
import forge.gui.MouseUtil;
import forge.gui.MouseUtil.MouseCursor;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FComboBox<E> extends JComboBox<E> { public class FComboBox<E> extends JComboBox<E> {
@@ -44,9 +32,6 @@ public class FComboBox<E> extends JComboBox<E> {
} }
private TextAlignment textAlignment = TextAlignment.LEFT; private TextAlignment textAlignment = TextAlignment.LEFT;
private boolean showComboButton = true;
private MouseAdapter mouseListener = null;
// CTR // CTR
public FComboBox() { public FComboBox() {
super(); super();
@@ -64,65 +49,12 @@ public class FComboBox<E> extends JComboBox<E> {
private void initialize() { private void initialize() {
setUI(new FComboBoxUI()); setUI(new FComboBoxUI());
setBorder(getDefaultBorder()); setBorder(getDefaultBorder());
setMouseListener();
} }
private Border getDefaultBorder() { private Border getDefaultBorder() {
return UIManager.getBorder("ComboBox.border"); return UIManager.getBorder("ComboBox.border");
} }
private Color getBorderColor() {
Border thisBorder = getDefaultBorder();
if (thisBorder != null && thisBorder instanceof LineBorder) {
return ((LineBorder)thisBorder).getLineColor();
} else {
return getForeground();
}
}
public void setButtonVisible(boolean isVisible) {
showComboButton = isVisible;
initialize();
}
private void setMouseListener() {
if (mouseListener != null) {
removeMouseListener(mouseListener);
}
if (!showComboButton) {
mouseListener = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
setMouseCursor(Cursor.HAND_CURSOR);
setBorderHighlight(true);
}
@Override
public void mouseExited(MouseEvent e) {
setMouseCursor(Cursor.DEFAULT_CURSOR);
setBorderHighlight(false);
}
};
addMouseListener(mouseListener);
}
}
private void setBorderHighlight(boolean highlight) {
if (isEnabled()) {
if (highlight) {
setBorder(BorderFactory.createLineBorder(getForeground(), 2));
} else {
setBorder(BorderFactory.createLineBorder(getBorderColor(), 1));
}
}
}
private void setMouseCursor(int cursor) {
// Testing...
//SwingUtilities.getWindowAncestor(this).setCursor(Cursor.getPredefinedCursor(cursor));
// Forge...
MouseUtil.setMouseCursor(MouseCursor.fromInt(cursor));
}
public void setTextAlignment(TextAlignment align) { public void setTextAlignment(TextAlignment align) {
textAlignment = align; textAlignment = align;
} }
@@ -136,8 +68,8 @@ public class FComboBox<E> extends JComboBox<E> {
int shapeHeight = 10; int shapeHeight = 10;
int x = getWidth() - shapeWidth - 8; int x = getWidth() - shapeWidth - 8;
int y = getHeight() / 2 - 2; int y = getHeight() / 2 - 2;
int[] xPoints = {x, x + shapeWidth, x + (shapeWidth/2)}; int[] xPoints = {x, x + shapeWidth, x + (shapeWidth / 2)};
int[] yPoints = {y, y, y + (shapeHeight/2)}; int[] yPoints = {y, y, y + (shapeHeight / 2)};
g2d.fillPolygon(xPoints, yPoints, 3); g2d.fillPolygon(xPoints, yPoints, 3);
} }
@@ -145,11 +77,7 @@ public class FComboBox<E> extends JComboBox<E> {
@Override @Override
protected LayoutManager createLayoutManager() { protected LayoutManager createLayoutManager() {
if (!showComboButton) { return super.createLayoutManager();
return new BorderLayout();
} else {
return super.createLayoutManager();
}
} }
@Override @Override

View File

@@ -23,7 +23,7 @@ import forge.properties.ForgePreferences.FPref;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FComboBoxPanel<E> extends JPanel { public class FComboBoxPanel<E> extends JPanel {
private static ArrayList<FComboBoxPanel<?>> allPanels = new ArrayList<FComboBoxPanel<?>>(); private static final ArrayList<FComboBoxPanel<?>> allPanels = new ArrayList<FComboBoxPanel<?>>();
public static void refreshAllSkins() { public static void refreshAllSkins() {
for (FComboBoxPanel<?> panel : allPanels) { for (FComboBoxPanel<?> panel : allPanels) {

View File

@@ -17,7 +17,7 @@ import javax.swing.ListCellRenderer;
*/ */
public class FComboBoxWrapper<E> { public class FComboBoxWrapper<E> {
private static ArrayList<FComboBoxWrapper<?>> allWrappers = new ArrayList<FComboBoxWrapper<?>>(); private static final ArrayList<FComboBoxWrapper<?>> allWrappers = new ArrayList<FComboBoxWrapper<?>>();
public static void refreshAllSkins() { public static void refreshAllSkins() {
for (FComboBoxWrapper<?> wrapper : allWrappers) { for (FComboBoxWrapper<?> wrapper : allWrappers) {