今、私はNimbusルックアンドフィールを既に使用中のアプリケーションに設定しています。 アプリケーションには、垂直線と水平線を表示する必要があるJTree
が含まれています。Nimbus JTreeプレゼンテーションエラー、Javaバージョン1.8
UIManager.put("Tree.drawVerticalLines", true);
と
UIManager.put("Tree.drawHorizontalLines", true);
UIDefaults
でそれらの特定のエントリで設定するのは簡単だった使用されるJavaのバージョン1.7の下で
上記を暗示しているように、バージョン1.7のjreを使用している限り、これは完全にうまく動作します.1.8を使用すると、JTree
の垂直線が表示されません。
これはNimbusの既知の問題がJava 1.8の下にあるかどうかを誰かが知っているかどうかを尋ねたかったのですが、もしそうなら、この問題の解決策または回避策を知っている人はいますか?
EDIT:私の問題を明確にするここではいくつかのサンプルコード:
public class test
{
public static void main(String args[]) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
{
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
UIManager.put("Tree.drawVerticalLines", true);
UIManager.put("Tree.drawHorizontalLines", true);
UIManager.put("Tree.linesStyle", "dashed");
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Root");
top.add(new DefaultMutableTreeNode("Branch1"));
top.add(new DefaultMutableTreeNode("Branch2"));
top.add(new DefaultMutableTreeNode("Branch3"));
((DefaultMutableTreeNode)top.getFirstChild()).add(new DefaultMutableTreeNode("Leaf1"));
((DefaultMutableTreeNode)top.getFirstChild()).add(new DefaultMutableTreeNode("Leaf2"));
JFrame frame = new JFrame();
JTree tree = new JTree(top);
frame.setSize(new Dimension(450,300));
JScrollPane scroll = new JScrollPane(tree);
frame.add(scroll);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
これは単なるサンプルコードではなく、私は現在で働いています実際のソフトウェアですので、私は問題は間違い次第だと思います私はどちらのコードでも、Javaバージョン1.8でいくつかの問題を抱えていました。
jdk1.7とjdk1.8の使用は、2つの異なる結果をもたらす:
jdk1.7
jdk1.8
可能な限り1.8バージョンの水平線が見当たらないことを見てください。
ひどい文法で申し訳ありませんが、私はネイティブスピーカーではありません。私は私が回避策を見つけたと思う
import java.awt.*;
import javax.swing.*;
public class NimbusDrawVerticalLinesTest {
public static void main(String... args) {
EventQueue.invokeLater(() -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
// UIManager.put("Tree.drawVerticalLines", true);
UIManager.getLookAndFeelDefaults().put("Tree.drawVerticalLines", true);
UIManager.put("Tree.drawHorizontalLines", true);
UIManager.put("Tree.linesStyle", "dashed");
JTree tree = new JTree();
// UIDefaults d = new UIDefaults();
// d.put("Tree.drawVerticalLines", Boolean.TRUE);
// tree.putClientProperty("Nimbus.Overrides", d);
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new JScrollPane(tree));
f.setSize(320, 240);
f.setLocationRelativeTo(null);
f.setVisible(true);
});
}
}
すぐに役立つようにするには、[MCVE]または[ショート、自己完結型、正しい例](http://www.sscce.org/)を投稿してください。 –