Skip to content

Commit 1224297

Browse files
authored
Merge pull request #48 from kovzol/Traumlos
Traumlos' changes to fix the Javadoc
2 parents 1ad9a84 + 604e9ca commit 1224297

195 files changed

Lines changed: 26594 additions & 20375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/UI/BLeveledButtonUI.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,51 @@
77
import java.awt.*;
88

99
/**
10-
* Created by IntelliJ IDEA.
11-
* User: yezheng
12-
* Date: 2006-7-22
13-
* Time: 15:25:17
14-
* To change this template use File | Settings | File Templates.
10+
* BLeveledButtonUI.java
11+
* This class extends BasicButtonUI to create a custom button UI with leveled borders.
12+
* It changes the button's border based on its rollover state.
1513
*/
16-
1714
public class BLeveledButtonUI extends BasicButtonUI {
1815

1916
private static Border border1 = BorderFactory.createRaisedBevelBorder();
2017
private static Border border2 = BorderFactory.createEtchedBorder();//createEtchedBorder(Color.white,Color.gray.brighter());//.createMatteBorder(2,2,2,2,Color.LIGHT_GRAY);//.createEmptyBorder(2, 2, 2, 2);
2118

19+
/**
20+
* Constructs a BLeveledButtonUI.
21+
* Calls the superclass constructor.
22+
*/
2223
public BLeveledButtonUI() {
2324
super();
2425
}
2526

27+
/**
28+
* Installs the UI for a specified component.
29+
* Sets the rollover enabled and applies the default border.
30+
*
31+
* @param c the component where this UI will be installed
32+
*/
2633
public void installUI(JComponent c) {
2734
super.installUI(c);
2835
AbstractButton button = (AbstractButton) c;
2936
button.setRolloverEnabled(true);
3037
button.setBorder(border2);
3138
}
3239

40+
/**
41+
* Paints the specified component.
42+
* Changes the border based on the rollover state of the button.
43+
*
44+
* @param g the Graphics context in which to paint
45+
* @param c the component being painted
46+
*/
3347
public void paint(Graphics g, JComponent c) {
3448
AbstractButton button = (AbstractButton) c;
3549
boolean b1 = button.getModel().isRollover();
36-
boolean b2 = button.getModel().isArmed();
37-
boolean b3 = button.getModel().isSelected();
3850
if (b1) {
39-
//border1.paintBorder(button,g,button.getX(),button.getY(),button.getWidth(),button.getHeight());
4051
button.setBorder(border1);
41-
}else button.setBorder(border2);
52+
} else {
53+
button.setBorder(border2);
54+
}
4255

4356
super.paint(g, c);
4457
}

src/main/java/UI/BLeveledButtonUIX.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,51 @@
66
import java.awt.*;
77

88
/**
9-
* Created by IntelliJ IDEA.
10-
* User: ye
11-
* Date: 2007-12-10
12-
* Time: 17:11:21
13-
* To change this template use File | Settings | File Templates.
9+
* BLeveledButtonUIX is a custom button UI that extends BlueishButtonUI.
10+
* It provides a leveled button appearance with different borders for different states.
1411
*/
1512
public class BLeveledButtonUIX extends BlueishButtonUI {
1613
private static Border border1 = BorderFactory.createRaisedBevelBorder();
1714
private static Border border2 = BorderFactory.createEtchedBorder();//createEtchedBorder(Color.white,Color.gray.brighter());//.createMatteBorder(2,2,2,2,Color.LIGHT_GRAY);//.createEmptyBorder(2, 2, 2, 2);
1815

16+
/**
17+
* Constructs a BLeveledButtonUIX.
18+
* Calls the superclass constructor.
19+
*/
1920
public BLeveledButtonUIX() {
2021
super();
2122
}
2223

24+
/**
25+
* Installs the UI for a specified component.
26+
* Sets the rollover enabled and applies the default border.
27+
*
28+
* @param c the component where this UI will be installed
29+
*/
2330
public void installUI(JComponent c) {
2431
super.installUI(c);
2532
AbstractButton button = (AbstractButton) c;
2633
button.setRolloverEnabled(true);
2734
button.setBorder(border2);
2835
}
2936

37+
/**
38+
* Paints the specified component.
39+
* Changes the border based on the rollover, armed, and selected states of the button.
40+
*
41+
* @param g the Graphics context in which to paint
42+
* @param c the component being painted
43+
*/
3044
public void paint(Graphics g, JComponent c) {
3145
AbstractButton button = (AbstractButton) c;
3246
boolean b1 = button.getModel().isRollover();
3347
boolean b2 = button.getModel().isArmed();
3448
boolean b3 = button.getModel().isSelected();
35-
// if (b2) {
36-
// } else
3749
if (b2 || b3) {
3850
button.setBorder(border1);
39-
} else button.setBorder(border2);
51+
} else {
52+
button.setBorder(border2);
53+
}
4054

4155
super.paint(g, c);
4256
}

