1

我的run.bat:

@echo off
@title test
java -Dfile.encoding=Cp1252 -classpath bin;lib/libs.jar;lib/substance-6.0.jar;lib/trident-1.2.jar; Loader
pause

我的框架:

void openFrame() {
        try {
         UIManager.setLookAndFeel("org.pushingpixals.substance.api.skin.SubstanceTwilightLookAndFeel"); 
            JFrame.setDefaultLookAndFeelDecorated(true);
             JDialog.setDefaultLookAndFeelDecorated(true);
        } catch (Throwable e) {
            e.getStackTrace();
        }
               appletFrame = new JFrame(Settings.serverName);
               appletFrame.setLayout(new BorderLayout());
    appletFrame.setDefaultCloseOperation(3);
    appletPanel.setLayout(new BorderLayout());
    appletPanel.add(this);
    appletPanel.setPreferredSize(new Dimension(765, 504));
    appletFrame.getContentPane().add(appletPanel, "Center");
    appletFrame.pack();
    appletFrame.setLocationRelativeTo(null);
    appletFrame.setVisible(true);

我这样做了,但由于某种原因,主题没有改变。似乎是什么问题?我得到了正确的物质和三叉戟,但它没有改变。

4

1 回答 1

1

1.change forSubstance L&F必须包裹成invokeLater()

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            try {
                UIManager.setLookAndFeel(new org.pushingpixels.substance.api.skin.SubstanceBusinessBlackSteelLookAndFeel());
            } catch (UnsupportedLookAndFeelException ex) {
            }
            // rest of your code
        }
    });
}

2.最好是这个图,以他们的名字称呼皮肤

( SubstanceLookAndFeel.setSkin(new BusinessBlueSteelSkin());)

或者

( UIManager.setLookAndFeel(new org.pushingpixels.substance.api.skin.SubstanceBusinessBlackSteelLookAndFeel());)

基里尔的代码示例

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import org.pushingpixels.substance.api.DecorationAreaType;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.BusinessBlueSteelSkin;

/**
 * Test application that shows the use of the
 * {@link SubstanceLookAndFeel#getDecorationType(java.awt.Component)} API called
 * on different components.
 *
 * @author Kirill Grouchnikov
 * @see SubstanceLookAndFeel#getDecorationType(java.awt.Component)
 */
public class GetDecorationType extends JFrame {

    private static final long serialVersionUID = 1L;

    /**
     * Creates the main frame for <code>this</code> sample.
     */
    public GetDecorationType() {
        super("Get decoration type");
        this.setLayout(new BorderLayout());
        final JTabbedPane tabs = new JTabbedPane();
        SubstanceLookAndFeel.setDecorationType(tabs, DecorationAreaType.HEADER);
        JPanel tab1 = new JPanel(new FlowLayout());
        tab1.add(new JTextField("sample"));
        final JComboBox combo = new JComboBox(new Object[]{"sample"});
        tab1.add(combo);
        SubstanceLookAndFeel.setDecorationType(tab1, DecorationAreaType.GENERAL);
        JPanel tab2 = new JPanel(new FlowLayout());
        tab2.add(new JTextField("sample2"));
        tab2.add(new JComboBox(new Object[]{"sample2"}));
        SubstanceLookAndFeel.setDecorationType(tab2, DecorationAreaType.GENERAL);
        tabs.addTab("tab1", tab1);
        tabs.addTab("tab2", tab2);
        this.add(tabs, BorderLayout.CENTER);
        JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        JButton getTypes = new JButton("Get types");
        getTypes.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        DecorationAreaType tabsType = SubstanceLookAndFeel.getDecorationType(tabs);
                        DecorationAreaType comboType = SubstanceLookAndFeel.getDecorationType(combo);
                        JOptionPane.showMessageDialog(GetDecorationType.this,
                                "Tabbed pane: " + tabsType.getDisplayName() + "\n" + "Combo box: " + comboType.getDisplayName());
                    }
                });
            }
        });
        controlPanel.add(getTypes);
        this.add(controlPanel, BorderLayout.SOUTH);
        this.setSize(400, 200);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    /**
     * The main method for <code>this</code> sample. The arguments are ignored.
     *
     * @param args
     *            Ignored.
     */
    public static void main(String[] args) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                SubstanceLookAndFeel.setSkin(new BusinessBlueSteelSkin());
                UIManager.put("TabbedPane.contentOpaque", Boolean.TRUE);
                new GetDecorationType().setVisible(true);
            }
        });
    }
}
于 2012-06-22T07:58:38.210 回答