Example #1
0
  public static JToolBar getToolbar(String label, int size, boolean hasStrings) {
    JToolBar toolBar = new JToolBar();

    JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut"));
    buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    toolBar.add(buttonCut);
    JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy"));
    buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    buttonCopy.setEnabled(false);
    toolBar.add(buttonCopy);
    JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
    toolBar.add(buttonPaste);
    JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all"));
    toolBar.add(buttonSelectAll);
    JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
    toolBar.add(buttonDelete);
    toolBar.addSeparator();

    // add an inner toolbar to check the painting of toolbar
    // gradient and drop shadows under different skins.
    JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL);
    innerToolbar.setFloatable(false);
    JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center"));
    buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f);
    innerToolbar.add(buttonFormatCenter);
    JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left"));
    innerToolbar.add(buttonFormatLeft);
    JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right"));
    innerToolbar.add(buttonFormatRight);
    JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill"));
    buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
    innerToolbar.add(buttonFormatFill);

    toolBar.add(innerToolbar);
    toolBar.addSeparator();

    if (size > 20) {
      JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL);
      innerToolbar2.setFloatable(false);

      JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      innerToolbar2.add(innerPanel, BorderLayout.CENTER);

      final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold"));
      Set<Side> rightSide = EnumSet.of(Side.RIGHT);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);

      final JToggleButton buttonStyleItalic =
          new JToggleButton(getIcon(size + "/format-text-italic"));
      buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleItalic.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleUnderline =
          new JToggleButton(getIcon(size + "/format-text-underline"));
      buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleUnderline.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleStrikethrough =
          new JToggleButton(getIcon(size + "/format-text-strikethrough"));
      buttonStyleStrikethrough.putClientProperty(
          SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT));
      buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);
      buttonStyleBold.setSelected(true);

      innerPanel.add(buttonStyleBold);
      innerPanel.add(buttonStyleItalic);
      innerPanel.add(buttonStyleUnderline);
      innerPanel.add(buttonStyleStrikethrough);

      toolBar.add(innerToolbar2);
    }

    toolBar.add(Box.createGlue());
    JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
    buttonExit.setToolTipText("Closes the test application");
    buttonExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    toolBar.add(buttonExit);

    return toolBar;
  }
