Skip to content

Commit e1a51c5

Browse files
added support to jtextpane
1 parent da4be39 commit e1a51c5

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

src/MaterialUISwingDemo.java

Lines changed: 10 additions & 3 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

@@ -38,7 +38,6 @@ public static void main (String[] args) {
3838
JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem();
3939
checkBoxMenuItem.setText("test");
4040
menu1.add(checkBoxMenuItem);
41-
4241
menu1.add (item1);
4342
menu2.add (item2);
4443

@@ -114,6 +113,14 @@ public static void main (String[] args) {
114113
progressBar.setValue(5);
115114
pn.add(progressBar);
116115

116+
JTextPane textPane = new JTextPane();
117+
textPane.setText("Hi I'm super sayan");
118+
JTextPane textPane1 = new JTextPane();
119+
textPane1.setText("Hi I'm super sayan");
120+
textPane1.setEnabled(false);
121+
pn.add(textPane);
122+
pn.add(textPane1);
123+
117124
// make everything visible to the world
118125
frame.pack ();
119126
frame.setVisible (true);

src/mdlaf/MaterialLookAndFeel.java

Lines changed: 10 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;
@@ -21,6 +22,7 @@
2122
import mdlaf.components.table.MaterialTableHeaderUI;
2223
import mdlaf.components.table.MaterialTableUI;
2324
import mdlaf.components.textfield.MaterialTextFieldUI;
25+
import mdlaf.components.textpane.MaterialTextPaneUI;
2426
import mdlaf.components.togglebutton.MaterialToggleButtonUI;
2527
import mdlaf.components.toolbar.MaterialToolBarUI;
2628
import mdlaf.components.tree.MaterialTreeUI;
@@ -59,18 +61,7 @@ public class MaterialLookAndFeel extends MetalLookAndFeel {
5961
private static final String progressBarUI = MaterialProgressBarUI.class.getCanonicalName();
6062
private static final String radioButtonMenuItemUI = MaterialRadioButtonMenuItemUI.class.getCanonicalName();
6163
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-
}
64+
private static final String textPaneUI = MaterialTextPaneUI.class.getCanonicalName();
7465

7566
@Override
7667
public String getName () {
@@ -124,6 +115,7 @@ protected void initClassDefaults (UIDefaults table) {
124115
table.put("ProgressBarUI", progressBarUI);
125116
table.put("RadioButtonMenuItemUI", radioButtonMenuItemUI);
126117
table.put("CheckBoxMenuItemUI", checkBoxMenuItemUI);
118+
table.put("TextPaneUI", textPaneUI);
127119
}
128120

129121
@Override
@@ -292,5 +284,11 @@ protected void initComponentDefaults (UIDefaults table) {
292284
table.put ("CheckBoxMenuItem.border", BorderFactory.createEmptyBorder (5, 5, 5, 5));
293285
table.put("CheckBoxMenuItem.checkIcon", new ImageIcon(MaterialImages.UNCHECKED_BOX));
294286
table.put("CheckBoxMenuItem.selectedCheckIcon", new ImageIcon(MaterialImages.PAINTED_CHECKED_BOX));
287+
288+
table.put("TextPane.border", MaterialBorders.DEFAULT_SHADOW_BORDER);
289+
table.put("TextPane.background", MaterialColors.GRAY_50);
290+
table.put("TextPane.selectionBackground", MaterialColors.LIGHT_BLUE_200);
291+
table.put("TextPane.inactiveForeground", MaterialColors.GRAY_500);
292+
table.put("TextPane.font", MaterialFonts.BLACK_ITALIC);
295293
}
296294
}
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)