Example usage for javax.swing JScrollPane setBorder

List of usage examples for javax.swing JScrollPane setBorder

Introduction

In this page you can find the example usage for javax.swing JScrollPane setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Box topPanel = Box.createHorizontalBox();
    topPanel.add(new JLabel("Select Character:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(characterBox);/*ww  w  .  j  av a 2s  .  c o  m*/
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(partyBox);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(Box.createHorizontalStrut(50));
    topPanel.add(new JLabel("Export to:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(exportBox);
    contentPane.add(topPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(fileList);
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"),
            scrollPane.getBorder()));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    Box bottomPanel = Box.createHorizontalBox();
    bottomPanel.add(progressBar);
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(exportButton);
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(closeButton);
    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pack();
}

From source file:pcgen.gui2.tabs.SummaryInfoTab.java

/**
 * Initialise the "Things to be Done" panel. Creates the required components
 * and places them in the panel.//from w w  w .  ja va  2 s . c o m
 *
 * @param panel The panel to be initialised
 */
private void initTodoPanel(JPanel panel) {
    panel.setLayout(new BorderLayout());
    todoPane.setOpaque(false);
    todoPane.setContentType("text/html"); //$NON-NLS-1$
    todoPane.setEditable(false);

    JScrollPane scroll = new JScrollPane(todoPane);
    scroll.setBorder(BorderFactory.createEmptyBorder());

    panel.add(scroll, BorderLayout.CENTER);
}

From source file:pcgen.gui2.tabs.SummaryInfoTab.java

private void initMiddlePanel(JPanel middlePanel) {
    middlePanel.setLayout(new GridLayout(2, 1));

    JPanel statsPanel = new JPanel();
    setPanelTitle(statsPanel, LanguageBundle.getString("in_sumAbilityScores")); //$NON-NLS-1$
    statsPanel.setLayout(new BoxLayout(statsPanel, BoxLayout.Y_AXIS));

    StatTableModel.initializeTable(statsTable);
    JScrollPane pane = new JScrollPane(statsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) {

        @Override//from  w  ww.  j  a  v  a2  s .co m
        public Dimension getMaximumSize() {
            //This prevents the scroll pane from taking up more space than it needs.
            return super.getPreferredSize();
        }

    };
    pane.setBorder(BorderFactory.createEmptyBorder());
    JPanel statsBox = new JPanel();
    statsBox.setLayout(new BoxLayout(statsBox, BoxLayout.X_AXIS));
    statsBox.add(Box.createHorizontalGlue());
    statsBox.add(pane);
    statsBox.add(Box.createHorizontalGlue());
    statsPanel.add(statsBox);

    JPanel statTotalPanel = new JPanel();
    statTotalPanel.setLayout(new BoxLayout(statTotalPanel, BoxLayout.X_AXIS));
    //this makes box layout use the statTotalPanel to distribute extra space
    statTotalPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    statTotalPanel.add(Box.createHorizontalGlue());
    FontManipulation.title(statTotalLabel);
    statTotalPanel.add(statTotalLabel);
    statTotalPanel.add(statTotal);
    FontManipulation.title(modTotalLabel);
    statTotalPanel.add(modTotalLabel);
    statTotalPanel.add(modTotal);
    statTotalPanel.add(Box.createHorizontalGlue());
    generateRollsButton.setText(LanguageBundle.getString("in_sumGenerate_Rolls")); //$NON-NLS-1$
    statTotalPanel.add(generateRollsButton);
    rollMethodButton.setText(LanguageBundle.getString("in_sumRoll_Method")); //$NON-NLS-1$
    statTotalPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    statTotalPanel.add(rollMethodButton);
    statTotalPanel.add(Box.createHorizontalGlue());
    statsPanel.add(statTotalPanel);

    middlePanel.add(statsPanel);

    InfoPaneHandler.initializeEditorPane(infoPane);

    pane = new JScrollPane(infoPane);
    setPanelTitle(pane, LanguageBundle.getString("in_sumStats")); //$NON-NLS-1$
    middlePanel.add(pane);
}

From source file:picocash.components.AccountPanel.java

protected JScrollPane createTransactionScrollPane(ListModel listModel) {
    final JXList transactionList = new JXList(listModel);
    transactionList.setBackground(TRANSPARENT_LIST_BACKGROUND);
    transactionList.setCellRenderer(new DefaultListRenderer(new TransactionProvider()));
    transactionList.setRolloverEnabled(true);
    transactionList.addHighlighter(/*from   w  ww.  j a v a  2s  . co m*/
            new TransactionPainterHighlighter(HighlightPredicate.ALWAYS, new MattePainter(Color.WHITE)));
    transactionList.addHighlighter(
            new TransactionPainterHighlighter(HighlightPredicate.ROLLOVER_ROW, new PinstripePainter()));

    final JScrollPane scrollPane = new JScrollPane(transactionList);

    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    transactionList.setOpaque(true);
    scrollPane.setOpaque(true);

    return scrollPane;
}

From source file:pl.kotcrab.arget.gui.ContactsPanel.java

public ContactsPanel(final Profile profile, MainWindowCallback callback) {
    this.profile = profile;

    setLayout(new BorderLayout());

    table = new JTable(new ContactsTableModel(profile.contacts));

    table.setDefaultRenderer(ContactInfo.class, new ContactsTableEditor(table, callback));
    table.setDefaultEditor(ContactInfo.class, new ContactsTableEditor(table, callback));
    table.setShowGrid(false);//from  w  w  w . j a  va  2  s  .  com
    table.setTableHeader(null);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setRowHeight(40);

    final JPopupMenu popupMenu = new JPopupMenu();

    {
        JMenuItem menuModify = new JMenuItem("Modify");
        JMenuItem menuDelete = new JMenuItem("Delete");

        popupMenu.add(menuModify);
        popupMenu.add(menuDelete);

        menuModify.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String key = Base64.encodeBase64String(profile.rsa.getPublicKey().getEncoded());
                new CreateContactDialog(MainWindow.instance, key,
                        (ContactInfo) table.getValueAt(table.getSelectedRow(), 0));
                ProfileIO.saveProfile(profile);
                updateContactsTable();
            }
        });

        menuDelete.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ContactInfo contact = (ContactInfo) table.getValueAt(table.getSelectedRow(), 0);

                if (contact.status == ContactStatus.CONNECTED_SESSION) {
                    JOptionPane.showMessageDialog(MainWindow.instance,
                            "This contact cannot be deleted because session is open.", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                int result = JOptionPane.showConfirmDialog(MainWindow.instance,
                        "Are you sure you want to delete '" + contact.name + "'?", "Warning",
                        JOptionPane.YES_NO_OPTION);

                if (result == JOptionPane.NO_OPTION || result == JOptionPane.CLOSED_OPTION)
                    return;

                profile.contacts.remove(contact);
                ProfileIO.saveProfile(profile);
                updateContactsTable();
            }
        });
    }

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), table);

                int rowNumber = table.rowAtPoint(p);
                table.editCellAt(rowNumber, 0);
                table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber);

                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    JScrollPane tableScrollPane = new JScrollPane(table);
    tableScrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));

    add(tableScrollPane, BorderLayout.CENTER);
}

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