Example #2
0
  public Check() {
    super(
        "Substance test with very very very very very very very very very very very very very very long title");

    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      setIconImage(
          SubstanceLogo.getLogoImage(
              SubstanceLookAndFeel.getCurrentSkin(this.getRootPane())
                  .getColorScheme(
                      DecorationAreaType.PRIMARY_TITLE_PANE,
                      ColorSchemeAssociationKind.FILL,
                      ComponentState.ENABLED)));
    }
    SubstanceLookAndFeel.registerSkinChangeListener(
        new SkinChangeListener() {
          @Override
          public void skinChanged() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    setIconImage(
                        SubstanceLogo.getLogoImage(
                            SubstanceLookAndFeel.getCurrentSkin(Check.this.getRootPane())
                                .getColorScheme(
                                    DecorationAreaType.PRIMARY_TITLE_PANE,
                                    ColorSchemeAssociationKind.FILL,
                                    ComponentState.ENABLED)));
                  }
                });
          }
        });

    setLayout(new BorderLayout());

    jtp = new JTabbedPane();
    try {
      mainTabPreviewPainter = new MyMainTabPreviewPainter();
      jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, mainTabPreviewPainter);
    } catch (Throwable e) {
    }
    jtp.getModel().addChangeListener(new TabSwitchListener());

    final JXPanel jxPanel = new JXPanel(new BorderLayout());
    toolbar = getToolbar("", 22, true);
    jxPanel.add(toolbar, BorderLayout.NORTH);

    JXStatusBar statusBar = getStatusBar(jxPanel, jtp);
    this.add(statusBar, BorderLayout.SOUTH);

    taskPaneContainer =
        new JXTaskPaneContainer() {
          @Override
          public boolean getScrollableTracksViewportWidth() {
            return false;
          }
        };
    taskPaneContainer.setScrollableTracksViewportHeight(false);
    taskPaneContainer.setScrollableTracksViewportWidth(false);

    mainTaskPane = new JXTaskPane();
    mainTaskPane.setLayout(new BorderLayout());
    JPanel mainControlPanel =
        ControlPanelFactory.getMainControlPanel(this, jtp, mainTabPreviewPainter, toolbar);
    // mainControlPanel.setOpaque(false);
    mainTaskPane.add(mainControlPanel, BorderLayout.CENTER);
    mainTaskPane.setTitle("General settings");
    mainTaskPane.setIcon(getIcon("JFrameColor16"));
    mainTaskPane.setCollapsed(true);
    taskPaneContainer.add(mainTaskPane);

    JPanel dialogControlPanel = ControlPanelFactory.getDialogControlPanel(this);
    JXTaskPane dialogTaskPane = new JXTaskPane();
    dialogTaskPane.setLayout(new BorderLayout());
    dialogTaskPane.add(dialogControlPanel, BorderLayout.CENTER);
    dialogTaskPane.setTitle("Frames & Dialogs");
    dialogTaskPane.setIcon(getIcon("JDialogColor16"));
    dialogTaskPane.setCollapsed(true);
    // dialogTaskPane.setOpaque(false);
    taskPaneContainer.add(dialogTaskPane);

    currentSpecificTaskPane = null;

    final JScrollPane scrollPane =
        new JScrollPane(
            taskPaneContainer,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    SubstanceLookAndFeel.setDecorationType(scrollPane, DecorationAreaType.GENERAL);
    // scrollPane.setOpaque(false);
    // scrollPane.getViewport().setOpaque(false);

    JPanel mainPanel = new JPanel();
    mainPanel.add(scrollPane);
    mainPanel.add(jtp);
    mainPanel.setLayout(
        new LayoutManager() {
          @Override
          public void addLayoutComponent(String name, Component comp) {}

          @Override
          public Dimension minimumLayoutSize(Container parent) {
            Dimension min1 = scrollPane.getMinimumSize();
            Dimension min2 = jtp.getMinimumSize();
            return new Dimension(min1.width + min2.width, min1.height + min2.height);
          }

          @Override
          public void layoutContainer(Container parent) {
            // give 30% width to task pane container and
            // 70% width to the tabbed pane with controls.
            int width = parent.getWidth();
            int height = parent.getHeight();
            scrollPane.setBounds(0, 0, (int) (0.3 * width), height);
            jtp.setBounds((int) (0.3 * width), 0, width - (int) (0.3 * width), height);
          }

          @Override
          public Dimension preferredLayoutSize(Container parent) {
            Dimension pref1 = scrollPane.getPreferredSize();
            Dimension pref2 = jtp.getPreferredSize();
            return new Dimension(pref1.width + pref2.width, pref1.height + pref2.height);
          }

          @Override
          public void removeLayoutComponent(Component comp) {}
        });
    jxPanel.add(mainPanel, BorderLayout.CENTER);

    this.add(jxPanel, BorderLayout.CENTER);

    setPreferredSize(new Dimension(400, 400));
    this.setSize(getPreferredSize());
    setMinimumSize(getPreferredSize());

    ButtonsPanel buttonsPanel = new ButtonsPanel();
    jtp.addTab("Buttons", getIcon("JButtonColor16"), buttonsPanel);
    getRootPane().setDefaultButton(buttonsPanel.defaultButton);

    jtp.addTab("Combo box", getIcon("JComboBoxColor16"), new CombosPanel());

    jtp.addTab("Scroll pane", getIcon("JScrollPaneColor16"), new ScrollPanel());

    TabCloseCallback closeCallback =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    try {
      TabPanel tp = new TabPanel();
      tp.jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback);
      jtp.addTab("Tabs", getIcon("JTabbedPaneColor16"), tp);
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Split", new SplitPanel());

    jtp.addTab("Desktop", getIcon("JDesktopPaneColor16"), new DesktopPanel());

    jtp.addTab("Text fields", getIcon("JTextPaneColor16"), new TextFieldsPanel());

    jtp.addTab("Table", getIcon("JTableColor16"), new TablePanel());

    try {
      jtp.addTab("List", getIcon("JListColor16"), new ListPanel());
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Slider", getIcon("JSliderColor16"), new SliderPanel());

    jtp.addTab("Progress bar", getIcon("JProgressBarColor16"), new ProgressBarPanel());

    jtp.addTab("Spinner", getIcon("JSpinnerColor16"), new SpinnerPanel());

    jtp.addTab("Tree", getIcon("JTreeColor16"), new TreePanel());

    jtp.addTab("File tree", getIcon("JTreeColor16"), new FileTreePanel());

    jtp.addTab("Cards", new CardPanel());

    JPanel verticalButtonPanel = new JPanel();
    verticalButtonPanel.setLayout(new GridLayout(1, 3));
    verticalButtonPanel.add(new JButton("Vert button 1"));
    verticalButtonPanel.add(new JButton("Vert button 2"));
    JPanel smallVerticalButtonPanel = new JPanel();
    smallVerticalButtonPanel.setLayout(new GridLayout(4, 4));
    for (int row = 0; row < 4; row++) {
      for (int col = 0; col < 4; col++) {
        JButton vertButton = new JButton("vert");
        vertButton.setToolTipText("Vertical button " + row + ":" + col);
        smallVerticalButtonPanel.add(vertButton);
      }
    }
    verticalButtonPanel.add(smallVerticalButtonPanel);
    jtp.addTab("V-Buttons", verticalButtonPanel);

    jtp.addTab("Colored", new ColoredControlsPanel());

    jtp.addTab("Colorized", new ColorizedControlsPanel());

    jtp.addTab("Cells", new CellsPanel());

    jtp.addTab("Sizes", new SizesPanel());

    jtp.addTab("H-Align", new HAlignmentPanel());

    jtp.addTab("V-Align", new VAlignmentPanel());

    // sample menu bar
    JMenuBar jmb = new JMenuBar();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      jmb.add(SampleMenuFactory.getSkinMenu());
      jmb.add(SampleMenuFactory.getTransformMenu());
    }
    JMenu coloredMenu = new JMenu("Colors");
    coloredMenu.setMnemonic('0');
    JMenuItem coloredMI = new JMenuItem("Italic red");
    coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC));
    coloredMI.setForeground(Color.red);
    coloredMenu.add(coloredMI);
    JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem("Bold green");
    coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(Font.BOLD));
    coloredRBMI.setForeground(Color.green);
    coloredMenu.add(coloredRBMI);
    JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem("Big blue");
    coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f));
    coloredCBMI.setForeground(Color.blue);
    coloredMenu.add(coloredCBMI);
    JMenu coloredM = new JMenu("Always big magenta");
    coloredM.setForeground(Color.magenta);
    coloredM.setFont(coloredM.getFont().deriveFont(24f));
    coloredMenu.add(coloredM);
    jmb.add(coloredMenu);

    JMenu testMenu = SampleMenuFactory.getTestMenu();
    jmb.add(testMenu);

    JMenu jm4 = new JMenu("Disabled");
    jm4.add(new JMenuItem("dummy4"));
    jm4.setMnemonic('4');
    jmb.add(jm4);
    jm4.setEnabled(false);

    // LAF changing
    jmb.add(SampleMenuFactory.getLookAndFeelMenu(this));
    setJMenuBar(jmb);

    TabCloseCallback closeCallbackMain =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON2) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallbackMain);
    SubstanceLookAndFeel.registerTabCloseChangeListener(
        new TabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab");
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableTabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab - specific");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab - specific");
          }

          @Override
          public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close '"
                        + tabbedPane.getTitleAt(tabbedPane.indexOfComponent(tabComponent))
                        + "' tab?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableMultipleTabCloseListener() {
          @Override
          public void tabsClosed(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closed " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public void tabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closing " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close " + tabComponents.size() + " tabs?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            System.out.println("Size " + getSize());
          }
        });
  }
