Search in sources :

Example 56 with ComponentEvent

use of java.awt.event.ComponentEvent in project javatari by ppeccin.

the class PanelScreen method setup.

private void setup() {
    setTransferHandler(new ROMDropTransferHandler());
    monitorPanel.addComponentListener(new ComponentAdapter() {

        public void componentResized(ComponentEvent e) {
            if (e.getComponent() == monitorPanel)
                validate();
        }
    });
    setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
    setOpaque(false);
    add(monitorPanel);
    if (consolePanel != null)
        add(consolePanel);
    validate();
}
Also used : FlowLayout(java.awt.FlowLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 57 with ComponentEvent

use of java.awt.event.ComponentEvent in project lwjgl by LWJGL.

the class MacOSXCanvasPeerInfo method addComponentListener.

private void addComponentListener(final Canvas component) {
    ComponentListener[] components = component.getComponentListeners();
    // avoid adding duplicate listners by checking if one has already been added
    for (int i = 0; i < components.length; i++) {
        ComponentListener c = components[i];
        if (c.toString() == "CanvasPeerInfoListener") {
            // already contains the listner below return without adding
            return;
        }
    }
    ComponentListener comp = new ComponentListener() {

        public void componentHidden(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
            // nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
            reSetLayerBounds(component, getHandle());
        }

        public void componentResized(ComponentEvent e) {
            // nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
            reSetLayerBounds(component, getHandle());
        }

        public void componentShown(ComponentEvent e) {
        }

        public String toString() {
            return "CanvasPeerInfoListener";
        }
    };
    component.addComponentListener(comp);
}
Also used : ComponentListener(java.awt.event.ComponentListener) ComponentEvent(java.awt.event.ComponentEvent) Point(java.awt.Point)

Example 58 with ComponentEvent

use of java.awt.event.ComponentEvent in project cayenne by apache.

the class CayenneModelerFrame method initToolbar.

/**
 * Initializes main toolbar.
 */
protected void initToolbar() {
    final JToolBar toolBar = new MainToolBar();
    Dimension smallBtnDim = new Dimension(30, 30);
    JButton backButton = getAction(NavigateBackwardAction.class).buildButton(1);
    backButton.setMinimumSize(smallBtnDim);
    backButton.setPreferredSize(smallBtnDim);
    toolBar.add(backButton);
    JButton forwardButton = getAction(NavigateForwardAction.class).buildButton(3);
    forwardButton.setMinimumSize(smallBtnDim);
    forwardButton.setPreferredSize(smallBtnDim);
    toolBar.add(forwardButton);
    toolBar.addSeparator(new Dimension(30, 0));
    toolBar.add(getAction(NewProjectAction.class).buildButton(1));
    toolBar.add(getAction(OpenProjectAction.class).buildButton(2));
    toolBar.add(getAction(SaveAction.class).buildButton(3));
    toolBar.addSeparator();
    JButton removeButton = getAction(RemoveAction.class).buildButton();
    toolBar.add(removeButton);
    toolBar.addSeparator();
    toolBar.add(getAction(CutAction.class).buildButton(1));
    toolBar.add(getAction(CopyAction.class).buildButton(2));
    toolBar.add(getAction(PasteAction.class).buildButton(3));
    toolBar.addSeparator();
    toolBar.add(getAction(UndoAction.class).buildButton(1));
    toolBar.add(getAction(RedoAction.class).buildButton(3));
    toolBar.addSeparator();
    toolBar.add(getAction(CreateNodeAction.class).buildButton(1));
    toolBar.add(getAction(CreateDataMapAction.class).buildButton(3));
    toolBar.addSeparator();
    toolBar.add(getAction(CreateDbEntityAction.class).buildButton(1));
    toolBar.add(getAction(CreateProcedureAction.class).buildButton(3));
    toolBar.addSeparator();
    toolBar.add(getAction(CreateObjEntityAction.class).buildButton(1));
    toolBar.add(getAction(CreateEmbeddableAction.class).buildButton(2));
    toolBar.add(getAction(CreateQueryAction.class).buildButton(3));
    // is used to place search feature components the most right on a toolbar
    toolBar.add(new SearchPanel());
    getContentPane().add(toolBar, BorderLayout.NORTH);
    // Hide some buttons when frame is too small
    final int defaultBtnWidth = removeButton.getUI().getPreferredSize(backButton).width;
    addComponentListener(new ComponentAdapter() {

        private final int[] empty = {};

        private final int[] all = { 6, 7, 8, 9, 10, 11, 12, 13, 14 };

        private final int[] remove = { 6, 7 };

        private final int[] removeAndCopy = { 6, 7, 8, 9, 10, 11 };

        private final int[] undo = { 12, 13, 14 };

        private final int[] undoAndCopy = { 8, 9, 10, 11, 12, 13, 14 };

        @Override
        public void componentResized(ComponentEvent e) {
            int[] hidden, shown;
            if (getSize().width < (13 * defaultBtnWidth + 300)) {
                hidden = all;
                shown = empty;
            } else if (getSize().width < (16 * defaultBtnWidth + 300)) {
                hidden = removeAndCopy;
                shown = undo;
            } else if (getSize().width < (18 * defaultBtnWidth + 300)) {
                hidden = remove;
                shown = undoAndCopy;
            } else {
                hidden = empty;
                shown = all;
            }
            for (int i : hidden) {
                toolBar.getComponentAtIndex(i).setVisible(false);
            }
            for (int i : shown) {
                toolBar.getComponentAtIndex(i).setVisible(true);
            }
        }
    });
}
Also used : JButton(javax.swing.JButton) NavigateForwardAction(org.apache.cayenne.modeler.action.NavigateForwardAction) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) NavigateBackwardAction(org.apache.cayenne.modeler.action.NavigateBackwardAction) MainToolBar(org.apache.cayenne.swing.components.MainToolBar) ComponentEvent(java.awt.event.ComponentEvent) RemoveAction(org.apache.cayenne.modeler.action.RemoveAction) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 59 with ComponentEvent

use of java.awt.event.ComponentEvent in project cayenne by apache.

the class ObjEntityCallbackMethodsTab method initController.

/**
 * listeners initialization
 */
protected void initController() {
    super.initController();
    addComponentListener(new ComponentAdapter() {

        public void componentShown(ComponentEvent e) {
            rebuildTables();
        }
    });
    mediator.addObjEntityDisplayListener(e -> {
        if (ObjEntityCallbackMethodsTab.this.isVisible()) {
            rebuildTables();
        }
    });
}
Also used : ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 60 with ComponentEvent

use of java.awt.event.ComponentEvent in project cayenne by apache.

the class AdapterEditor method initController.

protected void initController() {
    // init bindings
    BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
    adapterNameBinding = builder.bindToTextField(view.getCustomAdapter(), "adapterName");
    ((ProjectController) getParent()).addDataNodeDisplayListener(new DataNodeDisplayListener() {

        public void currentDataNodeChanged(DataNodeDisplayEvent e) {
            refreshView(e.getDataNode());
        }
    });
    getView().addComponentListener(new ComponentAdapter() {

        public void componentShown(ComponentEvent e) {
            refreshView(node != null ? node : ((ProjectController) getParent()).getCurrentDataNode());
        }
    });
}
Also used : BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DataNodeDisplayListener(org.apache.cayenne.modeler.event.DataNodeDisplayListener) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) ComponentEvent(java.awt.event.ComponentEvent) ProjectController(org.apache.cayenne.modeler.ProjectController) 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