Example usage for java.awt.event ComponentAdapter ComponentAdapter

List of usage examples for java.awt.event ComponentAdapter ComponentAdapter

Introduction

In this page you can find the example usage for java.awt.event ComponentAdapter ComponentAdapter.

Prototype

ComponentAdapter

Source Link

Usage

From source file:components.CustomDialog.java

/** Creates the reusable dialog. */
public CustomDialog(Frame aFrame, String aWord, DialogDemo parent) {
    super(aFrame, true);
    dd = parent;/*from ww w  .j  ava 2  s.  c  o  m*/

    magicWord = aWord.toUpperCase();
    setTitle("Quiz");

    textField = new JTextField(10);

    //Create an array of the text and components to be displayed.
    String msgString1 = "What was Dr. SEUSS's real last name?";
    String msgString2 = "(The answer is \"" + magicWord + "\".)";
    Object[] array = { msgString1, msgString2, textField };

    //Create an array specifying the number of dialog buttons
    //and their text.
    Object[] options = { btnString1, btnString2 };

    //Create the JOptionPane.
    optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options,
            options[0]);

    //Make this dialog display it.
    setContentPane(optionPane);

    //Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window,
             * we're going to change the JOptionPane's
             * value property.
             */
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
        }
    });

    //Ensure the text field always gets the first focus.
    addComponentListener(new ComponentAdapter() {
        public void componentShown(ComponentEvent ce) {
            textField.requestFocusInWindow();
        }
    });

    //Register an event handler that puts the text into the option pane.
    textField.addActionListener(this);

    //Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
}

From source file:org.objectstyle.cayenne.modeler.pref.ComponentGeometry.java

/**
 * Binds this preference object to synchronize its state with a given component,
 * allowing to specify an initial offset compared to the stored position.
 *///from w w  w  . j av a  2 s .com
public void bind(final JFrame frame, int initialWidth, int initialHeight, int maxOffset) {

    updateSize(frame, initialWidth, initialHeight);
    updateLocation(frame, maxOffset);

    frame.addComponentListener(new ComponentAdapter() {

        public void componentResized(ComponentEvent e) {
            setWidth(new Integer(frame.getWidth()));
            setHeight(new Integer(frame.getHeight()));
        }

        public void componentMoved(ComponentEvent e) {
            setX(new Integer(frame.getX()));
            setY(new Integer(frame.getY()));
        }
    });
}

From source file:es.emergya.ui.base.BasicWindow.java

/**
 * Initialize the window with default values.
 *//*w w  w .  ja  v a 2s .  c  o m*/
private void inicializar() {
    frame = new JFrame(i18n.getString("title")); //$NON-NLS-1$
    getFrame().setBackground(Color.WHITE);
    getFrame().setIconImage(ICON_IMAGE); //$NON-NLS-1$
    getFrame().addWindowListener(new RemoveClientesConectadosListener());

    getFrame().setMinimumSize(new Dimension(900, 600));
    getFrame().addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            resize();
        }

    });

    busyCursor = new Cursor(Cursor.WAIT_CURSOR);
    defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = getImageIcon("/images/hand.gif");
    if (image != null)
        handCursor = toolkit.createCustomCursor(image, new Point(0, 0), "hand"); //$NON-NLS-1$
}

From source file:com.sshtools.powervnc.PowerVNCFullScreenWindowContainer.java

public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    getContentPane().invalidate();/*w w  w . j ava  2 s  . c  om*/
    //setUndecorated(true);
    this.panel = panel;
    this.application = application;
    setJMenuBar(((PowerVNCPanel) panel).getJMenuBar());
    // We dont want the status bar, menu bar or tool bar showing in full screen mode by default
    ((PowerVNCPanel) panel).setToolsVisible(false);
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0));
    panel.registerAction(exitAction = new ExitAction(application, this));
    panel.registerAction(newWindowAction = new NewWindowAction(application));
    panel.registerAction(aboutAction = new AboutAction(this, application));
    panel.registerAction(fullScreenAction = new FullScreenActionImpl(application, this));

    getApplicationPanel().rebuildActionComponents();
    JPanel p = new JPanel(new BorderLayout());
    if (panel.getToolBar() != null) {
        JPanel t = new JPanel(new BorderLayout());
        t.add(panel.getToolBar(), BorderLayout.NORTH);
        t.add(toolSeperator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {
            public void componentHidden(ComponentEvent evt) {
                log.debug("Tool separator is now " + pnl.getToolBar().isVisible());
                toolSeperator.setVisible(pnl.getToolBar().isVisible());
            }
        });
        p.add(t, BorderLayout.NORTH);
    }
    p.add(panel, BorderLayout.CENTER);
    if (panel.getStatusBar() != null) {
        p.add(panel.getStatusBar(), BorderLayout.SOUTH);
    }
    getContentPane().setLayout(new GridLayout(1, 1));
    getContentPane().add(p);
    // Watch for the frame closing
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            application.closeContainer(PowerVNCFullScreenWindowContainer.this);
        }
    });
    getContentPane().validate();
}

