2017-12-14 10 views
0

フラミンゴの基本的な例を実装しようとしていますが、これはWindowsアプリケーションのリボンエミュレータですが、私は固執しています。もう1つはテキスト "エディション"が表示され、コンポーネントは表示されません。また、クリックすると最初の "エディション"のバンドの下に表示され、再び、などのように表示されます。コードは最初のバンドと同じです。ここ フラミンゴのスイングリボン:最初のバンドだけが正しく表示されます

は私のコードです:

package tries; 

import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState; 
import org.pushingpixels.flamingo.api.common.JCommandButton; 
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon; 
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon; 
import org.pushingpixels.flamingo.api.ribbon.JRibbonBand; 
import org.pushingpixels.flamingo.api.ribbon.JRibbonFrame; 
import org.pushingpixels.flamingo.api.ribbon.RibbonTask; 
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies; 
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy; 
import org.pushingpixels.substance.api.SubstanceLookAndFeel; 
import org.pushingpixels.substance.api.skin.CeruleanSkin; 

import javax.swing.*; 
import java.awt.*; 
import java.util.Arrays; 

import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.MEDIUM; 
import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.TOP; 

public class RibbonTry extends JRibbonFrame { 

    public static void main(String[] args) { 

    JFrame.setDefaultLookAndFeelDecorated(true); 
    SwingUtilities.invokeLater(() -> { 
     SubstanceLookAndFeel.setSkin(new CeruleanSkin()); 
     RibbonTry ribbonTry = new RibbonTry(); 

     JRibbonBand bnd_store = new JRibbonBand("Stockage", null); 
     bnd_store.setResizePolicies(Arrays.asList 
       (new IconRibbonBandResizePolicy(bnd_store.getControlPanel()))); 
     JRibbonBand bnd_edition = new JRibbonBand("Edition", null); 
     bnd_edition.setResizePolicies(Arrays.asList(
       new IconRibbonBandResizePolicy(bnd_edition.getControlPanel()))); 
     JRibbonBand bnd_searches = new JRibbonBand("Recherches", null); 
     bnd_searches.setResizePolicies(Arrays.asList(
       new IconRibbonBandResizePolicy(bnd_searches.getControlPanel()))); 


     JCommandButton btn_saveInFile = new JCommandButton("Enregistrer", 
       getResizableIconFromResource("save1.png")); 
     btn_saveInFile.setDisplayState(CommandButtonDisplayState.BIG); 
     btn_saveInFile 
       .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); 
     bnd_store.addCommandButton(btn_saveInFile, TOP); 
     btn_saveInFile.setDisplayState(CommandButtonDisplayState.BIG); 
     JCommandButton btn_loadFromFile = new JCommandButton("Charger", 
       getResizableIconFromResource("load1.png")); 
     btn_loadFromFile 
       .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); 
     bnd_store.addCommandButton(btn_loadFromFile, TOP); 
     bnd_store.setResizePolicies(Arrays.asList(
       new CoreRibbonResizePolicies.None(bnd_store.getControlPanel()), 
       new IconRibbonBandResizePolicy(bnd_store.getControlPanel()) 
    )); 
     JCommandButton btn_saveInTable = new JCommandButton("Stocker dans table", 
       getResizableIconFromResource("add-row.png")); 
     btn_saveInTable.setDisplayState(CommandButtonDisplayState.MEDIUM); 
     btn_saveInTable 
       .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); 
     bnd_edition.addCommandButton(btn_saveInTable, MEDIUM); 

     JCommandButton btn_cancelFromTable = new JCommandButton("Annuler les " + 
       "changements", 
       getResizableIconFromResource("open-in-browser.png")); 
     btn_cancelFromTable.setDisplayState(CommandButtonDisplayState.MEDIUM); 
     btn_cancelFromTable 
       .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); 
     bnd_edition.addCommandButton(btn_cancelFromTable, MEDIUM); 

     JCommandButton btn_deleteInTable = new JCommandButton("Effacer dans table", 
       getResizableIconFromResource("delete-row.png")); 
     btn_deleteInTable.setDisplayState(CommandButtonDisplayState.MEDIUM); 
     btn_deleteInTable 
       .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); 
     bnd_edition.addCommandButton(btn_deleteInTable, MEDIUM); 

     RibbonTask task1 = new RibbonTask("Commandes", bnd_store, bnd_edition, 
       bnd_searches); 
     ribbonTry.getRibbon().addTask(task1); 


     ribbonTry.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
     ribbonTry.setLocation(300, 200); 
     ribbonTry.pack(); 
     ribbonTry.setMinimumSize(new Dimension(500, 300)); 
     ribbonTry.setVisible(true); 

    }); 

    } 

    private static ResizableIcon getResizableIconFromResource(String resource) { 
    return ImageWrapperResizableIcon 
      .getIcon(RibbonTry.class.getClassLoader().getResource(resource), new 
        Dimension(48, 48)); 
    } 


} 

ありがとう

オリヴィエ

答えて

1

あなたはすべての3つのバンドにsetResizePoliciesを呼び出すだけIconRibbonBandResizePolicyに合格している - リボンバンドを強制的に一つでありますアイコン化された状態にする。

次に、2つのサイズ変更ポリシー(noneとiconified)を使用してbnd_storeを再設定し、コンテンツを表示します。しかし、他の2つはアイコン化されたままです。

アイコン化されたポリシーのみでsetResizePoliciesを呼び出すことができるフラミンゴのバグがあります。これはhttps://github.com/kirill-grouchnikov/flamingo/issues/17

によって追跡されます
関連する問題