src/main/java/UI/BlueishButtonUI.java

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,70 @@
66
import java.awt.*;
77

88
/**
9-
* Created by IntelliJ IDEA.
10-
* User: Ye
11-
* Date: 2006-4-11
12-
* Time: 16:28:51
13-
* To change this template use File | Settings | File Templates.
9+
* BlueishButtonUI.java
10+
* This class extends BasicButtonUI to create a custom button UI with a blueish theme.
11+
* It provides a unique look and feel for buttons in a Swing application.
1412
*/
15-
public class BlueishButtonUI extends BasicButtonUI
16-
{
13+
public class BlueishButtonUI extends BasicButtonUI {
1714

18-
private static Color blueishBackgroundOver = new Color(214, 214, 214);
19-
private static Color blueishBorderOver = new Color(152, 180, 226);
15+
private static Color blueishBackgroundOver = new Color(214, 214, 214);
16+
private static Color blueishBorderOver = new Color(152, 180, 226);
2017

21-
private static Color blueishBackgroundSelected = new Color(192, 192, 192);
22-
private static Color blueishBorderSelected = new Color(49, 106, 197);
18+
private static Color blueishBackgroundSelected = new Color(192, 192, 192);
19+
private static Color blueishBorderSelected = new Color(49, 106, 197);
2320

24-
public BlueishButtonUI()
25-
{
26-
super();
27-
}
21+
/**
22+
* Constructs a BlueishButtonUI.
23+
* Calls the superclass constructor.
24+
*/
25+
public BlueishButtonUI() {
26+
super();
27+
}
2828

29-
public void installUI(JComponent c)
30-
{
29+
/**
30+
* Installs the UI for a specified component.
31+
* Sets the rollover enabled, makes the button non-opaque, and adjusts text position.
32+
*
33+
* @param c the component where this UI will be installed
34+
*/
35+
public void installUI(JComponent c) {
36+
super.installUI(c);
37+
AbstractButton b = (AbstractButton) c;
38+
b.setRolloverEnabled(true);
39+
b.setOpaque(false);
40+
b.setHorizontalTextPosition(JButton.CENTER);
41+
b.setVerticalTextPosition(JButton.BOTTOM);
42+
}
3143

32-
super.installUI(c);
33-
AbstractButton b = (AbstractButton) c;
34-
b.setRolloverEnabled(true);
35-
b.setOpaque(false);
36-
b.setHorizontalTextPosition(JButton.CENTER);
37-
b.setVerticalTextPosition(JButton.BOTTOM);
38-
39-
}
40-
41-
public void paint(Graphics g, JComponent c)
42-
{
43-
AbstractButton button = (AbstractButton) c;
44-
if (button.getModel().isRollover() || button.getModel().isArmed()
45-
|| button.getModel().isSelected())
46-
{
47-
48-
Color oldColor = g.getColor();
49-
if (button.getModel().isSelected())
50-
{
51-
g.setColor(blueishBackgroundSelected);
52-
} else
53-
{
54-
g.setColor(blueishBackgroundOver);
55-
}
56-
g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
57-
58-
if (button.getModel().isSelected())
59-
{
60-
g.setColor(blueishBorderSelected);
61-
} else
62-
{
63-
g.setColor(blueishBorderOver);
64-
}
65-
g.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
44+
/**
45+
* Paints the specified component.
46+
* Changes the background and border colors based on the button's state.
47+
*
48+
* @param g the Graphics context in which to paint
49+
* @param c the component being painted
50+
*/
51+
public void paint(Graphics g, JComponent c) {
52+
AbstractButton button = (AbstractButton) c;
53+
if (button.getModel().isRollover() || button.getModel().isArmed() || button.getModel().isSelected()) {
54+
Color oldColor = g.getColor();
55+
if (button.getModel().isSelected()) {
56+
g.setColor(blueishBackgroundSelected);
57+
} else {
58+
g.setColor(blueishBackgroundOver);
59+
}
60+
g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
6661

67-
g.setColor(oldColor);
62+
if (button.getModel().isSelected()) {
63+
g.setColor(blueishBorderSelected);
64+
} else {
65+
g.setColor(blueishBorderOver);
6866
}
67+
g.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
68+
69+
g.setColor(oldColor);
70+
}
6971

70-
super.paint(g, c);
71-
}
72+
super.paint(g, c);
73+
}
7274

7375
}

src/main/java/UI/ButtonBorder.java

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
public class ButtonBorder extends AbstractBorder
3232
{
3333

34+
/**
35+
* Paints the border of the specified component.
36+
* Determines the state of the button (pressed, rollover, enabled) and calls the appropriate paint method.
37+
*
38+
* @param c the component for which this border is being painted
39+
* @param g the Graphics context in which to paint
40+
* @param x the x position of the painted border
41+
* @param y the y position of the painted border
42+
* @param width the width of the painted border
43+
* @param height the height of the painted border
44+
*/
3445
public void paintBorder(Component c, Graphics g, int x, int y, int width,
3546
int height)
3647
{
@@ -66,34 +77,86 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width,
6677
}
6778
}
6879

80+
/**
81+
* Paints the border for a normal (default) button state.
82+
*
83+
* @param b the button being painted
84+
* @param g the Graphics context in which to paint
85+
* @param x the x position of the painted border
86+
* @param y the y position of the painted border
87+
* @param width the width of the painted border
88+
* @param height the height of the painted border
89+
*/
6990
protected void paintNormal(AbstractButton b, Graphics g, int x, int y,
7091
int width, int height)
7192
{
7293
}
7394

95+
/**
96+
* Paints the border for a disabled button state.
97+
*
98+
* @param b the button being painted
99+
* @param g the Graphics context in which to paint
100+
* @param x the x position of the painted border
101+
* @param y the y position of the painted border
102+
* @param width the width of the painted border
103+
* @param height the height of the painted border
104+
*/
74105
protected void paintDisabled(AbstractButton b, Graphics g, int x, int y,
75106
int width, int height)
76107
{
77108
}
78109

110+
/**
111+
* Paints the border for a rollover button state.
112+
*
113+
* @param b the button being painted
114+
* @param g the Graphics context in which to paint
115+
* @param x the x position of the painted border
116+
* @param y the y position of the painted border
117+
* @param width the width of the painted border
118+
* @param height the height of the painted border
119+
*/
79120
protected void paintRollover(AbstractButton b, Graphics g, int x, int y,
80121
int width, int height)
81122
{
82123
}
83124

125+
/**
126+
* Paints the border for a pressed button state.
127+
*
128+
* @param b the button being painted
129+
* @param g the Graphics context in which to paint
130+
* @param x the x position of the painted border
131+
* @param y the y position of the painted border
132+
* @param width the width of the painted border
133+
* @param height the height of the painted border
134+
*/
84135
protected void paintPressed(AbstractButton b, Graphics g, int x, int y,
85136
int width, int height)
86137
{
87138
}
88139

140+
/**
141+
* Returns the insets of the border.
142+
*
143+
* @param c the component for which this border insets value applies
144+
* @return the insets of the border
145+
*/
89146
public Insets getBorderInsets(Component c)
90147
{
91148
return getBorderInsets(c, new Insets(0, 0, 0, 0));
92149
}
93150

151+
/**
152+
* Reinitializes the insets parameter with this border's current insets.
153+
*
154+
* @param c the component for which this border insets value applies
155+
* @param insets the object to be reinitialized
156+
* @return the insets of the border
157+
*/
94158
public Insets getBorderInsets(Component c, Insets insets)
95159
{
96160
return insets;
97161
}
98-
99162
}

0 commit comments

Comments
 (0)