Make scroll arrow buttons semi-transparent and more like FLabels

This commit is contained in:
drdev
2014-01-22 03:14:23 +00:00
parent 961461aa19
commit 97c74ec2b1
2 changed files with 93 additions and 152 deletions

View File

@@ -115,12 +115,12 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder selectable(final boolean b0) { this.bldSelectable = b0; return this; } public Builder selectable(final boolean b0) { this.bldSelectable = b0; return this; }
public Builder selectable() { selectable(true); return this; } public Builder selectable() { selectable(true); return this; }
/**@param b0   boolean /**@param b0   boolean
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder selected(final boolean b0) { this.bldSelected = b0; return this; } public Builder selected(final boolean b0) { this.bldSelected = b0; return this; }
public Builder selected() { selected(true); return this; } public Builder selected() { selected(true); return this; }
/**@param b0   boolean that controls when the label responds to mouse events /**@param b0   boolean that controls when the label responds to mouse events
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder reactOnMouseDown(final boolean b0) { this.bldReactOnMouseDown = b0; return this; } public Builder reactOnMouseDown(final boolean b0) { this.bldReactOnMouseDown = b0; return this; }
@@ -129,7 +129,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
/**@param b0   boolean that controls whether the text uses skin colors /**@param b0   boolean that controls whether the text uses skin colors
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder useSkinColors(final boolean b0) { bldUseSkinColors = b0; return this; } public Builder useSkinColors(final boolean b0) { bldUseSkinColors = b0; return this; }
/**@param c0   {@link forge.Command} to execute if clicked /**@param c0   {@link forge.Command} to execute if clicked
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder cmdClick(final Command c0) { this.bldCmd = c0; return this; } public Builder cmdClick(final Command c0) { this.bldCmd = c0; return this; }
@@ -173,7 +173,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
* @return {@link forge.gui.toolbox.Builder} */ * @return {@link forge.gui.toolbox.Builder} */
public Builder iconInsets(final Point i0) { this.bldIconInsets = i0; return this; } public Builder iconInsets(final Point i0) { this.bldIconInsets = i0; return this; }
} }
// sets better defaults for button labels // sets better defaults for button labels
public static class ButtonBuilder extends Builder { public static class ButtonBuilder extends Builder {
public ButtonBuilder() { public ButtonBuilder() {
@@ -181,7 +181,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
bldOpaque = true; bldOpaque = true;
} }
} }
//========== Constructors //========== Constructors
// Call this using FLabel.Builder()... // Call this using FLabel.Builder()...
protected FLabel(final Builder b0) { protected FLabel(final Builder b0) {
@@ -207,27 +207,27 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
this.setFontAlign(b0.bldFontAlign); this.setFontAlign(b0.bldFontAlign);
this.setToolTipText(b0.bldToolTip); this.setToolTipText(b0.bldToolTip);
this.setHoverable(b0.bldHoverable); this.setHoverable(b0.bldHoverable);
// Call this last; to allow the properties which affect icons to already be in place. // Call this last; to allow the properties which affect icons to already be in place.
this.setIcon(b0.bldIcon); this.setIcon(b0.bldIcon);
// If the label has button-like properties, interpret keypresses like a button // If the label has button-like properties, interpret keypresses like a button
if (b0.bldSelectable || b0.bldHoverable) { if (b0.bldSelectable || b0.bldHoverable) {
this.setFocusable(true); this.setFocusable(true);
this.addKeyListener(new KeyAdapter() { this.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyPressed(final KeyEvent e) { public void keyPressed(final KeyEvent e) {
if (e.getKeyChar() == ' ' || e.getKeyCode() == 10 || e.getKeyCode() == KeyEvent.VK_ENTER) { _doMouseAction(); } if (e.getKeyChar() == ' ' || e.getKeyCode() == 10 || e.getKeyCode() == KeyEvent.VK_ENTER) { _doMouseAction(); }
} }
}); });
this.addFocusListener(new FocusListener() { this.addFocusListener(new FocusListener() {
@Override public void focusLost(FocusEvent arg0) { repaintSelf(); } @Override public void focusLost(FocusEvent arg0) { repaintSelf(); }
@Override public void focusGained(FocusEvent arg0) { repaintSelf(); } @Override public void focusGained(FocusEvent arg0) { repaintSelf(); }
}); });
} }
if (b0.bldUseSkinColors) { if (b0.bldUseSkinColors) {
// Non-custom display properties // Non-custom display properties
this.setForeground(clrText); this.setForeground(clrText);
@@ -254,7 +254,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
private final SkinColor l10 = clrMain.stepColor(10); private final SkinColor l10 = clrMain.stepColor(10);
private final SkinColor l20 = clrMain.stepColor(20); private final SkinColor l20 = clrMain.stepColor(20);
private final SkinColor l30 = clrMain.stepColor(30); private final SkinColor l30 = clrMain.stepColor(30);
// Custom properties, assigned either at realization (using builder) // Custom properties, assigned either at realization (using builder)
// or dynamically (using methods below). // or dynamically (using methods below).
private double iconScaleFactor; private double iconScaleFactor;
@@ -307,7 +307,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
cmdClick.run(); cmdClick.run();
} }
} }
private void _doRightClickAction() { private void _doRightClickAction() {
if (cmdRightClick != null && isEnabled()) { if (cmdRightClick != null && isEnabled()) {
cmdRightClick.run(); cmdRightClick.run();
@@ -318,38 +318,34 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
private final FMouseAdapter madEvents = new FMouseAdapter() { private final FMouseAdapter madEvents = new FMouseAdapter() {
@Override @Override
public void onMouseEnter(MouseEvent e) { public void onMouseEnter(MouseEvent e) {
hovered = true; setHovered(true);
repaintSelf();
} }
@Override @Override
public void onMouseExit(MouseEvent e) { public void onMouseExit(MouseEvent e) {
hovered = false; setHovered(false);
repaintSelf();
} }
@Override @Override
public void onLeftMouseDown(MouseEvent e) { public void onLeftMouseDown(MouseEvent e) {
if (reactOnMouseDown) { if (reactOnMouseDown) {
_doMouseAction(); //for best responsiveness, do action before repainting for pressed state _doMouseAction(); //for best responsiveness, do action before repainting for pressed state
} }
pressed = true; setPressed(true);
repaintSelf();
} }
@Override @Override
public void onLeftMouseUp(MouseEvent e) { public void onLeftMouseUp(MouseEvent e) {
pressed = false; setPressed(false);
repaintSelf();
} }
@Override @Override
public void onLeftClick(MouseEvent e) { public void onLeftClick(MouseEvent e) {
if (!reactOnMouseDown) { if (!reactOnMouseDown) {
_doMouseAction(); _doMouseAction();
} }
} }
@Override @Override
public void onRightClick(MouseEvent e) { public void onRightClick(MouseEvent e) {
_doRightClickAction(); _doRightClickAction();
@@ -376,6 +372,16 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
else { this.addMouseListener(madEvents); } else { this.addMouseListener(madEvents); }
} }
protected void setHovered(boolean hovered0) {
this.hovered = hovered0;
repaintSelf();
}
protected void setPressed(boolean pressed0) {
this.pressed = pressed0;
repaintSelf();
}
/** @param b0   boolean */ /** @param b0   boolean */
// Must be public. // Must be public.
public void setSelected(final boolean b0) { public void setSelected(final boolean b0) {
@@ -386,7 +392,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
public boolean getSelected() { public boolean getSelected() {
return this.selected; return this.selected;
} }
/** Sets alpha if icon is in background. /** Sets alpha if icon is in background.
* @param f0   float */ * @param f0   float */
// NOT public; must be set when label is built. // NOT public; must be set when label is built.
@@ -540,13 +546,26 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
else if (selectable) { else if (selectable) {
if (selected) { if (selected) {
paintDown(g2d, w, h); paintDown(g2d, w, h);
} else { }
else {
paintBorder(g2d, w, h); paintBorder(g2d, w, h);
} }
} }
paintContent(g2d, w, h, paintPressedState);
if (hoverable) {
g2d.setComposite(oldComp);
}
if (hasFocus() && isEnabled()) {
paintFocus(g2d, w, h);
}
}
protected void paintContent(final Graphics2D g, int w, int h, final boolean paintPressedState) {
if (paintPressedState) { //while pressed, translate graphics so icon and text appear shifted down and to the right if (paintPressedState) { //while pressed, translate graphics so icon and text appear shifted down and to the right
g2d.translate(1, 1); g.translate(1, 1);
} }
// Icon in background // Icon in background
@@ -560,21 +579,13 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
int y = (int) (((h - sh) / 2) + iconInsets.getY()); int y = (int) (((h - sh) / 2) + iconInsets.getY());
g2d.drawImage(img, x, y, sw + x, sh + y, 0, 0, iw, ih, null); g.drawImage(img, x, y, sw + x, sh + y, 0, 0, iw, ih, null);
} }
super.paintComponent(g); super.paintComponent(g);
if (paintPressedState) { //reset translation after icon and text painted if (paintPressedState) { //reset translation after icon and text painted
g2d.translate(-1, -1); g.translate(-1, -1);
}
if (hoverable) {
g2d.setComposite(oldComp);
}
if (hasFocus() && isEnabled()) {
paintFocus(g2d, w, h);
} }
} }
@@ -584,7 +595,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint {
FSkin.setGraphicsColor(g, l30); FSkin.setGraphicsColor(g, l30);
g.drawRect(1, 1, w - 4, h - 4); g.drawRect(1, 1, w - 4, h - 4);
} }
private void paintPressed(final Graphics2D g, int w, int h) { private void paintPressed(final Graphics2D g, int w, int h) {
FSkin.setGraphicsGradientPaint(g, 0, h, d50, 0, 0, d10); FSkin.setGraphicsGradientPaint(g, 0, h, d50, 0, 0, d10);
g.fillRect(0, 0, w - 1, h - 1); g.fillRect(0, 0, w - 1, h - 1);

View File

@@ -17,10 +17,7 @@
*/ */
package forge.gui.toolbox; package forge.gui.toolbox;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Composite;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -28,17 +25,13 @@ import java.awt.LayoutManager;
import java.awt.PopupMenu; import java.awt.PopupMenu;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.ScrollPaneConstants; import javax.swing.ScrollPaneConstants;
import javax.swing.Timer; import javax.swing.Timer;
import javax.swing.border.Border; import javax.swing.border.Border;
import forge.gui.framework.ILocalRepaint;
import forge.gui.toolbox.FSkin.SkinColor; import forge.gui.toolbox.FSkin.SkinColor;
/** /**
@@ -47,10 +40,11 @@ import forge.gui.toolbox.FSkin.SkinColor;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FScrollPanel extends FScrollPane { public class FScrollPanel extends FScrollPane {
private static final SkinColor arrowColor = FSkin.getColor(FSkin.Colors.CLR_TEXT);
private final boolean useArrowButtons; private final boolean useArrowButtons;
private final ArrowButton[] arrowButtons = new ArrowButton[4]; private final ArrowButton[] arrowButtons = new ArrowButton[4];
private JPanel innerPanel; private JPanel innerPanel;
/** /**
* An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars * An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars
* This constructor assumes no layout, assumes using scrollbars to scroll, and "as needed" for horizontal and vertical scroll policies. * This constructor assumes no layout, assumes using scrollbars to scroll, and "as needed" for horizontal and vertical scroll policies.
@@ -59,7 +53,7 @@ public class FScrollPanel extends FScrollPane {
public FScrollPanel() { public FScrollPanel() {
this(null); this(null);
} }
/** /**
* An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars * An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars
* This constructor assumes using scrollbars to scroll and "as needed" for horizontal and vertical scroll policies. * This constructor assumes using scrollbars to scroll and "as needed" for horizontal and vertical scroll policies.
@@ -69,7 +63,7 @@ public class FScrollPanel extends FScrollPane {
public FScrollPanel(final LayoutManager layout) { public FScrollPanel(final LayoutManager layout) {
this(layout, false); this(layout, false);
} }
/** /**
* An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars * An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars
* This constructor assumes "as needed" for horizontal and vertical scroll policies. * This constructor assumes "as needed" for horizontal and vertical scroll policies.
@@ -94,7 +88,7 @@ public class FScrollPanel extends FScrollPane {
innerPanel = (JPanel)getViewport().getView(); innerPanel = (JPanel)getViewport().getView();
innerPanel.setOpaque(false); innerPanel.setOpaque(false);
} }
/** /**
* An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars * An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars
* *
@@ -104,7 +98,7 @@ public class FScrollPanel extends FScrollPane {
public FScrollPanel(final Component view, boolean useArrowButtons0) { public FScrollPanel(final Component view, boolean useArrowButtons0) {
this(view, useArrowButtons0, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this(view, useArrowButtons0, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
} }
/** /**
* An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars * An extension of JScrollPane that can be used as a panel and supports using arrow buttons to scroll instead of scrollbars
* *
@@ -124,7 +118,7 @@ public class FScrollPanel extends FScrollPane {
getVerticalScrollBar().setPreferredSize(new Dimension(0, 0)); getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
} }
} }
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
@@ -146,7 +140,7 @@ public class FScrollPanel extends FScrollPane {
} }
} }
} }
private void updateArrowButton(int dir, boolean[] visible) { private void updateArrowButton(int dir, boolean[] visible) {
ArrowButton arrowButton = arrowButtons[dir]; ArrowButton arrowButton = arrowButtons[dir];
if (!visible[dir]) { if (!visible[dir]) {
@@ -155,14 +149,14 @@ public class FScrollPanel extends FScrollPane {
} }
return; return;
} }
//determine bounds of button //determine bounds of button
int x, y, w, h; int x, y, w, h;
final int panelWidth = getWidth(); final int panelWidth = getWidth();
final int panelHeight = getHeight(); final int panelHeight = getHeight();
final int arrowButtonSize = 18; final int arrowButtonSize = 18;
final int cornerSize = arrowButtonSize - 1; //make borders line up final int cornerSize = arrowButtonSize - 1; //make borders line up
if (dir < 2) { //if button for horizontal scrolling if (dir < 2) { //if button for horizontal scrolling
y = 0; y = 0;
h = panelHeight; h = panelHeight;
@@ -189,7 +183,7 @@ public class FScrollPanel extends FScrollPane {
y = (dir == 2 ? 0 : panelHeight - arrowButtonSize); y = (dir == 2 ? 0 : panelHeight - arrowButtonSize);
h = arrowButtonSize; h = arrowButtonSize;
} }
if (arrowButton == null) { if (arrowButton == null) {
switch (dir) { switch (dir) {
case 0: case 0:
@@ -211,66 +205,39 @@ public class FScrollPanel extends FScrollPane {
arrowButton.setSize(w, h); arrowButton.setSize(w, h);
FAbsolutePositioner.SINGLETON_INSTANCE.show(arrowButton, this, x, y); FAbsolutePositioner.SINGLETON_INSTANCE.show(arrowButton, this, x, y);
} }
private abstract class ArrowButton extends JLabel implements ILocalRepaint { private abstract class ArrowButton extends FLabel {
private final SkinColor clrFore = FSkin.getColor(FSkin.Colors.CLR_TEXT);
private final SkinColor clrBack = FSkin.getColor(FSkin.Colors.CLR_INACTIVE);
private final SkinColor d50 = clrBack.stepColor(-50);
private final SkinColor d10 = clrBack.stepColor(-10);
private final SkinColor l10 = clrBack.stepColor(10);
private final SkinColor l20 = clrBack.stepColor(20);
private final AlphaComposite alphaDefault = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
private final AlphaComposite alphaHovered = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f);
protected final int arrowSize = 6; protected final int arrowSize = 6;
private final JScrollBar scrollBar; private final JScrollBar scrollBar;
private final int incrementDirection; private final int incrementDirection;
private boolean hovered;
protected ArrowButton(final JScrollBar scrollBar0, final int incrementDirection0) { protected ArrowButton(final JScrollBar scrollBar0, final int incrementDirection0) {
super(""); super(new FLabel.ButtonBuilder());
scrollBar = scrollBar0; scrollBar = scrollBar0;
incrementDirection = incrementDirection0; incrementDirection = incrementDirection0;
timer.setInitialDelay(500); //wait half a second after mouse down before starting timer timer.setInitialDelay(500); //wait half a second after mouse down before starting timer
addMouseListener(madEvents);
} }
@Override @Override
public void repaintSelf() { protected void setPressed(boolean pressed0) {
final Dimension d = getSize(); super.setPressed(pressed0);
repaint(0, 0, d.width, d.height); if (pressed0) {
scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement() * incrementDirection);
timer.start();
}
else {
timer.stop();
}
} }
@Override @Override
public void paintComponent(final Graphics g) { protected void paintContent(final Graphics2D g, int w, int h, final boolean paintPressedState) {
Graphics2D g2d = (Graphics2D)g; FSkin.setGraphicsColor(g, arrowColor);
int w = getWidth();
int h = getHeight();
g.setColor(Color.white); //draw white background before composite so not semi-transparent
g.fillRect(0, 0, w, h);
Composite oldComp = g2d.getComposite();
g2d.setComposite(hovered ? alphaHovered : alphaDefault);
FSkin.setGraphicsGradientPaint(g2d, 0, h, d10, 0, 0, l20);
g.fillRect(0, 0, w, h);
FSkin.setGraphicsColor(g, d50);
g.drawRect(0, 0, w - 1, h - 1);
FSkin.setGraphicsColor(g, l10);
g.drawRect(1, 1, w - 3, h - 3);
FSkin.setGraphicsColor(g, clrFore);
drawArrow(g); drawArrow(g);
super.paintComponent(g);
g2d.setComposite(oldComp);
} }
protected abstract void drawArrow(final Graphics g); protected abstract void drawArrow(final Graphics g);
//timer to continue scrollling while mouse remains down //timer to continue scrollling while mouse remains down
final Timer timer = new Timer(50, new ActionListener() { final Timer timer = new Timer(50, new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@@ -282,53 +249,19 @@ public class FScrollPanel extends FScrollPane {
scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement() * incrementDirection); scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement() * incrementDirection);
} }
}); });
private final MouseAdapter madEvents = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement() * incrementDirection);
timer.start();
}
@Override
public void mouseReleased(final MouseEvent e) {
timer.stop();
}
@Override
public void mouseEntered(MouseEvent e) {
hovered = true;
repaintSelf();
}
@Override
public void mouseExited(MouseEvent e) {
hovered = false;
repaintSelf();
}
@Override
public void mouseMoved(MouseEvent e) {
if (!hovered) {
hovered = true;
repaintSelf();
}
}
};
} }
private class LeftArrowButton extends ArrowButton { private class LeftArrowButton extends ArrowButton {
public LeftArrowButton(final JScrollBar horzScrollbar) { public LeftArrowButton(final JScrollBar horzScrollbar) {
super(horzScrollbar, -1); super(horzScrollbar, -1);
} }
@Override @Override
protected void drawArrow(final Graphics g) { protected void drawArrow(final Graphics g) {
int x = (getWidth() - arrowSize) / 2; int x = (getWidth() - arrowSize) / 2;
int y2 = getHeight() / 2; int y2 = getHeight() / 2;
int y1 = y2 - 1; int y1 = y2 - 1;
for (int i = 0; i < arrowSize; i++) for (int i = 0; i < arrowSize; i++) {
{
g.drawLine(x, y1, x, y2); g.drawLine(x, y1, x, y2);
x++; x++;
y1--; y1--;
@@ -336,19 +269,18 @@ public class FScrollPanel extends FScrollPane {
} }
} }
} }
private class RightArrowButton extends ArrowButton { private class RightArrowButton extends ArrowButton {
public RightArrowButton(final JScrollBar horzScrollbar) { public RightArrowButton(final JScrollBar horzScrollbar) {
super(horzScrollbar, 1); super(horzScrollbar, 1);
} }
@Override @Override
protected void drawArrow(final Graphics g) { protected void drawArrow(final Graphics g) {
int x = (getWidth() + arrowSize) / 2; int x = (getWidth() + arrowSize) / 2;
int y2 = getHeight() / 2; int y2 = getHeight() / 2;
int y1 = y2 - 1; int y1 = y2 - 1;
for (int i = 0; i < arrowSize; i++) for (int i = 0; i < arrowSize; i++) {
{
g.drawLine(x, y1, x, y2); g.drawLine(x, y1, x, y2);
x--; x--;
y1--; y1--;
@@ -356,19 +288,18 @@ public class FScrollPanel extends FScrollPane {
} }
} }
} }
private class TopArrowButton extends ArrowButton { private class TopArrowButton extends ArrowButton {
public TopArrowButton(final JScrollBar vertScrollbar) { public TopArrowButton(final JScrollBar vertScrollbar) {
super(vertScrollbar, -1); super(vertScrollbar, -1);
} }
@Override @Override
protected void drawArrow(final Graphics g) { protected void drawArrow(final Graphics g) {
int x2 = getWidth() / 2; int x2 = getWidth() / 2;
int x1 = x2 - 1; int x1 = x2 - 1;
int y = (getHeight() - arrowSize) / 2; int y = (getHeight() - arrowSize) / 2;
for (int i = 0; i < arrowSize; i++) for (int i = 0; i < arrowSize; i++) {
{
g.drawLine(x1, y, x2, y); g.drawLine(x1, y, x2, y);
x1--; x1--;
x2++; x2++;
@@ -376,19 +307,18 @@ public class FScrollPanel extends FScrollPane {
} }
} }
} }
private class BottomArrowButton extends ArrowButton { private class BottomArrowButton extends ArrowButton {
public BottomArrowButton(final JScrollBar vertScrollbar) { public BottomArrowButton(final JScrollBar vertScrollbar) {
super(vertScrollbar, 1); super(vertScrollbar, 1);
} }
@Override @Override
protected void drawArrow(final Graphics g) { protected void drawArrow(final Graphics g) {
int x2 = getWidth() / 2; int x2 = getWidth() / 2;
int x1 = x2 - 1; int x1 = x2 - 1;
int y = (getHeight() + arrowSize) / 2; int y = (getHeight() + arrowSize) / 2;
for (int i = 0; i < arrowSize; i++) for (int i = 0; i < arrowSize; i++) {
{
g.drawLine(x1, y, x2, y); g.drawLine(x1, y, x2, y);
x1--; x1--;
x2++; x2++;
@@ -405,7 +335,7 @@ public class FScrollPanel extends FScrollPane {
} }
return super.add(comp); return super.add(comp);
} }
@Override @Override
public void add(PopupMenu popup) { public void add(PopupMenu popup) {
if (innerPanel != null) { if (innerPanel != null) {
@@ -414,7 +344,7 @@ public class FScrollPanel extends FScrollPane {
} }
super.add(popup); super.add(popup);
} }
@Override @Override
public void add(Component comp, Object constraints) { public void add(Component comp, Object constraints) {
if (innerPanel != null) { if (innerPanel != null) {
@@ -423,7 +353,7 @@ public class FScrollPanel extends FScrollPane {
} }
super.add(comp, constraints); super.add(comp, constraints);
} }
@Override @Override
public Component add(Component comp, int index) { public Component add(Component comp, int index) {
if (innerPanel != null) { if (innerPanel != null) {
@@ -431,7 +361,7 @@ public class FScrollPanel extends FScrollPane {
} }
return super.add(comp, index); return super.add(comp, index);
} }
@Override @Override
public void add(Component comp, Object constraints, int index) { public void add(Component comp, Object constraints, int index) {
if (innerPanel != null) { if (innerPanel != null) {
@@ -440,7 +370,7 @@ public class FScrollPanel extends FScrollPane {
} }
super.add(comp, constraints, index); super.add(comp, constraints, index);
} }
@Override @Override
public Component add(String name, Component comp) { public Component add(String name, Component comp) {
if (innerPanel != null) { if (innerPanel != null) {