From source file:demo.AnimatingAddNodeDemo.java

@Override
public void init() {

    //create a graph
    Graph<Number, Number> ig = Graphs
            .<Number, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number, Number>());

    ObservableGraph<Number, Number> og = new ObservableGraph<Number, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<Number, Number>() {

        public void handleGraphEvent(GraphEvent<Number, Number> evt) {
            System.err.println("got " + evt);

        }/*from  www  .  j a  va  2s. c o  m*/
    });
    this.g = og;
    //create a graphdraw
    layout = new FRLayout<Number, Number>(g);
    layout.setSize(new Dimension(600, 600));
    Relaxer relaxer = new VisRunner((IterativeContext) layout);
    relaxer.stop();
    relaxer.prerelax();

    Layout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);

    vv = new VisualizationViewer<Number, Number>(staticLayout, new Dimension(600, 600));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));

    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);

    timer = new Timer();
}

From source file:edu.uci.ics.jung.samples.AnimatingAddNodeDemo.java

@Override
public void init() {

    //create a graph
    Graph<Number, Number> ig = Graphs
            .<Number, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number, Number>());

    ObservableGraph<Number, Number> og = new ObservableGraph<Number, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<Number, Number>() {

        public void handleGraphEvent(GraphEvent<Number, Number> evt) {
            System.err.println("got " + evt);

        }/*from   www.j  a va2s  . c  o m*/
    });
    this.g = og;
    //create a graphdraw
    layout = new FRLayout<Number, Number>(g);
    layout.setSize(new Dimension(600, 600));
    Relaxer relaxer = new VisRunner((IterativeContext) layout);
    relaxer.stop();
    relaxer.prerelax();

    Layout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);

    vv = new VisualizationViewer<Number, Number>(staticLayout, new Dimension(600, 600));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));

    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            System.err.println("resized");
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    switchLayout.addActionListener(new ActionListener() {

        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void actionPerformed(ActionEvent ae) {
            Dimension d = vv.getSize();//new Dimension(600,600);
            if (switchLayout.getText().indexOf("Spring") > 0) {
                switchLayout.setText("Switch to FRLayout");
                layout = new SpringLayout<Number, Number>(g, new ConstantTransformer(EDGE_LENGTH));
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);
                LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            } else {
                switchLayout.setText("Switch to SpringLayout");
                layout = new FRLayout<Number, Number>(g, d);
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);
                LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            }
        }
    });

    getContentPane().add(switchLayout, BorderLayout.SOUTH);

    timer = new Timer();
}

From source file:com.google.code.facebook.graph.sna.applet.AnimatingAddNodeDemo.java

