Search in sources :

Example 6 with ComponentAdapter

use of java.awt.event.ComponentAdapter in project omegat by omegat-org.

the class StaticUIUtils method persistGeometry.

public static void persistGeometry(Window window, String key, Runnable extraProcessing) {
    getStoredRectangle(key).ifPresent(window::setBounds);
    String xKey = key + "_x";
    String yKey = key + "_y";
    String widthKey = key + "_width";
    String heightKey = key + "_height";
    Timer timer = new Timer(500, e -> {
        Rectangle bounds = window.getBounds();
        Preferences.setPreference(xKey, bounds.x);
        Preferences.setPreference(yKey, bounds.y);
        Preferences.setPreference(widthKey, bounds.width);
        Preferences.setPreference(heightKey, bounds.height);
        if (extraProcessing != null) {
            extraProcessing.run();
        }
    });
    timer.setRepeats(false);
    window.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentMoved(ComponentEvent e) {
            timer.restart();
        }

        @Override
        public void componentResized(ComponentEvent e) {
            timer.restart();
        }
    });
}
Also used : Timer(javax.swing.Timer) Rectangle(java.awt.Rectangle) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 7 with ComponentAdapter

use of java.awt.event.ComponentAdapter in project omegat by omegat-org.

the class EditorController method createUI.

private void createUI() {
    pane = new DockablePanel("EDITOR", " ", false);
    pane.setComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    pane.setMinimumSize(new Dimension(100, 100));
    pane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            updateTitle();
        }
    });
    scrollPane = new JScrollPane(editor);
    Border panelBorder = UIManager.getBorder("OmegaTDockablePanel.border");
    if (panelBorder != null) {
        scrollPane.setBorder(panelBorder);
    }
    Border viewportBorder = UIManager.getBorder("OmegaTDockablePanelViewport.border");
    if (viewportBorder != null) {
        scrollPane.setViewportBorder(viewportBorder);
    }
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.getVerticalScrollBar().addAdjustmentListener(scrollListener);
    pane.setLayout(new BorderLayout());
    pane.add(scrollPane, BorderLayout.CENTER);
    mw.addDockable(pane);
    DockingDesktop desktop = DockingUI.getDesktop(pane);
    if (desktop != null) {
        desktop.addDockableSelectionListener(e -> dockableSelected = pane == e.getSelectedDockable());
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) DockingDesktop(com.vlsolutions.swing.docking.DockingDesktop) Dimension(java.awt.Dimension) ComponentEvent(java.awt.event.ComponentEvent) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder) ComponentAdapter(java.awt.event.ComponentAdapter) DockablePanel(org.omegat.gui.main.DockablePanel)

Example 8 with ComponentAdapter

use of java.awt.event.ComponentAdapter in project jgnash by ccavanaugh.

the class DynamicJasperReportPanel method initializeUI.

