Java外观:Windows Server 2012显示进度条太薄 [英] java look and feel: windows server 2012 shows progress bar too thin

查看:62
本文介绍了Java外观:Windows Server 2012显示进度条太薄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用时,我在** windows server 2012 **上获得的进度条非常薄

I get very thin progress bar on **windows server 2012 ** , when I use

 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

在Windows 7中,该栏看起来还不错,在Windows Server 2012上非常薄.
Java版本(JDK和JRE都在哪里)1.6.0_25,32位

The bar look okay in windows 7, very thin on windows server 2012.
java version every where is (both JDK and JRE) 1.6.0_25, 32 bit

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

Here is the full code to demonstrate a problem (or documentation issue) I am on 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的行为,但我看不到任何与此相关的文档.

This is possibly a windows 2012 behavior, but I could not see any documentation related to it.

推荐答案

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

I'm hope that there isn't issue with 32b and 64b version

JDK_1.6_022 32b

JDK_1.6_022 32b

JDK_1.7_011 64b

JDK_1.7_011 64b

来自代码

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显示进度条太薄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