/** * Initialize the common user interface components. * * <p> */ protected JButton[] initUI( String title, JComponent extraComps, String confirm, String[][] extra, String cancel) { JButton[] extraBtns = null; /* create dialog body components */ { JPanel body = new JPanel(); body.setName("MainDialogPanel"); body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS)); body.add(UIFactory.createPanelLabel("Existing Layouts:")); body.add(Box.createRigidArea(new Dimension(0, 4))); { DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeData(), true); DefaultTreeModel model = new DefaultTreeModel(root, true); JTree tree = new JFancyTree(model); pTree = tree; tree.setName("DarkTree"); tree.setCellRenderer(new JLayoutTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); { JScrollPane scroll = UIFactory.createScrollPane( pTree, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, new Dimension(230, 120), new Dimension(230, 150), null); body.add(scroll); } } if (extraComps != null) body.add(extraComps); extraBtns = super.initUI(title, body, confirm, null, extra, cancel); } return extraBtns; }
/** * Creates and returns a Container containing the buttons. The buttons are created by calling * <code>getButtons</code>. */ protected Container createButtonArea() { JPanel bottom = new JPanel(); Border border = (Border) DefaultLookup.get(optionPane, this, "OptionPane.buttonAreaBorder"); bottom.setName("OptionPane.buttonArea"); if (border != null) { bottom.setBorder(border); } bottom.setLayout( new ButtonAreaLayout( DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true), DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6), DefaultLookup.getInt( optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER), DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false))); addButtonComponents(bottom, getButtons(), getInitialValueIndex()); return bottom; }
/** * Messaged from installComponents to create a Container containing the body of the message. The * icon is the created by calling <code>addIcon</code>. */ protected Container createMessageArea() { JPanel top = new JPanel(); Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder"); if (topBorder != null) { top.setBorder(topBorder); } top.setLayout(new BorderLayout()); /* Fill the body. */ Container body = new JPanel(new GridBagLayout()); Container realBody = new JPanel(new BorderLayout()); body.setName("OptionPane.body"); realBody.setName("OptionPane.realBody"); if (getIcon() != null) { JPanel sep = new JPanel(); sep.setName("OptionPane.separator"); sep.setPreferredSize(new Dimension(15, 1)); realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS); } realBody.add(body, BorderLayout.CENTER); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = cons.gridy = 0; cons.gridwidth = GridBagConstraints.REMAINDER; cons.gridheight = 1; cons.anchor = DefaultLookup.getInt( optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER); cons.insets = new Insets(0, 0, 3, 0); addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false); top.add(realBody, BorderLayout.CENTER); addIcon(top); return top; }
public MainFrame(String title) { super(title); setSize(WIDTH, HEIGHT); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); rootP = new JPanel(); rootP.setLayout(null); rootP.setName("root panel"); SelectionScreen s = new SelectionScreen(this); rootP .add(s) .setBounds( WIDTH / 2 - (s.getFinalWidth() / 2), HEIGHT / 2 - (s.getFinalHeight() / 2), s.getFinalWidth(), s.getFinalHeight()); add(rootP); setVisible(true); }
/** Construct a new dialog. */ public JArchiveDialog() { super("Archive Tool"); pPrivilegeDetails = new PrivilegeDetails(); /* create dialog body components */ { JPanel cpanel = new JPanel(); { cpanel.setName("ButtonDialogPanel"); cpanel.setLayout(new BoxLayout(cpanel, BoxLayout.Y_AXIS)); cpanel.add(UIFactory.createPanelLabel("Candidate Versions:")); cpanel.add(Box.createRigidArea(new Dimension(0, 4))); { ArchiveCandidateTableModel model = new ArchiveCandidateTableModel(); pCandidateTableModel = model; JTablePanel tpanel = new JTablePanel(model); pCandidateTablePanel = tpanel; cpanel.add(tpanel); } cpanel.add(Box.createRigidArea(new Dimension(0, 5))); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createHorizontalGlue()); hbox.add(Box.createRigidArea(new Dimension(10, 0))); { JButton btn = UIFactory.createDialogButton( "Search...", "candidate-search", this, "Search for new candidate checked-in versions to archive."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(20, 0))); { JButton btn = UIFactory.createDialogButton( "Clear", "clear-candidate", this, "Clear the displayed candidate checked-in versions."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(10, 0))); hbox.add(Box.createHorizontalGlue()); cpanel.add(hbox); } } JPanel apanel = new JPanel(); { apanel.setName("ButtonDialogPanel"); apanel.setLayout(new BoxLayout(apanel, BoxLayout.Y_AXIS)); { Box box = new Box(BoxLayout.X_AXIS); box.add(Box.createRigidArea(new Dimension(4, 0))); { JLabel label = new JLabel("Versions to Archive:"); label.setName("PanelLabel"); box.add(label); } box.add(Box.createHorizontalGlue()); { JLabel label = new JLabel("Total Size: ???"); pArchiveSizeLabel = label; label.setName("PanelLabel"); box.add(label); } box.add(Box.createRigidArea(new Dimension(23, 0))); apanel.add(box); } apanel.add(Box.createRigidArea(new Dimension(0, 4))); { NodeVersionSizeTableModel model = new NodeVersionSizeTableModel(880); pArchiveTableModel = model; JTablePanel tpanel = new JTablePanel(model); pArchiveTablePanel = tpanel; apanel.add(tpanel); } apanel.add(Box.createRigidArea(new Dimension(0, 5))); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createHorizontalGlue()); hbox.add(Box.createRigidArea(new Dimension(10, 0))); { JButton btn = UIFactory.createDialogButton( "Add", "add-archive", this, "Add the selected candidate versions to the list of versions to be " + "archived."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(10, 0))); { JButton btn = UIFactory.createDialogButton( "Add All", "add-all-archive", this, "Add all candidate versions to the list of versions to be archived."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(20, 0))); { JButton btn = UIFactory.createDialogButton( "Remove", "remove-archive", this, "Remove the selected versions from the list of versions to be archived."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(10, 0))); { JButton btn = UIFactory.createDialogButton( "Clear", "remove-all-archive", this, "Clear the list of versions to be archived."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(20, 0))); { JButton btn = UIFactory.createDialogButton( "Calc Sizes", "calc-archive", this, "Calculate the amount of disk space needed to archive the files " + "associated with the checked-in versions."); hbox.add(btn); } hbox.add(Box.createRigidArea(new Dimension(10, 0))); hbox.add(Box.createHorizontalGlue()); apanel.add(hbox); } } JSplitPane body = new JVertSplitPanel(cpanel, apanel); body.setAlignmentX(0.5f); String extra[][] = {{"Archive...", "archive"}}; JButton btns[] = super.initUI("Archive Tool:", body, null, null, extra, "Close", null); pArchiveButton = btns[0]; pArchiveButton.setEnabled(false); updatePanel(); pack(); } pQueryDialog = new JArchiveQueryDialog(this); pArchiveParamsDialog = new JArchiveParamsDialog(this); }
/** Sets the name of this editor. */ public final void setName(String name) { String oldName = getName(); super.setName(name); firePropertyChange("name", oldName, getName()); }
/** * Creates the appropriate object to represent <code>msg</code> and places it into <code>container * </code>. If <code>msg</code> is an instance of Component, it is added directly, if it is an * Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if * <code>d</code> is an Object[], this method will be recursively invoked for the children. <code> * internallyCreated</code> is true if Objc is an instance of Component and was created internally * by this method (this is used to correctly set hasCustomComponents only if !internallyCreated). */ protected void addMessageComponents( Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated) { if (msg == null) { return; } if (msg instanceof Component) { // To workaround problem where Gridbad will set child // to its minimum size if its preferred size will not fit // within allocated cells if (msg instanceof JScrollPane || msg instanceof JPanel) { cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; } else { cons.fill = GridBagConstraints.HORIZONTAL; } cons.weightx = 1; container.add((Component) msg, cons); cons.weightx = 0; cons.weighty = 0; cons.fill = GridBagConstraints.NONE; cons.gridy++; if (!internallyCreated) { hasCustomComponents = true; } } else if (msg instanceof Object[]) { Object[] msgs = (Object[]) msg; for (Object o : msgs) { addMessageComponents(container, cons, o, maxll, false); } } else if (msg instanceof Icon) { JLabel label = new JLabel((Icon) msg, SwingConstants.CENTER); configureMessageLabel(label); addMessageComponents(container, cons, label, maxll, true); } else { String s = msg.toString(); int len = s.length(); if (len <= 0) { return; } int nl; int nll = 0; if ((nl = s.indexOf(newline)) >= 0) { nll = newline.length(); } else if ((nl = s.indexOf("\r\n")) >= 0) { nll = 2; } else if ((nl = s.indexOf('\n')) >= 0) { nll = 1; } if (nl >= 0) { // break up newlines if (nl == 0) { JPanel breakPanel = new JPanel() { public Dimension getPreferredSize() { Font f = getFont(); if (f != null) { return new Dimension(1, f.getSize() + 2); } return new Dimension(0, 0); } }; breakPanel.setName("OptionPane.break"); addMessageComponents(container, cons, breakPanel, maxll, true); } else { addMessageComponents(container, cons, s.substring(0, nl), maxll, false); } addMessageComponents(container, cons, s.substring(nl + nll), maxll, false); } else if (len > maxll) { Container c = Box.createVerticalBox(); c.setName("OptionPane.verticalBox"); burstStringInto(c, s, maxll); addMessageComponents(container, cons, c, maxll, true); } else { JLabel label; label = new JLabel(s, JLabel.LEADING); label.setName("OptionPane.label"); configureMessageLabel(label); addMessageComponents(container, cons, label, maxll, true); } } }
/** Construct a new dialog. */ public JExecDetailsDialog() { super("Execution Details"); /* create dialog body components */ { JPanel body = new JPanel(); body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS)); { JPanel panel = new JPanel(); panel.setName("MainDialogPanel"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); /* working directory */ { panel.add(UIFactory.createPanelLabel("Working Directory:")); panel.add(Box.createRigidArea(new Dimension(0, 4))); JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT); pWorkingDirField = field; panel.add(field); } body.add(panel); } { JPanel panel = new JPanel(); panel.setName("HorizontalBar"); Dimension size = new Dimension(100, 7); panel.setPreferredSize(size); panel.setMinimumSize(size); panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7)); body.add(panel); } /* command line */ JPanel above = new JPanel(); { above.setName("MainDialogPanel"); above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS)); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createRigidArea(new Dimension(4, 0))); { JLabel label = new JLabel("X"); pCommandLineLabel = label; label.setName("PanelLabel"); hbox.add(label); } hbox.add(Box.createHorizontalGlue()); above.add(hbox); } above.add(Box.createRigidArea(new Dimension(0, 4))); { JTextArea area = new JTextArea(null, 5, 70); pCommandLineArea = area; area.setName("CodeTextArea"); area.setLineWrap(true); area.setWrapStyleWord(true); area.setEditable(false); } { JScrollPane scroll = UIFactory.createScrollPane( pCommandLineArea, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, new Dimension(100, 27), null, null); above.add(scroll); } } /* environment */ JPanel below = new JPanel(); { below.setName("MainDialogPanel"); below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS)); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createRigidArea(new Dimension(4, 0))); { JLabel label = new JLabel("X"); pEnvLabel = label; label.setName("PanelLabel"); hbox.add(label); } hbox.add(Box.createHorizontalGlue()); below.add(hbox); } below.add(Box.createRigidArea(new Dimension(0, 4))); Component comps[] = UIFactory.createTitledPanels(); { JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0))); vpanel.add(Box.createHorizontalGlue()); } { pEnvScroll = UIFactory.createScrollPane( comps[2], ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, new Dimension(100, 50), new Dimension(100, 300), null); below.add(pEnvScroll); } } { JVertSplitPanel split = new JVertSplitPanel(above, below); split.setResizeWeight(0.0); split.setAlignmentX(0.5f); body.add(split); } super.initUI("X", body, null, null, null, "Close", null); } }
void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField, String title) { InputMap im = panel.getInputMap(JComponent.WHEN_FOCUSED); ActionMap am = panel.getActionMap(); im.put(Globals.prefs.getKey("Entry editor, previous entry"), "prev"); am.put("prev", parent.prevEntryAction); im.put(Globals.prefs.getKey("Entry editor, next entry"), "next"); am.put("next", parent.nextEntryAction); im.put(Globals.prefs.getKey("Entry editor, store field"), "store"); am.put("store", parent.storeFieldAction); im.put(Globals.prefs.getKey("Entry editor, next panel"), "right"); im.put(Globals.prefs.getKey("Entry editor, next panel 2"), "right"); am.put("left", parent.switchLeftAction); im.put(Globals.prefs.getKey("Entry editor, previous panel"), "left"); im.put(Globals.prefs.getKey("Entry editor, previous panel 2"), "left"); am.put("right", parent.switchRightAction); im.put(Globals.prefs.getKey("Help"), "help"); am.put("help", parent.helpAction); im.put(Globals.prefs.getKey("Save database"), "save"); am.put("save", parent.saveDatabaseAction); im.put(Globals.prefs.getKey("Next tab"), "nexttab"); am.put("nexttab", parent.frame.nextTab); im.put(Globals.prefs.getKey("Previous tab"), "prevtab"); am.put("prevtab", parent.frame.prevTab); panel.setName(title); // String rowSpec = "left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref"; String colSpec = "fill:pref, 1dlu, fill:10dlu:grow, 1dlu, fill:pref, " + "8dlu, fill:pref, 1dlu, fill:10dlu:grow, 1dlu, fill:pref"; StringBuffer sb = new StringBuffer(); int rows = (int) Math.ceil((double) fields.length / 2.0); for (int i = 0; i < rows; i++) { sb.append("fill:pref:grow, "); } if (addKeyField) sb.append("4dlu, fill:pref"); else if (sb.length() >= 2) sb.delete(sb.length() - 2, sb.length()); String rowSpec = sb.toString(); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout(colSpec, rowSpec), panel); for (int i = 0; i < fields.length; i++) { // Create the text area: int editorType = BibtexFields.getEditorType(fields[i]); final FieldEditor ta; if (editorType == GUIGlobals.FILE_LIST_EDITOR) ta = new FileListEditor(frame, bPanel.metaData(), fields[i], null, parent); else ta = new FieldTextArea(fields[i], null); // ta.addUndoableEditListener(bPanel.undoListener); JComponent ex = parent.getExtra(fields[i], ta); // Add autocompleter listener, if required for this field: AbstractAutoCompleter autoComp = bPanel.getAutoCompleter(fields[i]); AutoCompleteListener acl = null; if (autoComp != null) { acl = new AutoCompleteListener(autoComp); } setupJTextComponent(ta.getTextComponent(), acl); ta.setAutoCompleteListener(acl); // Store the editor for later reference: editors.put(fields[i], ta); if (i == 0) activeField = ta; // System.out.println(fields[i]+": "+BibtexFields.getFieldWeight(fields[i])); // ta.getPane().setPreferredSize(new Dimension(100, // (int)(50.0*BibtexFields.getFieldWeight(fields[i])))); builder.append(ta.getLabel()); if (ex == null) builder.append(ta.getPane(), 3); else { builder.append(ta.getPane()); JPanel pan = new JPanel(); pan.setLayout(new BorderLayout()); pan.add(ex, BorderLayout.NORTH); builder.append(pan); } if (i % 2 == 1) builder.nextLine(); } // Add the edit field for Bibtex-key. if (addKeyField) { final FieldTextField tf = new FieldTextField( BibtexFields.KEY_FIELD, parent.getEntry().getField(BibtexFields.KEY_FIELD), true); // tf.addUndoableEditListener(bPanel.undoListener); setupJTextComponent(tf, null); editors.put("bibtexkey", tf); /* * If the key field is the only field, we should have only one * editor, and this one should be set as active initially: */ if (editors.size() == 1) activeField = tf; builder.nextLine(); builder.append(tf.getLabel()); builder.append(tf, 3); } }
private void createMainPanel() { panel = new JPanel(); panel.setName("Main Panel"); panel.setLayout(new BorderLayout()); }
/** * 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; }