1

使用すると、 **windows server 2012 ** で非常に薄い進行状況バーが表示されます

 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Windows Server 2012 ではバーが非常に薄く、Windows 7 では問題ないように見えます。
Java のバージョンはすべて (JDK と JRE の両方) 1.6.0_25、32 ビットです。

ここに画像の説明を入力

これは、私が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 の動作ですが、関連するドキュメントは見つかりませんでした。

4

1 に答える 1

2

32bバージョンと64bバージョンに問題がないことを願っています

JDK_1.6_022 32b

ここに画像の説明を入力してください

ここに画像の説明を入力してください

ここに画像の説明を入力してください

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();
            }
        });
    }
}
于 2013-03-19T09:50:30.933 に答える