public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JCheckBox checkbox = (JCheckBox) value; if (!UIUtil.isUnderNimbusLookAndFeel()) { checkbox.setBackground(getBackground(isSelected, checkbox)); checkbox.setForeground(getForeground(isSelected, checkbox)); } checkbox.setEnabled(isEnabled()); checkbox.setFont(getFont(checkbox)); checkbox.setFocusPainted(false); checkbox.setBorderPainted(true); checkbox.setBorder(isSelected ? mySelectedBorder : myBorder); adjustRendering(checkbox, isSelected, cellHasFocus); return checkbox; }
@Override public JComponent createComponent() { JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT)); myHighlightRecentlyChanged = new JCheckBox("Show changed in last"); myHighlightRecentlyChanged.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); myHighlightInterval = new JSpinner(new SpinnerNumberModel(1, 1, VcsContentAnnotationSettings.ourMaxDays, 1)); wrapper.add(myHighlightRecentlyChanged); wrapper.add(myHighlightInterval); wrapper.add(new JLabel("days")); myHighlightRecentlyChanged.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myHighlightInterval.setEnabled(myHighlightRecentlyChanged.isSelected()); } }); return wrapper; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (containerBox == null) { containerBox = Box.createHorizontalBox(); checkBox = new JCheckBox(); checkBox.setEnabled(isEnabled()); checkBox.setFont(getFont()); checkBox.setFocusPainted(false); checkBox.setBorderPainted(true); checkBox.setBorder( isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); containerBox.add(checkBox); } checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground()); checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground()); if (value != null) { ListItem item = (ListItem) value; checkBox.setText(item.dataItem.toString()); checkBox.setSelected(item.selected); } return containerBox; }
protected boolean exportApplicationPrompt() throws IOException, SketchException { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalStrut(6)); // Box panel = Box.createVerticalBox(); // Box labelBox = Box.createHorizontalBox(); // String msg = "<html>Click Export to Application to create a standalone, " + // "double-clickable application for the selected plaforms."; // String msg = "Export to Application creates a standalone, \n" + // "double-clickable application for the selected plaforms."; String line1 = "Export to Application creates double-clickable,"; String line2 = "standalone applications for the selected plaforms."; JLabel label1 = new JLabel(line1, SwingConstants.CENTER); JLabel label2 = new JLabel(line2, SwingConstants.CENTER); label1.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT); // label1.setAlignmentX(); // label2.setAlignmentX(0); panel.add(label1); panel.add(label2); int wide = label2.getPreferredSize().width; panel.add(Box.createVerticalStrut(12)); final JCheckBox windowsButton = new JCheckBox("Windows"); // windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); windowsButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean( "export.application.platform.windows", windowsButton.isSelected()); } }); final JCheckBox macosxButton = new JCheckBox("Mac OS X"); // macosxButton.setMnemonic(KeyEvent.VK_M); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); final JCheckBox linuxButton = new JCheckBox("Linux"); // linuxButton.setMnemonic(KeyEvent.VK_L); linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux")); linuxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected()); } }); JPanel platformPanel = new JPanel(); // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS)); platformPanel.add(windowsButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(macosxButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(linuxButton); platformPanel.setBorder(new TitledBorder("Platforms")); // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height); // platformPanel.setMaximumSize(goodIdea); wide = Math.max(wide, platformPanel.getPreferredSize().width); platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(platformPanel); // Box indentPanel = Box.createHorizontalBox(); // indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width)); final JCheckBox showStopButton = new JCheckBox("Show a Stop button"); // showStopButton.setMnemonic(KeyEvent.VK_S); showStopButton.setSelected(Preferences.getBoolean("export.application.stop")); showStopButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.stop", showStopButton.isSelected()); } }); showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen")); showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13)); // indentPanel.add(showStopButton); // indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT); final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)"); // fullscreenButton.setMnemonic(KeyEvent.VK_F); fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen")); fullScreenButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean sal = fullScreenButton.isSelected(); Preferences.setBoolean("export.application.fullscreen", sal); showStopButton.setEnabled(sal); } }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(fullScreenButton); optionPanel.add(showStopButton); // optionPanel.add(indentPanel); optionPanel.setBorder(new TitledBorder("Options")); wide = Math.max(wide, platformPanel.getPreferredSize().width); // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // optionPanel.setMaximumSize(goodIdea); panel.add(optionPanel); Dimension good; // label1, label2, platformPanel, optionPanel good = new Dimension(wide, label1.getPreferredSize().height); label1.setMaximumSize(good); good = new Dimension(wide, label2.getPreferredSize().height); label2.setMaximumSize(good); good = new Dimension(wide, platformPanel.getPreferredSize().height); platformPanel.setMaximumSize(good); good = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setMaximumSize(good); // JPanel actionPanel = new JPanel(); // optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); // optionPanel.add(Box.createHorizontalGlue()); // final JDialog frame = new JDialog(editor, "Export to Application"); // JButton cancelButton = new JButton("Cancel"); // cancelButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // frame.dispose(); // return false; // } // }); // Add the buttons in platform-specific order // if (PApplet.platform == PConstants.MACOSX) { // optionPanel.add(cancelButton); // optionPanel.add(exportButton); // } else { // optionPanel.add(exportButton); // optionPanel.add(cancelButton); // } String[] options = {"Export", "Cancel"}; final JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, // JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); final JDialog dialog = new JDialog(this, "Export Options", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setResizable(false); Rectangle bounds = getBounds(); dialog.setLocation( bounds.x + (bounds.width - dialog.getSize().width) / 2, bounds.y + (bounds.height - dialog.getSize().height) / 2); dialog.setVisible(true); Object value = optionPane.getValue(); if (value.equals(options[0])) { return jmode.handleExportApplication(sketch); } else if (value.equals(options[1]) || value.equals(new Integer(-1))) { // closed window by hitting Cancel or ESC statusNotice("Export to Application canceled."); } return false; }
protected FontOptions(@NotNull ColorAndFontOptions options, final String title) { setLayout(new MigLayout("ins 0, gap 5, flowx")); Insets borderInsets = new Insets( IdeBorderFactory.TITLED_BORDER_TOP_INSET, IdeBorderFactory.TITLED_BORDER_LEFT_INSET, 0, IdeBorderFactory.TITLED_BORDER_RIGHT_INSET); setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets)); myOptions = options; add(myOnlyMonospacedCheckBox, "sgx b, sx 2"); add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right"); add(myPrimaryCombo, "sgx b"); add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20"); add(myEditorFontSizeField); add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20"); add(myLineSpacingField); add( new JLabel( ApplicationBundle.message("label.fallback.fonts.list.description"), MessageType.INFO.getDefaultIcon(), SwingConstants.LEFT), "newline, sx 5"); add(myUseSecondaryFontCheckbox, "newline, ax right"); add(mySecondaryCombo, "sgx b"); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); myEnableLigaturesCheckbox.setBorder(null); panel.add(myEnableLigaturesCheckbox); myLigaturesInfoLinkLabel = new LinkLabel<Void>( ApplicationBundle.message("ligatures.more.info"), null, new LinkListener<Void>() { @Override public void linkSelected(LinkLabel aSource, Void aLinkData) { BrowserUtil.browse( "https://confluence.jetbrains.com/display/IDEADEV/Support+for+Ligatures+in+Editor"); } }); myLigaturesInfoLinkLabel.setBorder(new EmptyBorder(0, 5, 0, 0)); panel.add(myLigaturesInfoLinkLabel); add(panel, "newline, sx 2"); myOnlyMonospacedCheckBox.setBorder(null); myUseSecondaryFontCheckbox.setBorder(null); mySecondaryCombo.setEnabled(false); myOnlyMonospacedCheckBox.setSelected( EditorColorsManager.getInstance().isUseOnlyMonospacedFonts()); myOnlyMonospacedCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EditorColorsManager.getInstance() .setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected()); myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected()); mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected()); } }); myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected()); myPrimaryCombo.setRenderer(RENDERER); mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected()); mySecondaryCombo.setRenderer(RENDERER); myUseSecondaryFontCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected()); syncFontFamilies(); } }); ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { syncFontFamilies(); } } }; myPrimaryCombo.addItemListener(itemListener); mySecondaryCombo.addItemListener(itemListener); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { syncFontFamilies(); } }; myPrimaryCombo.addActionListener(actionListener); mySecondaryCombo.addActionListener(actionListener); myEditorFontSizeField .getDocument() .addDocumentListener( new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return; String selectedFont = myPrimaryCombo.getFontName(); if (selectedFont != null) { FontPreferences fontPreferences = getFontPreferences(); fontPreferences.register(selectedFont, getFontSizeFromField()); } updateDescription(true); } }); myEditorFontSizeField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return; boolean up = e.getKeyCode() == KeyEvent.VK_UP; try { int value = Integer.parseInt(myEditorFontSizeField.getText()); value += (up ? 1 : -1); value = Math.min( OptionsConstants.MAX_EDITOR_FONT_SIZE, Math.max(OptionsConstants.MIN_EDITOR_FONT_SIZE, value)); myEditorFontSizeField.setText(String.valueOf(value)); } catch (NumberFormatException ignored) { } } }); myLineSpacingField .getDocument() .addDocumentListener( new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { if (myIsInSchemeChange) return; float lineSpacing = getLineSpacingFromField(); if (getLineSpacing() != lineSpacing) { setCurrentLineSpacing(lineSpacing); } updateDescription(true); } }); myLineSpacingField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return; boolean up = e.getKeyCode() == KeyEvent.VK_UP; try { float value = Float.parseFloat(myLineSpacingField.getText()); value += (up ? 1 : -1) * .1F; value = Math.min( OptionsConstants.MAX_EDITOR_LINE_SPACING, Math.max(OptionsConstants.MIN_EDITOR_LINE_SPACING, value)); myLineSpacingField.setText(String.format(Locale.ENGLISH, "%.1f", value)); } catch (NumberFormatException ignored) { } } }); myEnableLigaturesCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getFontPreferences().setUseLigatures(myEnableLigaturesCheckbox.isSelected()); } }); }
public SceneLayoutApp() { super(); new Pair(); final JFrame frame = new JFrame("Scene Layout"); final JPanel panel = new JPanel(new BorderLayout()); frame.setContentPane(panel); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setMaximumSize(screenSize); frame.setSize(screenSize); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JMenuBar mb = new JMenuBar(); frame.setJMenuBar(mb); final JMenu jMenu = new JMenu("File"); mb.add(jMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Help")); JMenu menu = new JMenu("Look and Feel"); // // Get all the available look and feel that we are going to use for // creating the JMenuItem and assign the action listener to handle // the selection of menu item to change the look and feel. // UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lookAndFeelInfos.length; i++) { final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i]; JMenuItem item = new JMenuItem(lookAndFeelInfo.getName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { // // Set the look and feel for the frame and update the UI // to use a new selected look and feel. // UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } }); menu.add(item); } mb.add(menu); jMenu.add(new JMenuItem(new scene.action.QuitAction())); panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER); final JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); final JComboBox comboNewWindow = new JComboBox( new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"}); comboNewWindow.addActionListener(new CreateSceneWindowAction()); comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window")); bar.add(comboNewWindow); bar.add( new AbstractAction("Progress Bars") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new ProgressBarAnimator(); } }); bar.add( new AbstractAction("Sliders") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new SliderBarAnimator(); } }); final JCheckBox permaViz = new JCheckBox(); permaViz.setText("Show the dump window"); permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); dumpWindow = new JInternalFrame("perma dump window"); dumpWindow.setContentPane(new JScrollPane(permText)); permaViz.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dumpWindow.setVisible(permaViz.isSelected()); } }); comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize()); permaViz.setSelected(false); bar.add(new CreateWebViewV1Action()); bar.add(new CreateWebViewV2Action()); bar.add(permaViz); desktopPane.add(dumpWindow); dumpWindow.setSize(400, 400); dumpWindow.setResizable(true); dumpWindow.setClosable(false); dumpWindow.setIconifiable(false); final JMenuBar m = new JMenuBar(); final JMenu cmenu = new JMenu("Create"); m.add(cmenu); final JMenuItem menuItem = new JMenuItem( new AbstractAction("new") { @Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { Object[] in = (Object[]) XSTREAM.fromXML(permText.getText()); final JInternalFrame ff = new JInternalFrame(); final ScenePanel c = new ScenePanel(); ff.setContentPane(c); desktopPane.add(ff); final Dimension d = (Dimension) in[0]; c.setMaximumSize(d); c.setPreferredSize(d); ff.setSize(d.width + 50, d.height + 50); ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]); c.invalidate(); c.repaint(); ff.pack(); ff.setClosable(true); ff.setMaximizable(false); ff.setIconifiable(false); ff.setResizable(false); ff.show(); } }; SwingUtilities.invokeLater(runnable); } }); cmenu.add(menuItem); // JMenuBar menuBar = new JMenuBar(); // getContentPane().add(menuBar); dumpWindow.setJMenuBar(m); frame.setVisible(true); }