gpt4 book ai didi

java外观和感觉: windows server 2012 shows progress bar too thin

转载 作者:行者123 更新时间:2023-11-30 04:27:34 24 4
gpt4 key购买 nike

当我使用时,我在 **windows server 2012 ** 上看到非常细的进度条

 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

该栏在 Windows 7 中看起来还不错,但在 Windows Server 2012 中看起来很细。
java版本到处都是(JDK和JRE)1.6.0_25,32位

enter image description here

这是演示问题(或文档问题)的完整代码我使用的是jdk 1.6.0_25

package demos;

import javax.swing.*;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.*;

public class ProgressBarLookAndFeelDemo {

private void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

JPanel progPanel = new JPanel();
progPanel.setLayout(new GridBagLayout());

frame.getContentPane().add(progPanel, BorderLayout.CENTER);

//
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
progPanel.add(progressBar);

//Display the window.
frame.pack();
frame.setVisible(true);
}

public void showUI(String name) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());


if ( name.equalsIgnoreCase("system")) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}

public static void main(String[] args) throws
ClassNotFoundException, UnsupportedLookAndFeelException,
InstantiationException, IllegalAccessException {


if (args.length <1 ) {
System.out.println("usage : One argument is expected none|system");
throw new IllegalArgumentException("java classname none|system");
}

new ProgressBarLookAndFeelDemo().showUI(args[0]);

}
}

这可能是 Windows 2012 的行为,但我看不到任何与之相关的文档。

最佳答案

我希望 32b 和 64b 版本没有问题

JDK_1.6_022 32b

enter image description here

enter image description here

enter image description here

JDK_1.7_011 64b

enter image description here

enter image description here

enter image description here

来自代码

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GridBagLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;

public class ProgressBarLookAndFeelDemo {

public ProgressBarLookAndFeelDemo() {
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);

JProgressBar progressBar1 = new JProgressBar();
progressBar1.setValue(66);

JPanel progPanel = new JPanel();
progPanel.setLayout(new GridBagLayout());
progPanel.add(progressBar);
progPanel.add(progressBar1);

JFrame frame = new JFrame("Frame Demo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(progPanel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
System.out.println(info.getName());
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (UnsupportedLookAndFeelException e) {
// handle exception
} catch (ClassNotFoundException e) {
// handle exception
} catch (InstantiationException e) {
// handle exception
} catch (IllegalAccessException e) {
// handle exception
}/**/
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new ProgressBarLookAndFeelDemo();
}
});
}
}

关于java外观和感觉: windows server 2012 shows progress bar too thin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15494812/

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