1 package be
.nikiroo
.fanfix_swing
.gui
.utils
;
4 import java
.awt
.Container
;
6 import java
.awt
.Window
;
7 import java
.awt
.event
.ActionListener
;
9 import javax
.swing
.JButton
;
10 import javax
.swing
.JComponent
;
11 import javax
.swing
.JDialog
;
12 import javax
.swing
.JScrollPane
;
13 import javax
.swing
.SwingWorker
;
15 import be
.nikiroo
.utils
.Progress
;
17 public class UiHelper
{
18 static private Color buttonNormal
;
19 static private Color buttonPressed
;
21 static public void setButtonPressed(JButton button
, boolean pressed
) {
22 if (buttonNormal
== null) {
23 JButton defButton
= new JButton(" ");
24 buttonNormal
= defButton
.getBackground();
25 if (buttonNormal
.getBlue() >= 128) {
26 buttonPressed
= new Color( //
27 Math
.max(buttonNormal
.getRed() - 100, 0), //
28 Math
.max(buttonNormal
.getGreen() - 100, 0), //
29 Math
.max(buttonNormal
.getBlue() - 100, 0));
31 buttonPressed
= new Color( //
32 Math
.min(buttonNormal
.getRed() + 100, 255), //
33 Math
.min(buttonNormal
.getGreen() + 100, 255), //
34 Math
.min(buttonNormal
.getBlue() + 100, 255));
38 button
.setSelected(pressed
);
39 button
.setBackground(pressed ? buttonPressed
: buttonNormal
);
42 static public JComponent
scroll(JComponent pane
) {
43 JScrollPane scroll
= new JScrollPane(pane
);
44 scroll
.getVerticalScrollBar().setUnitIncrement(16);
45 scroll
.setHorizontalScrollBarPolicy(JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);