Skip to content

Commit f5c1c03

Browse files
authored
Merge pull request atarw#35 from vincenzopalazzo/pull_jprogressbar
added support to jtextpane
2 parents 1c26520 + 188021b commit f5c1c03

File tree

5 files changed

+111
-16
lines changed

5 files changed

+111
-16
lines changed

src/MaterialUISwingDemo.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import mdlaf.resources.MaterialColors;
44

55
import javax.swing.*;
6-
import java.awt.BorderLayout;
7-
import java.awt.Dimension;
6+
import java.awt.*;
7+
import java.awt.event.ActionEvent;
88

99
public class MaterialUISwingDemo {
1010

@@ -33,12 +33,12 @@ public static void main (String[] args) {
3333
JRadioButtonMenuItem jRadioButtonMenuItem = new JRadioButtonMenuItem();
3434
jRadioButtonMenuItem.setText("prova RadioButtonMenuItem");
3535
menu1.add(jRadioButtonMenuItem);
36-
36+
menu1.addSeparator();
3737
//TestCheckBoxMenuItem
3838
JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem();
3939
checkBoxMenuItem.setText("test");
4040
menu1.add(checkBoxMenuItem);
41-
41+
menu1.addSeparator();
4242
menu1.add (item1);
4343
menu2.add (item2);
4444

@@ -114,6 +114,18 @@ public static void main (String[] args) {
114114
progressBar.setValue(5);
115115
pn.add(progressBar);
116116

117+
JTextPane textPane = new JTextPane();
118+
textPane.setText("Hi I'm super sayan");
119+
JTextPane textPane1 = new JTextPane();
120+
textPane1.setText("Hi I'm super sayan");
121+
textPane1.setEnabled(false);
122+
pn.add(textPane);
123+
pn.add(textPane1);
124+
125+
JEditorPane editorPane = new JEditorPane();
126+
editorPane.setText("This theme is fantastic");
127+
pn.add(editorPane);
128+
117129
// make everything visible to the world
118130
frame.pack ();
119131
frame.setVisible (true);

src/mdlaf/MaterialLookAndFeel.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package mdlaf;
22

3+
import javafx.scene.paint.Material;
34
import mdlaf.components.button.MaterialButtonUI;
45
import mdlaf.components.checkBoxMenuItem.MaterialCheckBoxMenuItemUI;
56
import mdlaf.components.checkbox.MaterialCheckBoxUI;
@@ -15,12 +16,14 @@
1516
import mdlaf.components.radiobutton.MaterialRadioButtonUI;
1617
import mdlaf.components.radiobuttonmenuitem.MaterialRadioButtonMenuItemUI;
1718
import mdlaf.components.scrollbar.MaterialScrollBarUI;
19+
import mdlaf.components.separator.MaterialSeparatorUI;
1820
import mdlaf.components.slider.MaterialSliderUI;
1921
import mdlaf.components.spinner.MaterialSpinnerUI;
2022
import mdlaf.components.tabbedpane.MaterialTabbedPaneUI;
2123
import mdlaf.components.table.MaterialTableHeaderUI;
2224
import mdlaf.components.table.MaterialTableUI;
2325
import mdlaf.components.textfield.MaterialTextFieldUI;
26+
import mdlaf.components.textpane.MaterialTextPaneUI;
2427
import mdlaf.components.togglebutton.MaterialToggleButtonUI;
2528
import mdlaf.components.toolbar.MaterialToolBarUI;
2629
import mdlaf.components.tree.MaterialTreeUI;
@@ -59,18 +62,9 @@ public class MaterialLookAndFeel extends MetalLookAndFeel {
5962
private static final String progressBarUI = MaterialProgressBarUI.class.getCanonicalName();
6063
private static final String radioButtonMenuItemUI = MaterialRadioButtonMenuItemUI.class.getCanonicalName();
6164
private static final String checkBoxMenuItemUI = MaterialCheckBoxMenuItemUI.class.getCanonicalName();
62-
63-
public static String getCheckBoxMenuItemUI() {
64-
return checkBoxMenuItemUI;
65-
}
66-
67-
public static String getRadioButtonMenuItemUI() {
68-
return radioButtonMenuItemUI;
69-
}
70-
71-
public static String getProgressbarui() {
72-
return progressBarUI;
73-
}
65+
private static final String textPaneUI = MaterialTextPaneUI.class.getCanonicalName();
66+
private static final String editorPane = MaterialTextPaneUI.class.getCanonicalName();
67+
private static final String separatorUI = MaterialSeparatorUI.class.getCanonicalName();
7468

7569
@Override
7670
public String getName () {
@@ -124,6 +118,9 @@ protected void initClassDefaults (UIDefaults table) {
124118
table.put("ProgressBarUI", progressBarUI);
125119
table.put("RadioButtonMenuItemUI", radioButtonMenuItemUI);
126120
table.put("CheckBoxMenuItemUI", checkBoxMenuItemUI);
121+
table.put("TextPaneUI", textPaneUI);
122+
table.put("EditorPaneUI", editorPane);
123+
table.put("SeparatorUI", separatorUI);
127124
}
128125

129126
@Override
@@ -292,5 +289,20 @@ protected void initComponentDefaults (UIDefaults table) {
292289
table.put ("CheckBoxMenuItem.border", BorderFactory.createEmptyBorder (5, 5, 5, 5));
293290
table.put("CheckBoxMenuItem.checkIcon", new ImageIcon(MaterialImages.UNCHECKED_BOX));
294291
table.put("CheckBoxMenuItem.selectedCheckIcon", new ImageIcon(MaterialImages.PAINTED_CHECKED_BOX));
292+
293+
table.put("TextPane.border", MaterialBorders.DEFAULT_SHADOW_BORDER);
294+
table.put("TextPane.background", MaterialColors.GRAY_50);
295+
table.put("TextPane.selectionBackground", MaterialColors.LIGHT_BLUE_200);
296+
table.put("TextPane.inactiveForeground", MaterialColors.GRAY_500);
297+
table.put("TextPane.font", MaterialFonts.BLACK_ITALIC);
298+
299+
table.put("EditorPane.border", MaterialBorders.DEFAULT_SHADOW_BORDER);
300+
table.put("EditorPane.background", MaterialColors.GRAY_50);
301+
table.put("EditorPane.selectionBackground", MaterialColors.LIGHT_BLUE_200);
302+
table.put("EditorPane.inactiveForeground", MaterialColors.GRAY_500);
303+
table.put("EditorPane.font", MaterialFonts.BLACK_ITALIC);
304+
305+
table.put("Separator.background", MaterialColors.GRAY_300);
306+
table.put("Separator.foreground", MaterialColors.GRAY_300);
295307
}
296308
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package mdlaf.components.editorpane;
2+
3+
import javax.swing.*;
4+
import javax.swing.plaf.ComponentUI;
5+
import javax.swing.plaf.basic.BasicEditorPaneUI;
6+
7+
/**
8+
*
9+
* @author https://github.com/vincenzopalazzo
10+
*
11+
*/
12+
13+
public class MaterialEditorPaneUI extends BasicEditorPaneUI {
14+
15+
public static ComponentUI createUI(JComponent c){
16+
return new MaterialEditorPaneUI();
17+
}
18+
19+
@Override
20+
public void installUI(JComponent c) {
21+
super.installUI(c);
22+
}
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package mdlaf.components.separator;
2+
3+
import mdlaf.resources.MaterialDrawingUtils;
4+
5+
import javax.swing.*;
6+
import javax.swing.plaf.ComponentUI;
7+
import javax.swing.plaf.basic.BasicSeparatorUI;
8+
import java.awt.*;
9+
10+
public class MaterialSeparatorUI extends BasicSeparatorUI {
11+
12+
public static ComponentUI createUI(JComponent c){
13+
return new MaterialSeparatorUI();
14+
}
15+
16+
@Override
17+
public void installUI(JComponent c) {
18+
super.installUI(c);
19+
}
20+
21+
@Override
22+
public void paint(Graphics g, JComponent c) {
23+
super.paint(MaterialDrawingUtils.getAliasedGraphics(g), c);
24+
}
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package mdlaf.components.textpane;
2+
3+
import javax.swing.*;
4+
import javax.swing.plaf.ComponentUI;
5+
import javax.swing.plaf.basic.BasicTextPaneUI;
6+
7+
/**
8+
* @author https://github.com/vincenzopalazzo
9+
*/
10+
11+
public class MaterialTextPaneUI extends BasicTextPaneUI {
12+
13+
public static ComponentUI createUI(JComponent c){
14+
return new MaterialTextPaneUI();
15+
}
16+
17+
@Override
18+
public void installUI(JComponent c) {
19+
super.installUI(c);
20+
}
21+
22+
23+
}

0 commit comments

Comments
 (0)