Example #3
0
  protected static JXStatusBar getStatusBar(
      final JXPanel jxPanel, final JTabbedPane mainTabbedPane) {
    JXStatusBar statusBar = new JXStatusBar();

    try {
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      Enumeration<URL> urls = cl.getResources("META-INF/MANIFEST.MF");
      String substanceVer = null;
      String substanceBuildStamp = null;
      while (urls.hasMoreElements()) {
        InputStream is = urls.nextElement().openStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        while (true) {
          String line = br.readLine();
          if (line == null) break;
          int firstColonIndex = line.indexOf(":");
          if (firstColonIndex < 0) continue;
          String name = line.substring(0, firstColonIndex).trim();
          String val = line.substring(firstColonIndex + 1).trim();
          if (name.compareTo("Substance-Version") == 0) substanceVer = val;
          if (name.compareTo("Substance-BuildStamp") == 0) substanceBuildStamp = val;
        }
        try {
          br.close();
        } catch (IOException ioe) {
        }
      }
      if (substanceVer != null) {
        JLabel statusLabel = new JLabel(substanceVer + " [built on " + substanceBuildStamp + "]");
        JXStatusBar.Constraint cStatusLabel = new JXStatusBar.Constraint();
        cStatusLabel.setFixedWidth(300);
        statusBar.add(statusLabel, cStatusLabel);
      }
    } catch (IOException ioe) {
    }

    JXStatusBar.Constraint c2 =
        new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL);
    final JLabel tabLabel = new JLabel("");
    statusBar.add(tabLabel, c2);
    mainTabbedPane
        .getModel()
        .addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                int selectedIndex = mainTabbedPane.getSelectedIndex();
                if (selectedIndex < 0) tabLabel.setText("No selected tab");
                else
                  tabLabel.setText("Tab " + mainTabbedPane.getTitleAt(selectedIndex) + " selected");
              }
            });

    JPanel fontSizePanel = FontSizePanel.getPanel();
    JXStatusBar.Constraint fontSizePanelConstraints = new JXStatusBar.Constraint();
    fontSizePanelConstraints.setFixedWidth(270);
    statusBar.add(fontSizePanel, fontSizePanelConstraints);

    JPanel alphaPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));

    final JLabel alphaLabel = new JLabel("100%");
    final JSlider alphaSlider = new JSlider(0, 100, 100);
    alphaSlider.setFocusable(false);
    alphaSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            int currValue = alphaSlider.getValue();
            alphaLabel.setText(currValue + "%");
            jxPanel.setAlpha(currValue / 100.0f);
          }
        });
    alphaSlider.setToolTipText("Changes the global opacity. Is not Substance-specific");
    alphaSlider.setPreferredSize(new Dimension(120, alphaSlider.getPreferredSize().height));

    alphaPanel.add(alphaLabel);
    alphaPanel.add(alphaSlider);

    JXStatusBar.Constraint alphaPanelConstraints = new JXStatusBar.Constraint();
    alphaPanelConstraints.setFixedWidth(160);
    statusBar.add(alphaPanel, alphaPanelConstraints);
    return statusBar;
  }
  /**
   * Returns the main control panel.
   *
   * @param mainFrame The main test frame.
   * @param mainTabbedPane The main tabbed pane.
   * @param mainTabPreviewPainter The preview painter of the main tabbed pane.
   * @param toolbar The toolbar of the main test frame.
   * @return The main control panel.
   */
  public static JPanel getMainControlPanel(
      final JFrame mainFrame,
      final JTabbedPane mainTabbedPane,
      final MyMainTabPreviewPainter mainTabPreviewPainter,
      final JToolBar toolbar) {
    FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(lm);
    // builder.setDefaultDialogBorder();

    builder.appendSeparator("Title pane settings");
    final JCheckBox markAsModified = new JCheckBox("Marked modified");
    markAsModified.setOpaque(false);
    markAsModified.setSelected(false);
    markAsModified.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mainFrame
                .getRootPane()
                .putClientProperty(
                    SubstanceLookAndFeel.WINDOW_MODIFIED,
                    (markAsModified.isSelected() ? Boolean.TRUE : false));
          }
        });
    builder.append("Modified", markAsModified);

    final JCheckBox heapPanel = new JCheckBox("Has heap panel");
    heapPanel.setOpaque(false);
    heapPanel.setSelected(false);
    heapPanel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(),
                heapPanel.isSelected(),
                SubstanceWidgetType.TITLE_PANE_HEAP_STATUS);
          }
        });
    builder.append("Heap panel", heapPanel);

    JButton changeTitleButton = new JButton("Change");
    changeTitleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String random = "abcdefghijklmnopqrstuvwxyz ";
            int length = 60 + (int) (150 * Math.random());
            String title = "";
            while (length > 0) {
              title += random.charAt((int) (random.length() * Math.random()));
              length--;
            }
            mainFrame.setTitle(title);
          }
        });
    builder.append("Title string", changeTitleButton);

    builder.appendSeparator("Miscellaneous");

    final JCheckBox defaultRoundedCorners = new JCheckBox("by default");
    defaultRoundedCorners.setOpaque(false);
    boolean roundable =
        Boolean.valueOf(
            System.getProperty(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS_PROPERTY, "True"));
    defaultRoundedCorners.setSelected(roundable);
    defaultRoundedCorners.setEnabled(roundable);
    defaultRoundedCorners.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, defaultRoundedCorners.isSelected());
          }
        });
    builder.append("Rounded Windows", defaultRoundedCorners);

    final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox("use themed icons");
    useThemedDefaultIconsCheckBox.setOpaque(false);
    useThemedDefaultIconsCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    UIManager.put(
                        SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS,
                        useThemedDefaultIconsCheckBox.isSelected() ? Boolean.TRUE : null);
                    mainFrame.repaint();
                  }
                });
          }
        });
    builder.append("Themed icons", useThemedDefaultIconsCheckBox);

    final JCheckBox useConstantThemesOnDialogs = new JCheckBox("use constant themes");
    useConstantThemesOnDialogs.setOpaque(false);
    useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel.isToUseConstantThemesOnDialogs());
    useConstantThemesOnDialogs.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(
                        useConstantThemesOnDialogs.isSelected());
                    SubstanceLookAndFeel.setSkin(
                        SubstanceLookAndFeel.getCurrentSkin(mainFrame.getRootPane()));
                  }
                });
          }
        });
    builder.append("Option pane icons", useConstantThemesOnDialogs);

    final JComboBox placementCombo = new JComboBox(new Object[] {"top", "bottom", "left", "right"});
    placementCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selected = (String) placementCombo.getSelectedItem();
            if ("top".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.TOP);
            if ("bottom".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
            if ("left".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.LEFT);
            if ("right".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.RIGHT);
          }
        });
    builder.append("Placement", placementCombo);

    try {
      final JComboBox overviewKindCombo =
          new FlexiComboBox<TabOverviewKind>(
              TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) {
            @Override
            public String getCaption(TabOverviewKind item) {
              return item.getName();
            }
          };
      overviewKindCombo.setSelectedItem(
          LafWidgetUtilities2.getTabPreviewPainter(mainTabbedPane).getOverviewKind(mainTabbedPane));
      overviewKindCombo.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              mainTabPreviewPainter.setTabOverviewKind(
                  (TabOverviewKind) overviewKindCombo.getSelectedItem());
            }
          });

      builder.append("Overview kind", overviewKindCombo);
    } catch (NoClassDefFoundError ignored) {
    }

    final JComboBox menuGutterFillCombo =
        new FlexiComboBox<MenuGutterFillKind>(
            MenuGutterFillKind.NONE,
            MenuGutterFillKind.SOFT,
            MenuGutterFillKind.HARD,
            MenuGutterFillKind.SOFT_FILL,
            MenuGutterFillKind.HARD_FILL) {
          @Override
          public String getCaption(MenuGutterFillKind item) {
            return item.name();
          }
        };
    menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD);
    menuGutterFillCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem());
          }
        });
    builder.append("Menu fill", menuGutterFillCombo);

    final JComboBox focusKindCombo =
        new FlexiComboBox<FocusKind>(FocusKind.values()) {
          @Override
          public String getCaption(FocusKind item) {
            return item.name();
          }
        };
    focusKindCombo.setSelectedItem(FocusKind.ALL_INNER);
    focusKindCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo.getSelectedItem());
          }
        });
    builder.append("Focus kind", focusKindCombo);

    JButton buttonGlassPane = new JButton("Show");
    buttonGlassPane.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final JPanel glassPane =
                new JPanel() {
                  @Override
                  public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Graphics2D graphics = (Graphics2D) g;
                    int height = getHeight();
                    int width = getWidth();
                    Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.4);
                    graphics.setComposite(c);
                    for (int i = 0; i < height; i++) {
                      Color color =
                          (i % 2 == 0) ? new Color(200, 200, 255) : new Color(230, 230, 255);
                      graphics.setColor(color);
                      graphics.drawLine(0, i, width, i);
                    }
                    Composite c2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 1.0);
                    graphics.setComposite(c2);
                  }
                };
            glassPane.setOpaque(false);
            glassPane.addMouseListener(new MouseAdapter() {});
            glassPane.addKeyListener(new KeyAdapter() {});
            mainFrame.setGlassPane(glassPane);
            new Thread() {
              @Override
              public void run() {
                glassPane.setVisible(true);
                try {
                  Thread.sleep(5000);
                } catch (InterruptedException ie) {
                  ie.printStackTrace();
                }
                glassPane.setVisible(false);
              }
            }.start();
          }
        });
    builder.append("Glass pane", buttonGlassPane);

    builder.appendSeparator("Custom animations");
    final JCheckBox allowFocusLoopAnimations = new JCheckBox("Allow animation");
    allowFocusLoopAnimations.setOpaque(false);
    allowFocusLoopAnimations.setSelected(
        AnimationConfigurationManager.getInstance()
            .isAnimationAllowed(AnimationFacet.FOCUS_LOOP_ANIMATION, null));
    allowFocusLoopAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowFocusLoopAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            }
          }
        });
    builder.append("Focus loop", allowFocusLoopAnimations);

    final JCheckBox allowGlowIconAnimations = new JCheckBox("Allow animation");
    allowGlowIconAnimations.setOpaque(false);
    allowGlowIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGlowIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance().allowAnimations(AnimationFacet.ICON_GLOW);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.ICON_GLOW);
            }
          }
        });
    builder.append("Icon glow", allowGlowIconAnimations);

    final JCheckBox allowGhostIconAnimations = new JCheckBox("Allow animation");
    allowGhostIconAnimations.setOpaque(false);
    allowGhostIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            }
          }
        });
    builder.append("Icon rollover", allowGhostIconAnimations);

    final JCheckBox allowGhostPressAnimations = new JCheckBox("Allow animation");
    allowGhostPressAnimations.setOpaque(false);
    allowGhostPressAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostPressAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            }
          }
        });
    builder.append("Button press", allowGhostPressAnimations);

    builder.appendSeparator("Toolbar");
    final JCheckBox isToolbarFlat = new JCheckBox("Is flat");
    isToolbarFlat.setOpaque(false);
    isToolbarFlat.setSelected(true);
    isToolbarFlat.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            toolbar.putClientProperty(
                SubstanceLookAndFeel.FLAT_PROPERTY, isToolbarFlat.isSelected());
            toolbar.repaint();
          }
        });
    builder.append("Flat", isToolbarFlat);

    builder.appendSeparator("Menu bar");
    final JCheckBox menuSearch = new JCheckBox("Has menu search");
    menuSearch.setOpaque(false);
    menuSearch.setSelected(false);
    menuSearch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(), menuSearch.isSelected(), SubstanceWidgetType.MENU_SEARCH);
          }
        });
    builder.append("Menu search", menuSearch);

    final JCheckBox menuLocale = new JCheckBox("Has custom locale");
    menuLocale.setOpaque(false);
    menuLocale.setSelected(false);
    menuLocale.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (menuLocale.isSelected()) {
              mainFrame.getJMenuBar().setLocale(Locale.FRENCH);
              mainFrame
                  .getJMenuBar()
                  .putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE);
            } else {
              mainFrame.getJMenuBar().putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, null);
            }
          }
        });
    builder.append("Menu locale", menuLocale);

    JPanel result = builder.getPanel();
    result.setName("Main control panel");
    return result;
  }