JProgressBar
here : progressbar.xmlThe wiki guide explains the general idea on how skins and styles can be created. You need to do two things:
Make a custom skin XML that includes existing default skin - it is shown in this section
Add a custom default style for JProgressBar
that would adjust the background:
<!-- Progress bar -->
<style type="progressbar">
<painter>
<!-- Progress line -->
<progressPainter>
<decorations>
<decoration states="progress">
<GradientBackground>
<color>233,233,233</color>
<color>223,223,223</color>
</GradientBackground>
</decoration>
</decorations>
</progressPainter>
</painter>
</style>
The background part can be changed to any IBackground
implementation usage there (you can check them in the library). In the example above I've left the default GradientBackground
use.
<skin xmlns="http://weblookandfeel.com/XmlSkin">
<!-- com.alee.laf.progressbar.WebProgressBar -->
<id>progressbar.skin</id>
<class>com.alee.laf.progressbar.WebProgressBar</class>
<supportedSystems>all</supportedSystems>
<include nearClass= "com.alee.laf.progressbar.WebProgressBar">
<!-- Progress bar -->
<style type="progressbar" id="customProgressbarSkin">
<painter>
<!-- Progress line -->
<progressPainter>
<decorations>
<decoration states="progress">
<GradientBackground>
<color>16,194,20</color>
<color>16,194,20</color>
</GradientBackground>
</decoration>
</decorations>
</progressPainter>
</painter>
</style>
</include>
</skin>
package external_classes;
import com.alee.api.resource.ClassResource;
import com.alee.managers.style.XmlSkin;
public class ProgressBarSkin extends XmlSkin{
public ProgressBarSkin() {
super(new ClassResource(ProgressBarSkin.class, "customProgressbar.xml"));
}
}
WebLookAndFeel.install(ProgressBarSkin.class);
WebProgressBar progressBar = new WebProgressBar(StyleId.of("customProgressbarSkin"));
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
StyleManager.addExtensions(
new XmlSkinExtension(new ClassResource(Main.class, "/styling/customSkins.xml")),
new XmlSkinExtension(new ClassResource(Main.class, "/styling/customSkins-dark.xml")));
@kovadam69
You're a bit wrong though, he is creating skin, not an extensions, so he needs XmlSkin
not XmlSkinExtension
.
@htetaungkhant
As for what the issue is - you have put the style inside the include tag - why? All include does is it imports all styles from another XML skin file. For your case - you want to include the default light skin so you don't have to define all styles for all components. The include you need is:
<!-- Including WebLaF default skin, will use its style as a base -->
<include nearClass="com.alee.skin.light.WebLightSkin">resources/web-light-skin.xml</include>
(copy-pasted straight from example)
And simply place your custom progressbar
style nearby, you can look at some other skin/extension files available in the project if you aren't sure, like this one: demo-light-extension.xml
The error you see in the log is happening because you have no SLF4J implementation included in your project. It doesn't come with WebLaF by default because everyone have their own logging implementations in their projects and WebLaF uses SLF4J simply as an API for logging, it stil needs the actual implementation. You can read about SLF4J here: http://www.slf4j.org/
The most simple option - use SLF4J simple logger implementation, you can find it on Maven: https://search.maven.org/search?q=g:org.slf4j
Or you can use any other implementation available, for instance Log4j one if you're using it in your project for logging.
Once you have any implementation for SLF4J in your project - you will see the actual errors that occur in the styling with your example.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.27</version>
</dependency>
Also, if you're providing a style identifier like this:
<style type="progressbar" id="customProgressbarSkin">
You're creating a custom style based on default style and you will have to apply it manually to each specific progress bar you want to use that style on.
And if you remove the identifier - you will be adjusting the default style and it will apply to all newly created progress bars.
<skin xmlns="http://weblookandfeel.com/XmlSkin">
<!-- com.alee.laf.progressbar.WebProgressBar -->
<id>progressbar.skin</id>
<class>com.alee.skin</class>
<supportedSystems>all</supportedSystems>
<include nearClass="com.alee.skin.light.WebLightSkin">resources/web-light-skin.xml</include>
<!-- Progress bar -->
<style type="progressbar">
<painter>
<!-- Progress line -->
<progressPainter>
<decorations>
<decoration states="progress">
<GradientBackground>
<color>16,194,20</color>
<color>16,194,20</color>
</GradientBackground>
</decoration>
</decorations>
</progressPainter>
</painter>
</style>
</skin>
WebLookAndFeel.install ();
WebLookAndFeel.install(ProgressBarSkin.class);
JProgressBar jpb = new JProgressBar();
import com.alee.laf.WebLookAndFeel;
import javax.swing.*;
public class Test extends JFrame
{
Test()
{
JEditorPane p = new JEditorPane();
p.setText(
//"sdfsdfsdf sdfsdfsdf sssss s ss s s s s s s s s s ssssssssssssssssssssssss s s ss s sssssssssssssssssssss"
"للهِ تَعالى- لِتَعْمِيمِ النَّفْع بتِلْكَ الجُهُود المُبارَكة فِي هَذا المَيدَان العَظِيم باشَر القِسْمُ العِلْمِيُّ بِمُؤسَّسةِ الشَّيخِ محُمَّد بنِ صالِحٍ العُثَيمِين الخَيريَّةِ واجِباتِه فِي شَرَفِ الإِعْدادِ والتَّجْهِيز للطِّباعةِ والنَّشْر لإِخْراجِ ذَلِكَ التُّراث العِلمِي؛ إنفاذًا للقَواعِدِ والضَّوابِط والتَّوْجِيهاتِ الَّتِي قَرَّرها فَضيلةُ الشَّيخِ رَحِمَهُ اللهُ تَعالى في هَذا الشَّأْنِ.\n" +
"نَسْأل اللهَ تعالى أنْ يَجْعلَ هَذا العَمَلَ خالصًا لِوجهِه الكَريمِ؛ نافِعًا لعِبادِه، وأنْ يَجزِيَ فَضِيلةَ شيخِنا عَنِ الإسلامِ والمسلمِينَ خَيرَ الجزَاء، ويُضَاعِفَ لهُ المثُوبَةَ والأَجْرَ، ويُعليَ دَرَجَتَهُ في المَهْدِيِّينَ، إِنَّه سَمِيعٌ قَرِيبٌ مجُيبٌ."
);
WebLookAndFeel.setLeftToRightOrientation(true);
getContentPane().add(new JScrollPane(p, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
setSize(150, 100);
setVisible(true);
}
public static void main(String[] args)
{
WebLookAndFeel.install();
new Test();
}
}
Well, there are a few things with the wrapping - if you try the English variant it will also not wrap once you increase the size of the window and then shrink it, but that's a specific of how text layouting works within text areas, it is really hard to workaround that properly.
But yes, Arabic text doesn't seem to be wrapped at all on newest WebLaF version or with Metal with any Java version.
Hi @mgarin
Another question. i have this code
searchTree.addCheckStateChangeListener(new CheckStateChangeListener<DefaultMutableTreeNode>()
{
@Override
public void checkStateChanged(WebCheckBoxTree<DefaultMutableTreeNode> searchTree, List<CheckStateChange<DefaultMutableTreeNode>> checkStateChanges)
{
final java.util.List<DefaultMutableTreeNode> checkedNodes = searchTree.getNodes(CheckState.checked);
....
it throws the following exceptio:
java.lang.NullPointerException
at com.alee.extended.tree.NodesPositionComparator.compare(NodesPositionComparator.java:90)
at com.alee.extended.tree.NodesPositionComparator.compare(NodesPositionComparator.java:36)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:356)
at java.base/java.util.TimSort.sort(TimSort.java:220)
at java.base/java.util.Arrays.sort(Arrays.java:1306)
at java.base/java.util.ArrayList.sort(ArrayList.java:1720)
at java.base/java.util.Collections.sort(Collections.java:179)
at com.alee.extended.tree.DefaultTreeCheckingModel.getNodes(DefaultTreeCheckingModel.java:137)
at com.alee.extended.tree.WebCheckBoxTree.getNodes(WebCheckBoxTree.java:454)
at com.alee.extended.tree.WebCheckBoxTree.getNodes(WebCheckBoxTree.java:441)
at com.myapp.Indexer$2.checkStateChanged(Indexer.java:489)
at com.alee.extended.tree.DefaultTreeCheckingModel.fireCheckStateChanged(DefaultTreeCheckingModel.java:683)
at com.alee.extended.tree.DefaultTreeCheckingModel.setChecked(DefaultTreeCheckingModel.java:167)
at com.alee.extended.tree.WebCheckBoxTree.setChecked(WebCheckBoxTree.java:467)
at com.myapp.Indexer$22.actionPerformed(Indexer.java:3448)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369)
at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:349)
at com.myapp.Indexer$8$1.run(Indexer.java:1799)
any hint is appreciated. i cannot build a sample case. it is a bit complicated. but the point is that getNodes(CheckState.checked) throws internal NullPointerException
thank you, the exception happens when deleting the nodes. for some reason it is solved by replacing:
WebCheckBoxTree<DefaultMutableTreeNode> searchTree = new WebCheckBoxTree<>(searchRoot);
with
WebCheckBoxTree<DefaultMutableTreeNode> searchTree = new WebCheckBoxTree<>(new DefaultTreeModel(searchRoot));
really no clue what is happening (and i do not recall if the old code was working with swing laf or not) . so please just ignore this case and thank you