如何配置和安装Flamingo Java Swing Ribbon按钮和菜单?

时间:2019-03-07 06:26:18

标签: java swing swingx radiance-flamingo

问题:

我是Java swing火烈鸟框架的新手。首先,如何在netbean IDE中进行配置,请逐步指导我。

我在netbean项目中添加了flamingo 6.3.jar,但它不起作用或显示空白表格。

output Picture.png

脚本:

package javaapplication18;

//import java.awt.List;
import java.util.Arrays;
import java.util.List;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.SwingUtilities;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.ribbon.JRibbonBand;
import org.pushingpixels.flamingo.api.ribbon.JRibbonFrame;
import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.MEDIUM;
import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.TOP;
import org.pushingpixels.flamingo.api.ribbon.RibbonTask;
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy;

/**
 *
 * @author lubiesol
 */
public class MainFrame extends JRibbonFrame {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                MainFrame frame = new MainFrame();
                frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);

                JRibbonBand band1 = new JRibbonBand("Hello", null);
                JRibbonBand band2 = new JRibbonBand("world!", null);
                band1.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));
                band2.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));

                RibbonTask task1 = new RibbonTask("One", band1);
                RibbonTask task2 = new RibbonTask("Two", band2);

                JCommandButton button1 = new JCommandButton("Square", null);
                JCommandButton button2 = new JCommandButton("Circle", null);
                JCommandButton button3 = new JCommandButton("Triangle", null);
                JCommandButton button4 = new JCommandButton("Star", null);
                band1.addCommandButton(button1, TOP);
                band1.addCommandButton(button2, MEDIUM);
                band1.addCommandButton(button3, MEDIUM);
                band1.addCommandButton(button4, MEDIUM);
            }
        });
    }

    private void add(RibbonTask task1) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}

1 个答案:

答案 0 :(得分:0)

火烈鸟的作者在这里。您正在创建RibbonTask对象,但没有将它们添加到JRibbonFrame的功能区中。有关完整的Flamingo文档,请参见here