@Override
public void init() {

    //create a graph
    Graph<Number, Number> ig = Graphs
            .<Number, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number, Number>());

    ObservableGraph<Number, Number> og = new ObservableGraph<Number, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<Number, Number>() {

        public void handleGraphEvent(GraphEvent<Number, Number> evt) {
            System.err.println("got " + evt);

        }// w ww  . j ava2 s  .c om
    });
    this.g = og;
    //create a graphdraw
    layout = new FRLayout<Number, Number>(g);
    layout.setSize(new Dimension(600, 600));
    Relaxer relaxer = new VisRunner((IterativeContext) layout);
    relaxer.stop();
    relaxer.prerelax();

    Layout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);

    vv = new VisualizationViewer<Number, Number>(staticLayout, new Dimension(600, 600));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));

    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            System.err.println("resized");
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    switchLayout.addActionListener(new ActionListener() {

        @SuppressWarnings("unchecked")
        public void actionPerformed(ActionEvent ae) {
            Dimension d = vv.getSize();//new Dimension(600,600);
            if (switchLayout.getText().indexOf("Spring") > 0) {
                switchLayout.setText("Switch to FRLayout");
                layout = new SpringLayout<Number, Number>(g, new ConstantTransformer(EDGE_LENGTH));
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);
                LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            } else {
                switchLayout.setText("Switch to SpringLayout");
                layout = new FRLayout<Number, Number>(g, d);
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout);
                LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            }
        }
    });

    getContentPane().add(switchLayout, BorderLayout.SOUTH);

    timer = new Timer();
}

From source file:org.tsho.dmc2.managers.TrajectoryManager.java

public TrajectoryManager(final TrajectoryComponent component, final TrajectoryControlForm2 form) {

    super(component);
    this.model = component.getModel();
    this.component = component;
    this.form = form;

    /* defaults */
    gridlines = true;/*w w w . j a v  a  2 s  .co m*/
    crosshair = false;
    bigDots = false;

    chart.setLegend(new StandardLegend());

    chart.setTitle(model.getName());
    setCrosshair(crosshair);

    plot.setForegroundAlpha(0.1F);

    if (model instanceof SimpleMap) {
        plot.setAntialias(false);
        connectDots = false;
    } else if (model instanceof ODE) {
        plot.setAntialias(true);
        connectDots = true;
    }

    plot.addCoreStatusListener(new CoreStatusListener() {
        public void sendCoreStatus(final CoreStatusEvent event) {
            if (event.getType() == CoreStatusEvent.REDRAW) {
                ((TrajectoryRenderer) plot.getPlotRenderer()).setContinua(false);
                launchThread(false);
            } else if (event.getType() == CoreStatusEvent.REPAINT) {
                chartPanel.repaint();
            }
        }
    });

    // stop everything on resizing
    // TODO fix
    chartPanel.addComponentListener(new ComponentAdapter() {
        public final void componentResized(final ComponentEvent e) {
            TrajectoryManager.this.stopRendering();
        }
    });
}

From source file:br.univali.ps.ui.telas.TelaPrincipal.java

private void instalarObservadorJanela() {
    JFrame frame = Lancador.getJFrame();
    if (frame == null)
        return;//from w w  w .  ja  va  2 s . c  o  m

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            fecharAplicativo();
        }

        @Override
        public void windowOpened(WindowEvent e) {
            Configuracoes configuracoes = Configuracoes.getInstancia();
            if (configuracoes.isExibirDicasInterface()) {
                SwingUtilities.invokeLater(() -> {
                    PortugolStudio.getInstancia().getTelaDicas().setVisible(true);
                });
            }

            LOGGER.log(Level.INFO, "Janela principal aberta!");
        }

    });

    Lancador.getJFrame().addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            if (abrindo) {
                abrindo = false;

                // Por enquanto o Andr pediu para desativar esta verificao, ela s estar disponvel 
                // no final do ano
                //verificarAtualizacaoCritica();
                if (Configuracoes.getInstancia().isExibirTutorialUso()) {
                    //TODO: criar e executar tutorial de uso antes de iniciar o Portugol
                    dispararProcessosAbertura();
                } else {
                    dispararProcessosAbertura();
                }
            }
        }
    });
}

From source file:com.sec.ose.osi.ui.frm.main.manage.JPanManageMain.java

/**
 * This is the default constructor/*  w ww. j  a  va 2 s.  c o  m*/
 */
public JPanManageMain(final JTabbedPaneMain jTabbedPaneMain) {
    super();
    initialize();
    addCacheable();

    ManageMediator.getInstance().setJPanManage(this);
    ManageMediator.getInstance().setProjectTableModel(getProjectTableModel());
    monitor = BackgroundJobManager.getInstance().startAnalysisMonitoThread();

    this.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            if (jTabbedPaneMain.getSelectedIndex() == JTabbedPaneMain.TAB_INDEX_MANAGE) {
                resetTableHederSize();
            }
        }
    });
}