/**
 * create a new instance of XslTree The nodes will be automaticaly
 * duplicated if the schema specify that more than one element of this type
 * are mandatory/*  www  .jav a2s  .  c  o m*/
 */
public XsdTreePanelImpl(XsdTreeStructImpl xsdTree, JTextPane messagePane) {
    super(xsdTree);

    messagePane.setEditable(false);

    JScrollPane scrollpane = new JScrollPane(messagePane);
    scrollpane.setMaximumSize(new Dimension(Short.MAX_VALUE, 150));
    scrollpane.setMinimumSize(new Dimension(200, 150));
    scrollpane.setPreferredSize(new Dimension(200, 150));
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.setBorder(new TitledBorder("Messages"));

    add(scrollpane, BorderLayout.SOUTH);
    add(getButtonPanel(), BorderLayout.EAST);
    MouseListener mouseListener = new TreeMouseAdapter();
    xsdTree.tree.addMouseListener(mouseListener);
}

From source file:savant.view.swing.Frame.java

/**
 * Construct a new Frame for holding a track.
 *
 * @param df the DataFormat, so the frame can do any format-specific
 * initialisation (e.g. smaller height for sequence tracks)
 *///from w  w  w .  java  2 s .c  o m
public Frame(DataFormat df) {
    super(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    sequence = df == DataFormat.SEQUENCE;

    // Component which displays the legend component.
    legend = new JComponent() {
        @Override
        public Dimension getPreferredSize() {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    return d;
                }
            }
            return new Dimension(0, 0);
        }

        @Override
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        @Override
        public void paintComponent(Graphics g) {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    Graphics2D g2 = (Graphics2D) g;
                    GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 60, new Color(230, 230, 230));
                    g2.setPaint(gp);
                    g2.fillRect(0, 0, d.width, d.height);

                    g2.setColor(Color.BLACK);
                    g2.draw(new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1));
                    t.getRenderer().drawLegend(g2, t.getDrawingMode());
                    return;
                }
            }
        }
    };
    legend.setVisible(false);

    frameLandscape = new JLayeredPane();

    //add graphPane -> jlp -> scrollPane
    jlp = new JLayeredPane();
    jlp.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = 0;

    //scrollpane
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setWheelScrollingEnabled(false);
    scrollPane.setBorder(null);

    graphPane = new GraphPane(this);
    jlp.add(graphPane, gbc, 0);

    scrollPane.getViewport().add(jlp);

    //GRID FRAMEWORK AND COMPONENT ADDING...
    frameLandscape.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    //add sidepanel
    sidePanel = new JPanel() {
        @Override
        public Dimension getMinimumSize() {
            return new Dimension(0, 0);
        }
    };
    sidePanel.setLayout(new GridBagLayout());
    sidePanel.setOpaque(false);
    sidePanel.setVisible(false);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 16); // Leave 16 pixels so that we don't sit on top of the scroll-bar.
    frameLandscape.setLayer(sidePanel, JLayeredPane.PALETTE_LAYER);
    frameLandscape.add(sidePanel, c);

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            Dimension dim = getSize();
            if (dim != null) {
                // TODO: The following shouldn't be necessary, but it seems to be.
                int expectedWidth = frameLandscape.getWidth();
                if (expectedWidth != graphPane.getWidth()) {
                    Dimension goodSize = new Dimension(expectedWidth, graphPane.getHeight());
                    graphPane.setPreferredSize(goodSize);
                    graphPane.setSize(goodSize);
                }

                setLegendVisible(true);
            }
        }
    });

    //add graphPane to all cells
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(0, 0, 0, 0);

    frameLandscape.setLayer(scrollPane, JLayeredPane.DEFAULT_LAYER);
    frameLandscape.add(scrollPane, c);

    // Add our progress-panel.  If setTracks is called promptly, it will be cleared
    // away before it ever has a chance to draw.
    getContentPane().add(new ProgressPanel(null), BorderLayout.CENTER);
}