private void initializeUI() {
    GridBagConstraints gridBagConstraints;
    JToolBar toolBar = new JToolBar();
    firstButton = new JButton();
    previousButton = new JButton();
    nextButton = new JButton();
    lastButton = new JButton();
    actualSizeButton = new JToggleButton();
    fitPageButton = new JToggleButton();
    fitWidthButton = new JToggleButton();
    zoomInButton = new JButton();
    DefaultComboBoxModel<String> zoomModel = new DefaultComboBoxModel<>();
    for (int z : ZOOM) {
        zoomModel.addElement(z + "%");
    }
    zoomComboBox = new JComboBox<>(zoomModel);
    DefaultComboBoxModel<Integer> fontModel = new DefaultComboBoxModel<>();
    for (int i = 0; i <= 10; i++) {
        fontModel.addElement(5 + i);
    }
    fontSizeComboBox = new JComboBox<>(fontModel);
    fontSizeComboBox.setToolTipText(ResourceUtils.getString("ToolTip.FontSize"));
    fontSizeComboBox.setSelectedItem(report.getBaseFontSize());
    fontSizeComboBox.addActionListener(this);
    zoomOutButton = new JButton();
    mainPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    scrollPanePanel = new JPanel();
    pageGluePanel = new JPanel();
    JPanel pagePanel = new JPanel();
    JPanel shadowPanel1 = new JPanel();
    JPanel shadowPanel2 = new JPanel();
    JPanel shadowPanel3 = new JPanel();
    JPanel shadowPanel4 = new JPanel();
    JPanel shadowPanel5 = new JPanel();
    setLayout(new BorderLayout());
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    saveButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-save-as.png")));
    saveButton.setToolTipText(resourceBundle.getString("save"));
    saveButton.setFocusable(false);
    saveButton.addActionListener(this);
    toolBar.add(saveButton);
    printButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-print.png")));
    printButton.setToolTipText(resourceBundle.getString("print"));
    printButton.setFocusable(false);
    printButton.addActionListener(this);
    toolBar.add(printButton);
    toolBar.add(new JToolBar.Separator());
    pageSetupButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-properties.png")));
    pageSetupButton.setToolTipText(ResourceUtils.getString("ToolTip.PageSetup"));
    pageSetupButton.setFocusable(false);
    pageSetupButton.addActionListener(this);
    toolBar.add(pageSetupButton);
    fontSizeComboBox.setMaximumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setMinimumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setPreferredSize(new Dimension(50, pageSetupButton.getPreferredSize().height));
    toolBar.add(fontSizeComboBox);
    toolBar.add(new JToolBar.Separator());
    firstButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-first.png")));
    firstButton.setToolTipText(resourceBundle.getString("first.page"));
    firstButton.setFocusable(false);
    firstButton.setEnabled(false);
    firstButton.addActionListener(this);
    toolBar.add(firstButton);
    previousButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-previous.png")));
    previousButton.setToolTipText(resourceBundle.getString("previous.page"));
    previousButton.setFocusable(false);
    previousButton.setEnabled(false);
    previousButton.addActionListener(this);
    toolBar.add(previousButton);
    nextButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-next.png")));
    nextButton.setToolTipText(resourceBundle.getString("next.page"));
    nextButton.setFocusable(false);
    nextButton.setEnabled(false);
    nextButton.addActionListener(this);
    toolBar.add(nextButton);
    lastButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-last.png")));
    lastButton.setToolTipText(resourceBundle.getString("last.page"));
    lastButton.setFocusable(false);
    lastButton.setEnabled(false);
    lastButton.addActionListener(this);
    toolBar.add(lastButton);
    toolBar.add(new JToolBar.Separator());
    actualSizeButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF")));
    actualSizeButton.setToolTipText(resourceBundle.getString("actual.size"));
    actualSizeButton.setFocusable(false);
    actualSizeButton.addActionListener(this);
    toolBar.add(actualSizeButton);
    fitPageButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF")));
    fitPageButton.setToolTipText(resourceBundle.getString("fit.page"));
    fitPageButton.setFocusable(false);
    fitPageButton.addActionListener(this);
    toolBar.add(fitPageButton);
    fitWidthButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF")));
    fitWidthButton.setToolTipText(resourceBundle.getString("fit.width"));
    fitWidthButton.setFocusable(false);
    fitWidthButton.addActionListener(this);
    toolBar.add(fitWidthButton);
    toolBar.add(new JToolBar.Separator());
    zoomInButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-in.png")));
    zoomInButton.setToolTipText(resourceBundle.getString("zoom.in"));
    zoomInButton.setFocusable(false);
    zoomInButton.addActionListener(this);
    toolBar.add(zoomInButton);
    zoomComboBox.setEditable(true);
    zoomComboBox.setToolTipText(resourceBundle.getString("zoom.ratio"));
    zoomComboBox.setMaximumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setMinimumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setPreferredSize(new Dimension(90, zoomInButton.getPreferredSize().height));
    zoomComboBox.addItemListener(evt -> zoomStateChange());
    zoomComboBox.addActionListener(this);
    toolBar.add(zoomComboBox);
    zoomOutButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-out.png")));
    zoomOutButton.setToolTipText(resourceBundle.getString("zoom.out"));
    zoomOutButton.setFocusable(false);
    zoomOutButton.addActionListener(this);
    toolBar.add(zoomOutButton);
    JPanel reportController = report.getReportController();
    if (reportController != null) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(toolBar, BorderLayout.NORTH);
        panel.add(reportController, BorderLayout.CENTER);
        add(panel, BorderLayout.NORTH);
    } else {
        add(toolBar, BorderLayout.NORTH);
    }
    mainPanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(final ComponentEvent evt) {
            pnlMainComponentResized();
        }
    });
    mainPanel.setLayout(new BorderLayout());
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPanePanel.setLayout(new GridBagLayout());
    pageGluePanel.setLayout(new BorderLayout());
    pagePanel.setLayout(new GridBagLayout());
    spaceHoldPanel = new JPanel();
    spaceHoldPanel.setMinimumSize(new Dimension(5, 5));
    spaceHoldPanel.setOpaque(false);
    spaceHoldPanel.setPreferredSize(new Dimension(5, 5));
    spaceHoldPanel.setLayout(null);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    pagePanel.add(spaceHoldPanel, gridBagConstraints);
    shadowPanel1.setBackground(java.awt.Color.gray);
    shadowPanel1.setMinimumSize(new Dimension(5, 5));
    shadowPanel1.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.VERTICAL;
    pagePanel.add(shadowPanel1, gridBagConstraints);
    shadowPanel2.setMinimumSize(new Dimension(5, 5));
    shadowPanel2.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel2, gridBagConstraints);
    shadowPanel3.setBackground(Color.gray);
    shadowPanel3.setMinimumSize(new Dimension(5, 5));
    shadowPanel3.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pagePanel.add(shadowPanel3, gridBagConstraints);
    shadowPanel4.setBackground(Color.gray);
    shadowPanel4.setMinimumSize(new Dimension(5, 5));
    shadowPanel4.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel4, gridBagConstraints);
    shadowPanel5.setMinimumSize(new Dimension(5, 5));
    shadowPanel5.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    pagePanel.add(shadowPanel5, gridBagConstraints);
    pageRenderer = new PageRenderer(this);
    pageRenderer.setBackground(Color.white);
    pageRenderer.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    pageRenderer.setOpaque(true);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pagePanel.add(pageRenderer, gridBagConstraints);
    pageGluePanel.add(pagePanel, BorderLayout.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    scrollPanePanel.add(pageGluePanel, gridBagConstraints);
    scrollPane.setViewportView(scrollPanePanel);
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    add(mainPanel, BorderLayout.CENTER);
    zoomComboBox.setSelectedIndex(DEFAULT_ZOOM_INDEX);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JToggleButton(javax.swing.JToggleButton) BorderLayout(java.awt.BorderLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 9 with ComponentAdapter

use of java.awt.event.ComponentAdapter in project jgnash by ccavanaugh.

the class PartialSummary method initComponents.

private void initComponents() {
    destLabel = new JLabel("Account");
    transCount = new JLabel("0");
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent evt) {
            refreshInfo();
        }
    });
}
Also used : JLabel(javax.swing.JLabel) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 10 with ComponentAdapter

use of java.awt.event.ComponentAdapter in project jgnash by ccavanaugh.

the class PartialTwo method initComponents.

private void initComponents() {
    table = new PartialTable(qAcc);
    deleteButton = new JButton(rb.getString("Button.Delete"));
    helpPane = new JTextPane();
    helpPane.setEditable(false);
    helpPane.setEditorKit(new StyledEditorKit());
    helpPane.setBackground(getBackground());
    helpPane.setText(TextResource.getString("QifTwo.txt"));
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent evt) {
            refreshInfo();
        }
    });
    deleteButton.addActionListener(this);
}
Also used : StyledEditorKit(javax.swing.text.StyledEditorKit) JTextPane(javax.swing.JTextPane) JButton(javax.swing.JButton) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

ComponentAdapter (java.awt.event.ComponentAdapter)96 ComponentEvent (java.awt.event.ComponentEvent)96 Dimension (java.awt.Dimension)17 ActionEvent (java.awt.event.ActionEvent)17 JPanel (javax.swing.JPanel)17 JButton (javax.swing.JButton)15 Component (java.awt.Component)14 MouseEvent (java.awt.event.MouseEvent)14 JLabel (javax.swing.JLabel)13 JScrollPane (javax.swing.JScrollPane)13 BorderLayout (java.awt.BorderLayout)12 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 MouseAdapter (java.awt.event.MouseAdapter)11 Point (java.awt.Point)10 ActionListener (java.awt.event.ActionListener)10 AbstractAction (javax.swing.AbstractAction)8 BoxLayout (javax.swing.BoxLayout)8 JComponent (javax.swing.JComponent)8 JTable (javax.swing.JTable)8