Search in sources :

Example 61 with JDialog

use of javax.swing.JDialog in project sling by apache.

the class Util method showStartupDialog.

static JTextPane showStartupDialog(final String title, final Dimension screenSize) {
    JTextPane text = new JTextPane();
    text.setText("...");
    JDialog d = new JDialog((Window) null);
    d.setTitle(title);
    d.add(text);
    d.setSize((int) screenSize.getWidth() / 2, 30);
    d.setLocation((int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 2 - 15);
    d.setVisible(true);
    return text;
}
Also used : JTextPane(javax.swing.JTextPane) JDialog(javax.swing.JDialog)

Example 62 with JDialog

use of javax.swing.JDialog in project sling by apache.

the class RequestListSelectionListener method valueChanged.

public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
        int idx = lsm.getMinSelectionIndex();
        if (idx >= 0) {
            try {
                idx = table.getRowSorter().convertRowIndexToModel(idx);
                TableModel tm = ((RequestTrackerFile) table.getModel()).getData(idx);
                if (dataField == null) {
                    dataField = new JTable();
                    dataField.setAutoCreateRowSorter(true);
                    dataField.setGridColor(Color.GRAY);
                    dataField.setShowGrid(true);
                    dataField.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    dataField.setRowSelectionAllowed(true);
                    dataField.setTableHeader(new JTableHeader(dataField.getColumnModel()));
                    dataField.setFont(new Font("Monospaced", dataField.getFont().getStyle(), dataField.getFont().getSize()));
                    dataField.setShowHorizontalLines(false);
                    //                        dataField.setIntercellSpacing(new Dimension(3, 5));
                    JDialog d = new JDialog(this.parent);
                    d.add(new JScrollPane(dataField));
                    d.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            dataField = null;
                        }
                    });
                    // setup location and size and ensure updating preferences
                    Util.setupComponentLocationSize(d, REQUEST_X, REQUEST_Y, REQUEST_WIDTH, REQUEST_HEIGHT, (int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 4, (int) screenSize.getWidth() / 2, (int) screenSize.getHeight() / 2);
                    d.setVisible(true);
                }
                dataField.setModel(tm);
                Util.setupColumnWidths(dataField.getColumnModel(), REQUEST_COLS);
            } catch (IOException e1) {
            // ignore
            }
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ListSelectionModel(javax.swing.ListSelectionModel) JTableHeader(javax.swing.table.JTableHeader) WindowAdapter(java.awt.event.WindowAdapter) IOException(java.io.IOException) Font(java.awt.Font) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel) JDialog(javax.swing.JDialog)

Example 63 with JDialog

use of javax.swing.JDialog in project jabref by JabRef.

the class ParameterizedDialogNewEntryTest method cancelAddingEntryPlainTextOfGivenType.

@Test
public void cancelAddingEntryPlainTextOfGivenType() {
    mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
    JTableFixture entryTable = mainFrame.table();
    entryTable.requireRowCount(0);
    mainFrame.menuItemWithPath("BibTeX", "New entry from plain text...").click();
    selectEntryType();
    GenericTypeMatcher<JDialog> matcher2 = plainTextMatcher();
    findDialog(matcher2).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "Cancel".equals(jButton.getText());
        }
    }).click();
    entryTable.requireRowCount(0);
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Nonnull(org.assertj.swing.dependency.jsr305.Nonnull) JButton(javax.swing.JButton) GenericTypeMatcher(org.assertj.swing.core.GenericTypeMatcher) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 64 with JDialog

use of javax.swing.JDialog in project jabref by JabRef.

the class IdFetcherDialogTest method insertEmptySearchID.

@Test
public void insertEmptySearchID() {
    mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
    JTableFixture entryTable = mainFrame.table();
    entryTable.requireRowCount(0);
    mainFrame.menuItemWithPath("BibTeX", "New entry...").click();
    GenericTypeMatcher<JDialog> matcher = new GenericTypeMatcher<JDialog>(JDialog.class) {

        @Override
        protected boolean isMatching(JDialog dialog) {
            return "Select entry type".equals(dialog.getTitle());
        }
    };
    findDialog(matcher).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "Generate".equals(jButton.getText());
        }
    }).click();
    GenericTypeMatcher<JDialog> matcherEmptyDialog = new GenericTypeMatcher<JDialog>(JDialog.class) {

        @Override
        protected boolean isMatching(JDialog dialog) {
            return "Empty search ID".equals(dialog.getTitle());
        }
    };
    findDialog(matcherEmptyDialog).withTimeout(10_000).using(robot()).button(new GenericTypeMatcher<JButton>(JButton.class) {

        @Override
        protected boolean isMatching(@Nonnull JButton jButton) {
            return "OK".equals(jButton.getText());
        }
    }).click();
    entryTable.requireRowCount(0);
}
Also used : JTableFixture(org.assertj.swing.fixture.JTableFixture) Nonnull(org.assertj.swing.dependency.jsr305.Nonnull) JButton(javax.swing.JButton) GenericTypeMatcher(org.assertj.swing.core.GenericTypeMatcher) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 65 with JDialog

use of javax.swing.JDialog in project JMRI by JMRI.

the class PositionablePoint method setLink.

void setLink() {
    if (getConnect1() == null || getConnect1().getLayoutBlock() == null) {
        log.error("Can not set link until we have a connecting track with a block assigned");
        return;
    }
    editLink = new JDialog();
    editLink.setTitle("EDIT LINK from " + getConnect1().getLayoutBlock().getDisplayName());
    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());
    JButton done = new JButton(Bundle.getMessage("ButtonDone"));
    done.addActionListener((ActionEvent a) -> {
        updateLink();
    });
    // make this button the default button (return or enter activates)
    // Note: We have to invoke this later because we don't currently have a root pane
    SwingUtilities.invokeLater(() -> {
        JRootPane rootPane = SwingUtilities.getRootPane(done);
        rootPane.setDefaultButton(done);
    });
    container.add(getLinkPanel(), BorderLayout.NORTH);
    container.add(done, BorderLayout.SOUTH);
    container.revalidate();
    editLink.add(container);
    editLink.pack();
    editLink.setModal(false);
    editLink.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)181 JButton (javax.swing.JButton)70 JPanel (javax.swing.JPanel)61 ActionEvent (java.awt.event.ActionEvent)51 ActionListener (java.awt.event.ActionListener)39 JLabel (javax.swing.JLabel)39 JOptionPane (javax.swing.JOptionPane)34 BorderLayout (java.awt.BorderLayout)30 Dimension (java.awt.Dimension)27 JScrollPane (javax.swing.JScrollPane)27 JFrame (javax.swing.JFrame)23 BoxLayout (javax.swing.BoxLayout)21 FlowLayout (java.awt.FlowLayout)19 JCheckBox (javax.swing.JCheckBox)15 AbstractAction (javax.swing.AbstractAction)14 WindowEvent (java.awt.event.WindowEvent)13 JComponent (javax.swing.JComponent)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowAdapter (java.awt.event.WindowAdapter)11 IOException (java.io.IOException)10