gpt4 book ai didi

java - UIDefaults.getUI() 失败 : error when loading a JFrame into another project

转载 作者:行者123 更新时间:2023-12-01 19:03:01 26 4
gpt4 key购买 nike

我找到了this project它在独立运行中工作得很好。但是,当我尝试将其添加到另一个项目中的 JPanel 时(已经在完全相同的项目中执行此操作,但使用我自己的 JFrame 并且工作正常),则会出现此错误:

 UIDefaults.getUI() failed: no ComponentUI class for: doubleslider.MThumbSlider[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,isInverted=false,majorTickSpacing=0,minorTickSpacing=0,orientation=HORIZONTAL,paintLabels=false,paintTicks=false,paintTrack=true,snapToTicks=false,snapToValue=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:729)
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
at javax.swing.UIDefaults.getUI(UIDefaults.java:759)
at javax.swing.UIManager.getUI(UIManager.java:1002)
at javax.swing.JSlider.updateUI(JSlider.java:323)
at doubleslider.MThumbSlider.updateUI(MThumbSlider.java:44)
at javax.swing.JSlider.<init>(JSlider.java:275)
at javax.swing.JSlider.<init>(JSlider.java:182)
at doubleslider.MThumbSlider.<init>(MThumbSlider.java:24)
at doubleslider.DoubleSlider.<init>(DoubleSlider.java:29)
at com.einge.scadaremotecontrol.Ventana.<init>(Ventana.java:227)
at com.einge.scadaremotecontrol.ScadaRemoteControl.<init>(ScadaRemoteControl.java:92)
at com.einge.scadaremotecontrol.ScadaRemoteControl.main(ScadaRemoteControl.java:197)
UIDefaults.getUI() failed: no ComponentUI class for: doubleslider.MThumbSlider[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,isInverted=false,majorTickSpacing=0,minorTickSpacing=0,orientation=HORIZONTAL,paintLabels=false,paintTicks=false,paintTrack=true,snapToTicks=false,snapToValue=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:729)
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
at javax.swing.UIDefaults.getUI(UIDefaults.java:759)
at javax.swing.UIManager.getUI(UIManager.java:1002)
at javax.swing.JSlider.updateUI(JSlider.java:323)
at doubleslider.MThumbSlider.updateUI(MThumbSlider.java:44)
at doubleslider.MThumbSlider.<init>(MThumbSlider.java:26)
at doubleslider.DoubleSlider.<init>(DoubleSlider.java:29)
at com.einge.scadaremotecontrol.Ventana.<init>(Ventana.java:227)
at com.einge.scadaremotecontrol.ScadaRemoteControl.<init>(ScadaRemoteControl.java:92)
at com.einge.scadaremotecontrol.ScadaRemoteControl.main(ScadaRemoteControl.java:197)

我的第一个猜测是 MultiTumbSlider 类试图设置与我的 JFrame 不同的外观和感觉。有什么解决办法吗?我无法弄清楚这一点,我真的需要两个 slider 才能有一个时间范围

任何帮助将不胜感激!

最佳答案

我不认识这个非常古老的 example 中使用的加载方法。 ;它似乎是基于当前的外观和感觉。您可以尝试显式设置javax.swing.plaf.metal.MetalLookAndFeel。展望 future ,看看 Kirill Grouchnikov 的 How to Write a Custom Swing Component获取有关代表管道现代化的指导。

关于java - UIDefaults.getUI() 失败 : error when loading a JFrame into another project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11507739/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com