From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java

public JPanel getDetailsPanel() {
    if (detailsPanel == null) {
        detailsPanel = new JPanel(new GridLayout(5, 1));
        JScrollPane aux = new JScrollPane();
        aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Description")));
        aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        aux.setViewportView(getDescriptionPanel());
        detailsPanel.add(aux);//from  w  w w  .  ja  v  a  2s  .  c o m

        aux = new JScrollPane();
        aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Purpose")));
        aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        aux.setViewportView(getPurposePanel());
        detailsPanel.add(aux);

        aux = new JScrollPane();
        aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Use")));
        aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        aux.setViewportView(getUsePanel());
        detailsPanel.add(aux);

        aux = new JScrollPane();
        aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Misuse")));
        aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        aux.setViewportView(getMisusePanel());
        detailsPanel.add(aux);

        aux = new JScrollPane();
        aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("References")));
        aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        aux.setViewportView(getReferencePanel());
        detailsPanel.add(aux);
    }
    return detailsPanel;
}

From source file:tvbrowser.extras.reminderplugin.ReminderSettingsTab.java

/**
 * Creates the settings panel for this tab.
 *///  www. j  a va2 s.  c  o  m
public JPanel createSettingsPanel() {
    FormLayout layout = new FormLayout("5dlu,pref,5dlu,pref,pref:grow,3dlu,pref,3dlu,pref,5dlu",
            "pref,5dlu,pref,1dlu,pref,1dlu,pref,1dlu,pref,10dlu,pref,5dlu,"
                    + "pref,10dlu,pref,5dlu,pref,10dlu,pref,5dlu,pref,10dlu,"
                    + "pref,5dlu,pref,3dlu,pref,10dlu,pref,5dlu,pref");
    layout.setColumnGroups(new int[][] { { 7, 9 } });
    PanelBuilder pb = new PanelBuilder(layout, new ScrollableJPanel());
    pb.setDefaultDialogBorder();

    CellConstraints cc = new CellConstraints();

    final String[] extArr = { ".wav", ".aif", ".rmf", ".au", ".mid" };
    String soundFName = mSettings.getProperty("soundfile", "/");
    String msg = mLocalizer.msg("soundFileFilter", "Sound file ({0})", "*" + StringUtils.join(extArr, ", *"));

    mReminderWindowChB = new JCheckBox(mLocalizer.msg("reminderWindow", "Reminder window"),
            mSettings.getProperty("usemsgbox", "false").equalsIgnoreCase("true"));

    mShowAlwaysOnTop = new JCheckBox(mLocalizer.msg("alwaysOnTop", "Show always on top"),
            mSettings.getProperty("alwaysOnTop", "true").equalsIgnoreCase("true"));
    mShowAlwaysOnTop.setEnabled(mReminderWindowChB.isSelected());

    JPanel reminderWindowCfg = new JPanel(new FormLayout("12dlu,default:grow", "pref,1dlu,pref"));
    reminderWindowCfg.add(mReminderWindowChB, cc.xyw(1, 1, 2));
    reminderWindowCfg.add(mShowAlwaysOnTop, cc.xy(2, 3));

    mSoundFileChB = new FileCheckBox(mLocalizer.msg("playlingSound", "Play sound"), new File(soundFName), 0,
            false);

    JFileChooser soundChooser = new JFileChooser((String) null);
    soundChooser.setFileFilter(new ExtensionFileFilter(extArr, msg));

    mSoundFileChB.setFileChooser(soundChooser);

    mSoundFileChB.setSelected(mSettings.getProperty("usesound", "false").equals("true"));

    mBeep = new JCheckBox(mLocalizer.msg("beep", "Speaker sound"),
            mSettings.getProperty("usebeep", "true").equalsIgnoreCase("true"));

    mExecFileStr = mSettings.getProperty("execfile", "");
    mExecParamStr = mSettings.getProperty("execparam", "");

    final JButton soundTestBt = new JButton(mLocalizer.msg("test", "Test"));

    mExecChB = new JCheckBox(mLocalizer.msg("executeProgram", "Execute program"));
    mExecChB.setSelected(mSettings.getProperty("useexec", "false").equals("true"));

    mExecFileDialogBtn = new JButton(mLocalizer.msg("executeConfig", "Configure"));
    mExecFileDialogBtn.setEnabled(mExecChB.isSelected());

    mPluginLabel = new JLabel();
    JButton choose = new JButton(mLocalizer.msg("selectPlugins", "Choose Plugins"));

    mClientPluginTargets = ReminderPlugin.getInstance().getClientPluginsTargets();

    handlePluginSelection();

    choose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
                PluginChooserDlg chooser = null;
                chooser = new PluginChooserDlg(parent, mClientPluginTargets, null,
                        ReminderPluginProxy.getInstance());

                chooser.setLocationRelativeTo(parent);
                chooser.setVisible(true);

                if (chooser.getReceiveTargets() != null) {
                    mClientPluginTargets = chooser.getReceiveTargets();
                }

                handlePluginSelection();
            } catch (Exception ee) {
                ee.printStackTrace();
            }
        }
    });

    int autoCloseReminderTime = 10;
    try {
        String asString = mSettings.getProperty("autoCloseReminderTime", "10");
        autoCloseReminderTime = Integer.parseInt(asString);

        if (autoCloseReminderTime == 0) {
            autoCloseReminderTime = 10;
        }
    } catch (Exception exc) {
        // ignore
    }

    mCloseOnEnd = new JRadioButton(mLocalizer.msg("autoCloseReminderAtProgramEnd", "Program end"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onEnd"));
    mCloseOnEnd.setEnabled(mReminderWindowChB.isSelected());

    mCloseNever = new JRadioButton(mLocalizer.msg("autoCloseNever", "Never close"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("never"));
    mCloseNever.setEnabled(mReminderWindowChB.isSelected());

    mCloseOnTime = new JRadioButton(mLocalizer.ellipsisMsg("autoCloseAfterTime", "After time"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onTime"));
    mCloseOnTime.setEnabled(mReminderWindowChB.isSelected());

    ButtonGroup bg = new ButtonGroup();

    bg.add(mCloseOnEnd);
    bg.add(mCloseNever);
    bg.add(mCloseOnTime);

    mAutoCloseReminderTimeSp = new JSpinner(
            new SpinnerNumberModel(autoCloseReminderTime, autoCloseReminderTime < 5 ? 1 : 5, 600, 1));
    mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected());

    mShowTimeCounter = new JCheckBox(mLocalizer.msg("showTimeCounter", "Show time counter"),
            mSettings.getProperty("showTimeCounter", "false").compareTo("true") == 0);
    mShowTimeCounter.setEnabled(!mCloseNever.isSelected() && mReminderWindowChB.isSelected());

    PanelBuilder autoClosePanel = new PanelBuilder(
            new FormLayout("12dlu,default,2dlu,default:grow", "pref,2dlu,pref,2dlu,pref,2dlu,pref,10dlu,pref"));
    autoClosePanel.add(mCloseOnEnd, cc.xyw(1, 1, 4));
    autoClosePanel.add(mCloseNever, cc.xyw(1, 3, 4));
    autoClosePanel.add(mCloseOnTime, cc.xyw(1, 5, 4));
    autoClosePanel.add(mAutoCloseReminderTimeSp, cc.xy(2, 7));

    final JLabel secondsLabel = autoClosePanel.addLabel(mLocalizer.msg("seconds", "seconds (0 = off)"),
            cc.xy(4, 7));

    autoClosePanel.add(mShowTimeCounter, cc.xyw(1, 9, 4));

    secondsLabel.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected());

    String defaultReminderEntryStr = (String) mSettings.get("defaultReminderEntry");
    mDefaultReminderEntryList = new JComboBox(ReminderDialog.SMALL_REMIND_MSG_ARR);
    if (defaultReminderEntryStr != null) {
        try {
            int inx = Integer.parseInt(defaultReminderEntryStr);
            if (inx < ReminderDialog.SMALL_REMIND_MSG_ARR.length) {
                mDefaultReminderEntryList.setSelectedIndex(inx);
            }
        } catch (NumberFormatException e) {
            // ignore
        }
    }

    mShowTimeSelectionDlg = new JCheckBox(
            mLocalizer.msg("showTimeSelectionDialog", "Show time selection dialog"));
    mShowTimeSelectionDlg
            .setSelected(mSettings.getProperty("showTimeSelectionDialog", "true").compareTo("true") == 0);
    mShowRemovedDlg = new JCheckBox(
            mLocalizer.msg("showRemovedDialog", "Show removed reminders after data update"));
    mShowRemovedDlg.setSelected(mSettings.getProperty("showRemovedDialog", "true").compareTo("true") == 0);

    pb.addSeparator(mLocalizer.msg("remindBy", "Remind me by"), cc.xyw(1, 1, 10));

    pb.add(reminderWindowCfg, cc.xyw(2, 3, 4));
    pb.add(mSoundFileChB, cc.xyw(2, 5, 4));
    pb.add(mSoundFileChB.getButton(), cc.xy(7, 5));
    pb.add(soundTestBt, cc.xy(9, 5));
    pb.add(mBeep, cc.xy(2, 7));
    pb.add(mExecChB, cc.xyw(2, 9, 4));
    pb.add(mExecFileDialogBtn, cc.xyw(7, 9, 3));

    pb.addSeparator(mLocalizer.msg("sendToPlugin", "Send reminded program to"), cc.xyw(1, 11, 10));

    pb.add(mPluginLabel, cc.xyw(2, 13, 4));
    pb.add(choose, cc.xyw(7, 13, 3));

    final JLabel c = (JLabel) pb
            .addSeparator(mLocalizer.msg("autoCloseReminder", "Automatically close reminder"),
                    cc.xyw(1, 15, 10))
            .getComponent(0);
    c.setEnabled(mReminderWindowChB.isSelected());

    pb.add(autoClosePanel.getPanel(), cc.xyw(2, 17, 5));

    JPanel reminderEntry = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    reminderEntry.add(mDefaultReminderEntryList);

    pb.addSeparator(mLocalizer.msg("defaltReminderEntry", "Default reminder time"), cc.xyw(1, 19, 10));
    pb.add(reminderEntry, cc.xyw(2, 21, 4));

    pb.addSeparator(mLocalizer.msg("miscSettings", "Misc settings"), cc.xyw(1, 23, 10));
    pb.add(mShowTimeSelectionDlg, cc.xyw(2, 25, 7));
    pb.add(mShowRemovedDlg, cc.xyw(2, 27, 7));

    pb.addSeparator(DefaultMarkingPrioritySelectionPanel.getTitle(), cc.xyw(1, 29, 10));
    pb.add(mMarkingsPanel = DefaultMarkingPrioritySelectionPanel
            .createPanel(ReminderPlugin.getInstance().getMarkPriority(), false, false), cc.xyw(2, 31, 9));

    mReminderWindowChB.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mShowAlwaysOnTop.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            c.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            secondsLabel.setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected());
            mCloseOnEnd.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mCloseNever.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mCloseOnTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED && !mCloseNever.isSelected());
            mAutoCloseReminderTimeSp
                    .setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected());
        }
    });

    soundTestBt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (evt.getActionCommand().compareTo(mLocalizer.msg("test", "Test")) == 0) {
                mTestSound = ReminderPlugin.playSound(mSoundFileChB.getTextField().getText());
                if (mTestSound != null) {
                    soundTestBt.setText(mLocalizer.msg("stop", "Stop"));
                }
                if (mTestSound != null) {
                    if (mTestSound instanceof SourceDataLine) {
                        ((SourceDataLine) mTestSound).addLineListener(new LineListener() {
                            public void update(LineEvent event) {
                                if (event.getType() == Type.CLOSE) {
                                    soundTestBt.setText(mLocalizer.msg("test", "Test"));
                                }
                            }
                        });
                    } else if (mTestSound instanceof Sequencer) {
                        new Thread("Test MIDI sound") {
                            public void run() {
                                setPriority(Thread.MIN_PRIORITY);
                                while (((Sequencer) mTestSound).isRunning()) {
                                    try {
                                        Thread.sleep(100);
                                    } catch (Exception ee) {
                                    }
                                }

                                soundTestBt.setText(mLocalizer.msg("test", "Test"));
                            }
                        }.start();
                    }
                }
            } else if (mTestSound != null) {
                if (mTestSound instanceof SourceDataLine && ((SourceDataLine) mTestSound).isRunning()) {
                    ((SourceDataLine) mTestSound).stop();
                } else if (mTestSound instanceof Sequencer && ((Sequencer) mTestSound).isRunning()) {
                    ((Sequencer) mTestSound).stop();
                }
            }
        }
    });

    mSoundFileChB.getCheckBox().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            soundTestBt.setEnabled(mSoundFileChB.isSelected());
        }
    });

    mSoundFileChB.getTextField().addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            String text = mSoundFileChB.getTextField().getText();
            if ((new File(text)).isFile()) {
                boolean notFound = true;
                for (String extension : extArr) {
                    if (StringUtils.endsWithIgnoreCase(text, extension)) {
                        notFound = false;
                        break;
                    }
                }

                if (notFound) {
                    soundTestBt.setEnabled(false);
                } else {
                    soundTestBt.setEnabled(true);
                }
            } else {
                soundTestBt.setEnabled(false);
            }
        }
    });
    mSoundFileChB.getTextField().getKeyListeners()[0].keyReleased(null);

    mExecChB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            mExecFileDialogBtn.setEnabled(mExecChB.isSelected());
            if (mExecFileDialogBtn.isEnabled()) {
                showFileSettingsDialog();
            }
        }
    });

    mExecFileDialogBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showFileSettingsDialog();
        }
    });

    ItemListener autoCloseListener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected());
            secondsLabel.setEnabled(mCloseOnTime.isSelected());
            mShowTimeCounter.setEnabled(mCloseOnTime.isSelected() || mCloseOnEnd.isSelected());
        }
    };

    mCloseOnEnd.addItemListener(autoCloseListener);
    mCloseOnTime.addItemListener(autoCloseListener);

    mCloseOnTime.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JScrollPane scrollPane = new JScrollPane(pb.getPanel());
    scrollPane.setBorder(null);
    scrollPane.setViewportBorder(null);

    JPanel scrollPanel = new JPanel(new FormLayout("default:grow", "default"));
    scrollPanel.add(scrollPane, cc.xy(1, 1));

    return scrollPanel;
}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override/*from w  ww  .jav a  2 s. c o  m*/
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}