i want to make a menubar similar to that of MS OFfice.
I have downloaded some Executable JAR files that tells me they can help me,
but as I run the codes, nothing happens.

Can you please teach me how make a ribbon menu bar.?
or give me a link that really works.
I need that for my thesis. Thank You!

Recommended Answers

All 4 Replies

"nothing happens" is a bit thin to go on. What jars and what code?

Personally, I have no interest in playing with some tutorial to see if I can recreate "nothing happens". Perhaps someone else does. I can cause nothing to happen by just sitting here at my desk; it doesn't really help resolve your issue though.

Post your code and describe what isn't happening.

public class RibbonLastTry extends JRibbonFrame
{
    public static void main (String[] args)
    {
        SwingUtilities.invokeLater(new Runnable() {
            private RibbonElementPriority TOP;
            private RibbonElementPriority MEDIUM;

            @Override
            public void run() {
                //throw new UnsupportedOperationException("Not supported yet.");
                RibbonLastTry frame = new RibbonLastTry();
                // frame.setSize(new Dimension(500,500));
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setResizable(true);
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);
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);

// C:\Dokumente und Einstellungen\Claudia\Desktop\svgicons\black // “src\\gui\\rightblack.svg”
JCommandButton button1 = new JCommandButton("Square", getResizableIconFromResource("src\\gui\\rightblack.svg"));
JCommandButton button2 = new JCommandButton("Circle", null);
JCommandButton button3 = new JCommandButton("Triangle", null);
JCommandButton button4 = new JCommandButton("Star", null);
band1.addCommandButton(button1, RibbonElementPriority.TOP);
band1.addCommandButton(button2, RibbonElementPriority.MEDIUM);
band1.addCommandButton(button3, RibbonElementPriority.MEDIUM);
band1.addCommandButton(button4, RibbonElementPriority.MEDIUM);

band1.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
band1.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(band1.getControlPanel()), new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()), new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()), new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));

}
});
}

public static ResizableIcon getResizableIconFromResource(String resource)
{

File right = new File(resource);
URL url;
try
{
url = right.toURI().toURL();
} catch (MalformedURLException e)
{
// cannot do anything, stop program/thread with RuntimeException
throw new RuntimeException(e);
}
// URL u = MainFrame.class.getClassLoader().getResource(“leftblack”);
return ImageWrapperResizableIcon.getIcon(/*u*/ url, new Dimension(18, 18));
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.