Comments (3)
Please provide a simple standalone example which demonstrates the issue you are describing.
from darklaf.
Please provide a simple standalone example which demonstrates the issue you are describing.
hello @weisJ ,this is a simple demo code, when open the window and trigger node8,the bug will become!
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import java.awt.*;
/**
* @author richie
* Created by richie on 2023/5/17
*/
public class JTreeDemo {
public static void main(String... args) {
LafManager.installTheme(new IntelliJTheme());
JFrame frame = new JFrame();
JPanel contentPane = (JPanel) frame.getContentPane();
contentPane.setLayout(new BorderLayout());
JTreePane treePane = new JTreePane();
contentPane.add(treePane, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setVisible(true);
}
/**
* @author richie
* Created by richie on 2023/5/17
*/
public static class JTreePane extends JPanel {
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel(root);
private final JTree jTree = new JTree(model);
public JTreePane() {
setLayout(new BorderLayout());
jTree.setCellRenderer(new DatasourceTreeCellRenderer());
jTree.setRootVisible(false);
JScrollPane leftScrollPane = new JScrollPane(jTree);
add(leftScrollPane, BorderLayout.CENTER);
DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(new NodeObject("node1"));
node1.add(new DefaultMutableTreeNode( new NodeObject("node1-1")));
root.add(node1);
DefaultMutableTreeNode node2 = new DefaultMutableTreeNode(new NodeObject("node2"));
root.add(node2);
DefaultMutableTreeNode node3 = new DefaultMutableTreeNode(new NodeObject("node3"));
root.add(node3);
DefaultMutableTreeNode node4 = new DefaultMutableTreeNode(new NodeObject("node4"));
root.add(node4);
DefaultMutableTreeNode node5 = new DefaultMutableTreeNode(new NodeObject("node5"));
root.add(node5);
DefaultMutableTreeNode node6 = new DefaultMutableTreeNode(new NodeObject("node6"));
root.add(node6);
DefaultMutableTreeNode node7 = new DefaultMutableTreeNode(new NodeObject("node7"));
root.add(node7);
DefaultMutableTreeNode node8 = new DefaultMutableTreeNode(new NodeObject("node8"));
node8.add(new DefaultMutableTreeNode( new NodeObject("node8-1")));
root.add(node8);
model.reload(root);
}
}
/**
* @author richie
* Created by richie on 2023/5/17
*/
public interface Nameable extends Cloneable {
String getName();
void setName(String name);
}
/**
* @author richie
* Created by richie on 2023/5/17
*/
public static class NodeObject implements Nameable {
private String name;
public NodeObject(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
}
/**
* @author richie
* Created by richie on 2023/5/17
*/
public static class DatasourceTreeCellRenderer extends DefaultTreeCellRenderer {
public DatasourceTreeCellRenderer() {
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObject = node.getUserObject();
if (userObject instanceof Nameable) {
this.setText(((Nameable) userObject).getName());
}
return this;
}
}
}
from darklaf.
I can't reproduce this with the latest snapshot hence will assume it is fixed. I'll release the new version in the next few days. If the issue still happens for you feel free to reopen the issue.
from darklaf.
Related Issues (20)
- Wiki Demo links not working. HOT 1
- temp files not deleted on Windows HOT 2
- Stackoverflow when setting the border of a spinner editor to an UIResource border
- Advice on how to contribute, Darklaf theme broken in JMeter 5.3, 5.4, 5.5 HOT 4
- Event registered on EditorComponent for JComboBox will be cleared when new theme applied. HOT 3
- On a windows 10 computer,cannot open filechooser HOT 2
- JTabFrame custom PanelPopup buttons disappear after changing LaF settings HOT 1
- [Feature Request] JTabFrame disallow changing Alignment of the tabs.
- Buttons are "raised" in latest.integration (compared to 3.0.2)
- Can't build project on mac m1, 13.12.1 HOT 1
- Replace UIDefaultsWithResourceBundleCache with delegation
- [Feature Request] Allow confirm dialog on closing for ClosableTabbedPane without overwriting removeTabAt method
- [Bug] Exception when running on Windows Java 17 HOT 7
- [Bug] Opacity slider of JColorChooser has no effect
- [Feature Request] Apply color pipette with left-mouse click HOT 1
- [Bug] Wrong IconButton positioning in v3.0.3 HOT 2
- Dynamic colors in SVG icons don't work in native macOS menus
- [Feature Request] Frosted / Blurry background window support (Windows Acrylic / macOs: Vibrant) HOT 4
- Strange colors appearing in JColorChooser dialog
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from darklaf.