簡體   English   中英

為了改變java swing GUI的“外觀和感覺”,我需要采取哪些步驟?

[英]What steps do I need to take in order to change the 'look and feel' of java swing GUI?

我剛剛找到一個漂亮的外觀,我想用於我的程序外觀但是我不確定如何集成它。 這是我想要的樣子:

AcrylLookAndFeel

我已經設法找到該網站並下載了一個jar文件,我已將其包含在我的構建路徑中。 我還發現了以下代碼行:

UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");

當我運行它時,我沒有得到任何錯誤,但它看起來不像圖像。 我錯過了台階嗎? 我需要做什么?

另外一個問題是我正在使用mac,但無論我是在Mac上還是在Windows上運行程序,我都希望外觀保持一致。 這甚至可能嗎? 如果是這樣,請您告知如何執行此操作(如果需要更改)?

在Java中設置Swing外觀在操作系統之間進行。 在創建Swing GUI之前,我始終只做過它。

public static void main(String[] args) {
    try {    
        UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
    } 
    // Probably want to break this into handling the various exceptions that can be thrown.
    catch (Exception e) {
       // handle exception
    }

    // Create Swing GUI and so forth
}

在創建JFrame之前:

// setup the look and feel properties
Properties props = new Properties();

// set your theme
SmartLookAndFeel.setCurrentTheme(props);
// select the Look and Feel
UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
import org.jvnet.substance.SubstanceLookAndFeel;

public class Main {

    public static void main(String[] args) {
       /*Si no se tiene instalado la libreria Substance*/
       //formpadre fp= new formpadre();
       //fp.show();

        /*si la libreria substance esta instalada y configurada*/               
        EventQueue.invokeLater(new Runnable(){
        public void run(){
            try{
                JFrame.setDefaultLookAndFeelDecorated(true);                
                SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.BusinessBlueSteelSkin");            //SubstanceLookAndFeel.setCurrentTheme("org.jvnet.substance.theme.SubstanceAquaTheme");   
            }              
            catch(Exception e){
            }               
            new formpadre().setVisible(true);
        }
        });            
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM