Search in sources :

Example 1 with JDialog

use of javax.swing.JDialog in project screenbird by adamhub.

the class PreviewPlayer method initView.

/**
     * Creates "record from here" secondary window.
     */
private void initView() {
    this.previewTimeSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            previewTimeSlider.repaint();
            updateRecordNowButtonPosition();
            scrubManager.updateTimeLabels(previewTimeSlider.getValue());
        }
    });
    this.jfRecordFromHere = new JDialog(this.jfPreviewPlayer, "Record From Here");
    this.jfRecordFromHere.setUndecorated(true);
    this.jfRecordFromHere.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(ResourceUtil.LOGO_TASKBAR)));
    if (MediaUtil.osIsUnix()) {
        // Renders Linux's custom view due to transparency issues.
        this.jpRecordFromHere = new RecordFromHereLinux(this);
    } else {
        // Renders Default view
        this.jpRecordFromHere = new RecordFromHereSB(this);
    }
    this.jfRecordFromHere.add(jpRecordFromHere);
    try {
        if (!AWTUtilities.isTranslucencyCapable(this.jfRecordFromHere.getGraphicsConfiguration())) {
            log("Can not set transparency");
            this.setBackground(new Color(64, 64, 64, 255));
            this.jpRecordFromHere.setBackground(new Color(64, 64, 64, 255));
            this.jpRecordFromHere.setOpaque(true);
        } else {
            log("Transparency is set");
            AWTUtilities.setWindowOpaque(this.jfRecordFromHere, false);
        }
    } catch (Exception ex) {
        log(ex);
    }
    // Hack for handling draggable JFrames on Mac OSX
    this.jfRecordFromHere.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
    this.jfRecordFromHere.pack();
    this.addMouseListener(new PreivewMouseListener());
    this.addMouseMotionListener(new PreviewMotionListener());
    this.previewTimeSlider.addMouseMotionListener(new PreviewSliderMotionListener());
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) Color(java.awt.Color) ChangeListener(javax.swing.event.ChangeListener) JDialog(javax.swing.JDialog) IllegalComponentStateException(java.awt.IllegalComponentStateException)

Example 2 with JDialog

use of javax.swing.JDialog in project jna by java-native-access.

the class Excelautomation_KB_219151_Mod method displayQuaterlySales.

private static void displayQuaterlySales(ComIWorksheet sheet) {
    // Determine how many quarters to display data for.
    int iNumQtrs = 4;
    for (; iNumQtrs >= 2; iNumQtrs--) {
        JOptionPane pane = new JOptionPane(String.format("Enter sales data for %d quarter(s)?", iNumQtrs), JOptionPane.QUESTION_MESSAGE);
        pane.setOptionType(JOptionPane.YES_NO_OPTION);
        JDialog dialog = pane.createDialog("Input...");
        dialog.setAlwaysOnTop(true);
        dialog.show();
        if (((Integer) pane.getValue()) == JOptionPane.YES_OPTION) {
            break;
        }
    }
    JOptionPane.showMessageDialog(null, String.format("Displaying data for %d quarter(s).", iNumQtrs));
    // Starting at E1, fill headers for the number of columns selected.
    ComIRange oResizeRange = sheet.getRange("E1", "E1").getResize(VARIANT_MISSING, iNumQtrs);
    oResizeRange.setFormula("=\"Q\" & COLUMN() - 4 & CHAR(10) & \"Sales\"");
    // Change the Orientation and WrapText properties for the headers.
    oResizeRange.setOrientation(38);
    oResizeRange.setWrapText(true);
    // Fill the interior color of the headers.
    oResizeRange.getInterior().setColorIndex(36);
    // Fill the columns with a formula and apply a number format.
    oResizeRange = sheet.getRange("E2", "E6").getResize(VARIANT_MISSING, iNumQtrs);
    oResizeRange.setFormula("=RAND()*100");
    oResizeRange.setNumberFormat("$0.00");
    // Apply borders to the Sales data and headers.
    oResizeRange = sheet.getRange("E1", "E6").getResize(VARIANT_MISSING, iNumQtrs);
    oResizeRange.getBorders().setWeight(XlBorderWeight.xlThin);
    // Add a Totals formula for the sales data and apply a border.
    oResizeRange = sheet.getRange("E8", "E8").getResize(VARIANT_MISSING, iNumQtrs);
    oResizeRange.setFormula("=SUM(E2:E6)");
    Borders oResizeRangeBorders = oResizeRange.getBorders();
    oResizeRangeBorders.setLineStyle(XlLineStyle.xlDouble);
    oResizeRangeBorders.setWeight(XlBorderWeight.xlThick);
    // Add a Chart for the selected data
    oResizeRange = sheet.getRange("E2:E6").getResize(VARIANT_MISSING, iNumQtrs);
    Chart chart = sheet.getParent().getCharts().Add(VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING, VARIANT_MISSING);
    // Java note: Assumption is, that VARIANT_MISSING is the correct indicator
    // for missing values, it turns out, NULL is correct in this case...
    chart.ChartWizard(oResizeRange, XlChartType.xl3DColumn, VARIANT_MISSING, XlRowCol.xlColumns, null, null, null, null, null, null, null);
    chart.SeriesCollection(1).setXValues(sheet.getRange("C2", "C6"));
    for (int i = 1; i <= iNumQtrs; i++) {
        chart.SeriesCollection(i).setName("=\"Q" + Integer.toString(i) + "\"");
    }
    chart.Location(XlChartLocation.xlLocationAsObject, sheet.getName());
    // Move the chart so as not to cover your data.
    Shape shape = sheet.getShapes().Item(1);
    shape.setTop(sheet.getRows(10).getTop());
    shape.setLeft(sheet.getColumns(2).getLeft());
}
Also used : ComIRange(com.sun.jna.platform.win32.COM.util.office.excel.ComIRange) Shape(com.sun.jna.platform.win32.COM.util.office.excel.Shape) JOptionPane(javax.swing.JOptionPane) Borders(com.sun.jna.platform.win32.COM.util.office.excel.Borders) JDialog(javax.swing.JDialog) Chart(com.sun.jna.platform.win32.COM.util.office.excel.Chart)

Example 3 with JDialog

use of javax.swing.JDialog in project languagetool by languagetool-org.

the class LanguageManagerDialog method show.

public void show() {
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiLanguageManagerDialog"));
    // close dialog when user presses Escape key:
    // TODO: taken from ConfigurationDialog, avoid duplication:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {

        @Override
        @SuppressWarnings("unused")
        public void actionPerformed(ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    list = new JList<>(ruleFiles.toArray(new File[ruleFiles.size()]));
    GridBagConstraints cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    contentPane.add(new JScrollPane(list), cons);
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.fill = GridBagConstraints.HORIZONTAL;
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    addButton = new JButton(messages.getString("guiAddButton"));
    addButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 0;
    buttonPanel.add(addButton, cons);
    removeButton = new JButton(messages.getString("guiRemoveButton"));
    removeButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 1;
    buttonPanel.add(removeButton, cons);
    closeButton = new JButton(messages.getString("guiCloseButton"));
    closeButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 2;
    buttonPanel.add(closeButton, cons);
    cons.gridx = 1;
    cons.gridy = 0;
    cons = new GridBagConstraints();
    cons.anchor = GridBagConstraints.NORTH;
    contentPane.add(buttonPanel, cons);
    dialog.pack();
    dialog.setSize(300, 200);
    dialog.setLocationByPlatform(true);
    dialog.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 4 with JDialog

use of javax.swing.JDialog in project jodd by oblac.

the class SwingSpy method initSpyDialog.

/**
	 * Initializes Spy dialog.
	 */
protected void initSpyDialog(Component rootComponent, Component component) {
    if (rootComponent instanceof Dialog) {
        spyDialog = new CaddyDialog((Dialog) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else if (rootComponent instanceof Frame) {
        spyDialog = new CaddyDialog((Frame) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else {
        spyDialog = new JDialog() {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    }
    spyDialog.setName("SwingSpy");
    spyDialog.setTitle("SwingSpy");
    spyDialog.setModal(false);
    spyDialog.setAlwaysOnTop(true);
    Container contentPane = spyDialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    spyPanel = new SwingSpyPanel();
    spyPanel.reload(rootComponent, component);
    contentPane.add(spyPanel);
    spyDialog.pack();
    spyDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosed(e);
            spyGlass.setVisible(false);
            spyDialog = null;
        }
    });
    spyDialog.setLocationRelativeTo(null);
    spyDialog.setVisible(true);
}
Also used : Frame(java.awt.Frame) RootPaneContainer(javax.swing.RootPaneContainer) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JDialog(javax.swing.JDialog) Dialog(java.awt.Dialog) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 5 with JDialog

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

the class Messages method showYesNoCancelQuestion.

// ...................................................................
// incomplete
public static int showYesNoCancelQuestion(Editor editor, String title, String primary, String secondary) {
    if (!Platform.isMacOS()) {
        int result = JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        return result;
    //    if (result == JOptionPane.YES_OPTION) {
    //
    //    } else if (result == JOptionPane.NO_OPTION) {
    //      return true;  // ok to continue
    //
    //    } else if (result == JOptionPane.CANCEL_OPTION) {
    //      return false;
    //
    //    } else {
    //      throw new IllegalStateException();
    //    }
    } else {
        // Pane formatting adapted from the Quaqua guide
        // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
        JOptionPane pane = new JOptionPane("<html> " + "<head> <style type=\"text/css\">" + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }" + "</style> </head>" + "<b>" + Language.text("save.title") + "</b>" + "<p>" + Language.text("save.hint") + "</p>", JOptionPane.QUESTION_MESSAGE);
        String[] options = new String[] { Language.text("save.btn.save"), Language.text("prompt.cancel"), Language.text("save.btn.dont_save") };
        pane.setOptions(options);
        // highlight the safest option ala apple hig
        pane.setInitialValue(options[0]);
        // on macosx, setting the destructive property places this option
        // away from the others at the lefthand side
        pane.putClientProperty("Quaqua.OptionPane.destructiveOption", Integer.valueOf(2));
        JDialog dialog = pane.createDialog(editor, null);
        dialog.setVisible(true);
        Object result = pane.getValue();
        if (result == options[0]) {
            return JOptionPane.YES_OPTION;
        } else if (result == options[1]) {
            return JOptionPane.CANCEL_OPTION;
        } else if (result == options[2]) {
            return JOptionPane.NO_OPTION;
        } else {
            return JOptionPane.CLOSED_OPTION;
        }
    }
}
Also used : JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)141 JButton (javax.swing.JButton)65 JPanel (javax.swing.JPanel)50 ActionEvent (java.awt.event.ActionEvent)42 JLabel (javax.swing.JLabel)35 ActionListener (java.awt.event.ActionListener)30 BorderLayout (java.awt.BorderLayout)24 JScrollPane (javax.swing.JScrollPane)24 JFrame (javax.swing.JFrame)20 Dimension (java.awt.Dimension)18 BoxLayout (javax.swing.BoxLayout)18 JCheckBox (javax.swing.JCheckBox)15 FlowLayout (java.awt.FlowLayout)14 AbstractAction (javax.swing.AbstractAction)14 JOptionPane (javax.swing.JOptionPane)13 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowEvent (java.awt.event.WindowEvent)11 IOException (java.io.IOException)10 JProgressBar (javax.swing.JProgressBar)10 WindowAdapter (java.awt.event.WindowAdapter)9