Search in sources :

Example 6 with ComponentEvent

use of java.awt.event.ComponentEvent in project frostwire by frostwire.

the class LibraryLeftPanel method setupUI.

protected void setupUI() {
    setLayout(new BorderLayout());
    // Prepare a split pane with explorers
    splitPane.setTopComponent(libraryExplorer);
    splitPane.setBottomComponent(libraryPlaylists);
    splitPane.setAutoscrolls(true);
    add(splitPane, BorderLayout.CENTER);
    Dimension minSize = new Dimension(MIN_WIDTH, MIN_WIDTH);
    Dimension maxSize = new Dimension(MAX_WIDTH, MAX_WIDTH);
    libraryCoverArtPanel.setPreferredSize(minSize);
    libraryCoverArtPanel.setMinimumSize(minSize);
    libraryCoverArtPanel.setMaximumSize(maxSize);
    add(libraryCoverArtPanel, BorderLayout.PAGE_END);
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            layoutComponents();
        }
    });
    DividerLocationSettingUpdater.install(splitPane, UISettings.UI_LIBRARY_EXPLORER_DIVIDER_POSITION);
}
Also used : ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 7 with ComponentEvent

use of java.awt.event.ComponentEvent 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 8 with ComponentEvent

use of java.awt.event.ComponentEvent 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 9 with ComponentEvent

use of java.awt.event.ComponentEvent 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)

Example 10 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class XWindowPeer method setBounds.

//Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges
//the window but fails to revalidate, Sol-CDE
//This bug is regression for
//5025858: Resizing a decorated frame triggers componentResized event twice.
//Since events are not posted from Component.setBounds we need to send them here.
//Note that this function is overriden in XDecoratedPeer so event
//posting is not changing for decorated peers
public void setBounds(int x, int y, int width, int height, int op) {
    XToolkit.awtLock();
    try {
        Rectangle oldBounds = getBounds();
        super.setBounds(x, y, width, height, op);
        Rectangle bounds = getBounds();
        XSizeHints hints = getHints();
        setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize, bounds.x, bounds.y, bounds.width, bounds.height);
        XWM.setMotifDecor(this, false, 0, 0);
        boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
        boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
        if (isMoved || isResized) {
            repositionSecurityWarning();
        }
        if (isResized) {
            postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
        }
        if (isMoved) {
            postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
Also used : ComponentEvent(java.awt.event.ComponentEvent)

Aggregations

ComponentEvent (java.awt.event.ComponentEvent)120 ComponentAdapter (java.awt.event.ComponentAdapter)97 Dimension (java.awt.Dimension)22 Component (java.awt.Component)18 ActionEvent (java.awt.event.ActionEvent)18 JPanel (javax.swing.JPanel)18 JScrollPane (javax.swing.JScrollPane)16 ComponentListener (java.awt.event.ComponentListener)15 MouseEvent (java.awt.event.MouseEvent)15 JButton (javax.swing.JButton)15 JLabel (javax.swing.JLabel)15 BorderLayout (java.awt.BorderLayout)12 Point (java.awt.Point)12 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 MouseAdapter (java.awt.event.MouseAdapter)11 ActionListener (java.awt.event.ActionListener)10 JTable (javax.swing.JTable)9 AbstractAction (javax.swing.AbstractAction)8 BoxLayout (javax.swing.BoxLayout)8