Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.MEDIUM;
  2. import static org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority.TOP;
  3.  
  4. import java.awt.Dimension;
  5. import java.awt.EventQueue;
  6. import java.util.Arrays;
  7. import java.util.List;
  8.  
  9. import javax.swing.JFrame;
  10. import javax.swing.SwingUtilities;
  11.  
  12. import org.pushingpixels.flamingo.api.common.JCommandButton;
  13. import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
  14. import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
  15. import org.pushingpixels.flamingo.api.ribbon.*;
  16. import org.pushingpixels.flamingo.api.ribbon.resize.*;
  17.  
  18. public class MainFrame extends JRibbonFrame {
  19.  
  20. /** Serial version unique id. */
  21. private static final long serialVersionUID = 1L;
  22.  
  23. public static ResizableIcon getResizableIconFromResource(String resource) {
  24.  
  25. return ImageWrapperResizableIcon.getIcon(MainFrame.class
  26. .getClassLoader().getResource(resource), new Dimension(48, 48));
  27. }
  28.  
  29. public static void main(String[] args) {
  30.  
  31. SwingUtilities.invokeLater(new Runnable() {
  32.  
  33. @Override
  34. public void run() {
  35.  
  36. MainFrame frame = new MainFrame();
  37.  
  38. frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  39. frame.pack();
  40. frame.setVisible(true);
  41.  
  42. JRibbonBand band1 = new JRibbonBand(
  43. "Hello",
  44. getResizableIconFromResource("48px-Crystal_Clear_app_Staroffice.png"));
  45. JRibbonBand band2 = new JRibbonBand("world!", null);
  46.  
  47. JCommandButton button1 = new JCommandButton(
  48. "Square",
  49. getResizableIconFromResource("48px-Crystal_Clear_app_kthememgr.png"));
  50. JCommandButton button2 = new JCommandButton(
  51. "Circle",
  52. getResizableIconFromResource("48px-Crystal_Clear_app_ksame.png"));
  53. JCommandButton button3 = new JCommandButton(
  54. "Triangle",
  55. getResizableIconFromResource("48px-Crystal_Clear_app_error.png"));
  56. JCommandButton button4 = new JCommandButton(
  57. "Star",
  58. getResizableIconFromResource("48px-Crystal_Clear_action_bookmark.png"));
  59.  
  60. band1.addCommandButton(button1, TOP);
  61. band1.addCommandButton(button2, MEDIUM);
  62. band1.addCommandButton(button3, MEDIUM);
  63. band1.addCommandButton(button4, MEDIUM);
  64.  
  65. band1.setResizePolicies((List) Arrays.asList(
  66. new CoreRibbonResizePolicies.None(band1.getControlPanel()),
  67. new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()),
  68. new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()),
  69. new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()),
  70. new IconRibbonBandResizePolicy(band1.getControlPanel())));
  71. band2.setResizePolicies((List) Arrays
  72. .asList(new IconRibbonBandResizePolicy(band2
  73. .getControlPanel())));
  74.  
  75. RibbonTask task1 = new RibbonTask("One", band1);
  76. RibbonTask task2 = new RibbonTask("Two", band2);
  77.  
  78. frame.getRibbon().addTask(task1);
  79. frame.getRibbon().addTask(task2);
  80.  
  81. frame.getRibbon().setApplicationMenu(new RibbonApplicationMenu());
  82. }
  83. });
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement