Search in sources :

Example 81 with ComponentEvent

use of java.awt.event.ComponentEvent in project jabref by JabRef.

the class FindUnlinkedFilesDialog method initializeActions.

/**
     * Initializes action objects. <br>
     * Does not assign actions to components yet!
     */
private void initializeActions() {
    actionSelectAll = new AbstractAction(Localization.lang("Select all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            rootNode.setSelected(true);
            tree.invalidate();
            tree.repaint();
        }
    };
    actionUnselectAll = new AbstractAction(Localization.lang("Unselect all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            rootNode.setSelected(false);
            tree.invalidate();
            tree.repaint();
        }
    };
    actionExpandTree = new AbstractAction(Localization.lang("Expand all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            expandTree(tree, new TreePath(rootNode), true);
        }
    };
    actionCollapseTree = new AbstractAction(Localization.lang("Collapse all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            expandTree(tree, new TreePath(rootNode), false);
        }
    };
    dialogPositionListener = new ComponentAdapter() {

        /* (non-Javadoc)
             * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
             */
        @Override
        public void componentResized(ComponentEvent e) {
            storeSizeOfDialog();
        }

        /* (non-Javadoc)
             * @see java.awt.event.ComponentAdapter#componentMoved(java.awt.event.ComponentEvent)
             */
        @Override
        public void componentMoved(ComponentEvent e) {
            storeSizeOfDialog();
        }
    };
}
Also used : TreePath(javax.swing.tree.TreePath) ActionEvent(java.awt.event.ActionEvent) ComponentEvent(java.awt.event.ComponentEvent) AbstractAction(javax.swing.AbstractAction) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 82 with ComponentEvent

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

the class ImportSummary 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 83 with ComponentEvent

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

the class ImportTwo method initComponents.

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

        @Override
        public void componentShown(ComponentEvent evt) {
            refreshInfo();
        }
    });
    deleteButton.addActionListener(this);
    JTableUtils.packGenericTable(table);
}
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 84 with ComponentEvent

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

the class FileChooserHandler method prepareForWindowEvents.

private static void prepareForWindowEvents(JFileChooser fileChooser) {
    fileChooser.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            onFileChooserResized(e.getComponent().getSize().width, e.getComponent().getSize().height);
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            onFileChooserMoved(e.getComponent().getX(), e.getComponent().getY());
        }
    });
    if (ApplicationSettings.FILECHOOSER_X_POS.getValue() == -1) {
        // first time ever. calculate centered x,y offset. (Big-Small)/2.
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        ApplicationSettings.FILECHOOSER_X_POS.setValue((screenSize.width - ApplicationSettings.FILECHOOSER_WIDTH.getValue()) >> 1);
        ApplicationSettings.FILECHOOSER_Y_POS.setValue((screenSize.height - ApplicationSettings.FILECHOOSER_HEIGHT.getValue()) >> 1);
    }
    fileChooser.setLocation(ApplicationSettings.FILECHOOSER_X_POS.getValue(), ApplicationSettings.FILECHOOSER_Y_POS.getValue());
    fileChooser.setPreferredSize(new Dimension(ApplicationSettings.FILECHOOSER_WIDTH.getValue(), ApplicationSettings.FILECHOOSER_HEIGHT.getValue()));
}
Also used : ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 85 with ComponentEvent

use of java.awt.event.ComponentEvent in project litiengine by gurkenlabs.

the class Program method setupInterface.

private static void setupInterface() {
    MenuBar menuBar = new MenuBar();
    JFrame window = ((JFrame) Game.getScreenManager());
    Game.onTerminating(s -> {
        boolean terminate = notifyPendingChanges();
        if (terminate) {
            getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
        }
        return terminate;
    });
    window.setResizable(true);
    window.setMenuBar(menuBar);
    if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
        window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
    }
    if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
        window.setExtendedState(userPreferences.getFrameState());
    }
    Canvas canvas = Game.getScreenManager().getRenderComponent();
    canvas.setFocusable(true);
    canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
    window.remove(canvas);
    JPanel renderPane = new JPanel(new BorderLayout());
    renderPane.add(canvas);
    renderPane.setMinimumSize(new Dimension(300, 0));
    initCanvasPopupMenu(canvas);
    JPanel contentPane = new JPanel(new BorderLayout());
    window.setContentPane(contentPane);
    horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
    renderPane.add(horizontalScroll, BorderLayout.SOUTH);
    verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
    renderPane.add(verticalScroll, BorderLayout.EAST);
    horizontalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
        Game.getCamera().setFocus(newFocus);
    });
    verticalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
        Game.getCamera().setFocus(newFocus);
    });
    MapObjectPanel mapEditorPanel = new MapObjectPanel();
    MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
    JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mapWrap.setMinimumSize(new Dimension(300, 0));
    mapWrap.setBottomComponent(mapEditorPanel);
    mapWrap.setTopComponent(mapSelectionPanel);
    mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
    if (userPreferences.getSelectionEditSplitter() != 0) {
        mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
    }
    JPanel bottomPanel = new JPanel(new BorderLayout());
    JTabbedPane bottomTab = new JTabbedPane();
    bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
    bottomTab.addTab("Console", initConsole());
    bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
    bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
    bottomPanel.add(bottomTab, BorderLayout.CENTER);
    statusBar = new JLabel("");
    statusBar.setPreferredSize(new Dimension(0, 16));
    statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
    bottomPanel.add(statusBar, BorderLayout.SOUTH);
    EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
        if (selection.isEmpty()) {
            statusBar.setText("");
        } else {
            statusBar.setText(" " + selection.size() + " selected objects");
        }
    });
    JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
    if (userPreferences.getBottomSplitter() != 0) {
        rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
    } else {
        rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
    }
    rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
    rendersplit.setContinuousLayout(true);
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
    split.setContinuousLayout(true);
    split.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            userPreferences.setWidth(window.getWidth());
            userPreferences.setHeight(window.getHeight());
        }
    });
    split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
    contentPane.add(split, BorderLayout.CENTER);
    split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
    JToolBar toolbar = initToolBar();
    contentPane.add(toolbar, BorderLayout.NORTH);
    EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
    EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
    Menu mnFile = initFileMenu();
    menuBar.add(mnFile);
    Menu mnView = initViewMenu();
    menuBar.add(mnView);
    Menu mnProject = initProjectMenu();
    menuBar.add(mnProject);
    Menu mnMap = initMapMenu();
    menuBar.add(mnMap);
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) Canvas(java.awt.Canvas) JTabbedPane(javax.swing.JTabbedPane) MenuBar(java.awt.MenuBar) MapObjectPanel(de.gurkenlabs.utiliti.swing.panels.MapObjectPanel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) Font(java.awt.Font) JScrollBar(javax.swing.JScrollBar) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Point2D(java.awt.geom.Point2D) ComponentEvent(java.awt.event.ComponentEvent) PopupMenu(java.awt.PopupMenu) Menu(java.awt.Menu) JPopupMenu(javax.swing.JPopupMenu) JSplitPane(javax.swing.JSplitPane) ComponentAdapter(java.awt.event.ComponentAdapter)

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