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:jasmine.imaging.shapes.RadiusChart.java

public RadiusChart(double[] values) {

    super();/*  ww w .  j a  va2s.  com*/

    DefaultCategoryDataset series = new DefaultCategoryDataset();

    for (int i = 0; i < values.length; i++) {
        series.addValue(values[i], "row1", String.valueOf(i));
    }

    setTitle("Radius Change");

    chart = new JLabel();
    getContentPane().add(chart);

    setSize(320, 240);
    setVisible(true);

    myChart = ChartFactory.createLineChart(null, null, null, series, PlotOrientation.VERTICAL, false, false,
            false);

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            if (myChart != null)
                updateChart();
        }
    });

}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java

public DesktopScrollBoxLayout() {
    impl = new JScrollPane();
    // by default it is turned off
    impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    impl.setBorder(null);/*from   w w w  . java2  s .  co  m*/

    content = new DesktopVBox();

    DesktopVBox contentPane = new DesktopVBox();
    contentPane.setContainer(this);
    contentPane.add(content);

    impl.setViewportView(DesktopComponentsHelper.getComposition(contentPane));

    applyScrollBarPolicy(scrollBarPolicy);

    // support tables with 100% width like in web
    impl.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            adjustViewPreferredSize();
        }
    });

    setWidth("100%");
}

From source file:com.frostwire.gui.library.LibraryCoverArt.java

public LibraryCoverArt() {
    background = new BufferedImage(350, 350, BufferedImage.TYPE_INT_ARGB);
    defaultCoverArt = GUIMediator.getThemeImage("default_cover_art").getImage();
    setFile(null);//from  w  w w.j av a2  s  .com
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            updateTheme();
        }
    });
    ThemeMediator.addThemeObserver(this);
}

From source file:org.optaplanner.examples.tsp.swingui.TspWorldPanel.java

public TspWorldPanel(TspPanel tspPanel) {
    this.tspPanel = tspPanel;
    addComponentListener(new ComponentAdapter() {
        @Override/* w  ww.ja v  a 2s.com*/
        public void componentResized(ComponentEvent e) {
            // TODO Not thread-safe during solving
            TravelingSalesmanTour travelingSalesmanTour = TspWorldPanel.this.tspPanel
                    .getTravelingSalesmanTour();
            if (travelingSalesmanTour != null) {
                resetPanel(travelingSalesmanTour);
            }
        }
    });
    MouseAdapter mouseAdapter = new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (translator != null) {
                double longitude = translator.translateXToLongitude(e.getX());
                double latitude = translator.translateYToLatitude(e.getY());
                if (e.getButton() == MouseEvent.BUTTON1) {
                    dragSourceStandstill = TspWorldPanel.this.tspPanel
                            .findNearestStandstill(new AirLocation(-1L, latitude, longitude));
                    TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour();
                    dragTargetStandstill = tour.getDomicile();
                    resetPanel(tour);
                } else if (e.getButton() == MouseEvent.BUTTON2 || e.getButton() == MouseEvent.BUTTON3) {
                    TspWorldPanel.this.tspPanel.insertLocationAndVisit(longitude, latitude);
                }
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (translator != null) {
                if (dragSourceStandstill != null) {
                    double longitude = translator.translateXToLongitude(e.getX());
                    double latitude = translator.translateYToLatitude(e.getY());
                    dragTargetStandstill = TspWorldPanel.this.tspPanel
                            .findNearestStandstill(new AirLocation(-1L, latitude, longitude));
                    TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour();
                    if (dragSourceStandstill == dragTargetStandstill) {
                        dragTargetStandstill = tour.getDomicile();
                    }
                    resetPanel(tour);
                }
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (translator != null) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    double longitude = translator.translateXToLongitude(e.getX());
                    double latitude = translator.translateYToLatitude(e.getY());
                    dragTargetStandstill = TspWorldPanel.this.tspPanel
                            .findNearestStandstill(new AirLocation(-1L, latitude, longitude));
                    TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour();
                    if (dragSourceStandstill == dragTargetStandstill) {
                        dragTargetStandstill = tour.getDomicile();
                    }
                    Standstill sourceStandstill = TspWorldPanel.this.dragSourceStandstill;
                    Standstill targetStandstill = TspWorldPanel.this.dragTargetStandstill;
                    TspWorldPanel.this.dragSourceStandstill = null;
                    TspWorldPanel.this.dragTargetStandstill = null;
                    // connectStandstills() will call resetPanel()
                    TspWorldPanel.this.tspPanel.connectStandstills(sourceStandstill, targetStandstill);
                }
            }
        }
    };
    addMouseListener(mouseAdapter);
    addMouseMotionListener(mouseAdapter);
    europaBackground = new ImageIcon(getClass().getResource("europaBackground.png"));
}

From source file:com.hammurapi.jcapture.CaptureFrame.java

public CaptureFrame(final AbstractCaptureApplet applet) throws Exception {
    super("Screen capture");
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("camera.png")));

    setUndecorated(true);/*from   w w w  .j a va2  s .c o m*/

    Translucener.makeFrameTranslucent(this);

    setAlwaysOnTop(true);
    this.applet = applet;
    captureConfig = new CaptureConfig();
    captureConfig.load(applet.loadConfig());
    captureConfig.setBackgroundProcessor(applet.getBackgroundProcessor());

    //--- GUI construction ---

    capturePanel = new JPanel();

    final JLabel dimensionsLabel = new JLabel("");
    capturePanel.add(dimensionsLabel, BorderLayout.CENTER);

    capturePanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            dimensionsLabel.setText(e.getComponent().getWidth() + " x " + e.getComponent().getHeight());
        }
    });

    JButton captureButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            capturing.set(true);
            setVisible(false);
        }

    });
    captureButton.setText("Capture");
    captureButton.setToolTipText("Create a snapshot of the screen");
    capturePanel.add(captureButton, BorderLayout.CENTER);

    recordButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            recording.set(true);
            setVisible(false);
        }

    });
    recordButton.setText("Record");
    setRecordButtonState();
    capturePanel.add(recordButton, BorderLayout.CENTER);

    JButton optionsButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new CaptureOptionsDialog(CaptureFrame.this).setVisible(true);
        }

    });
    optionsButton.setText("Options");
    capturePanel.add(optionsButton, BorderLayout.CENTER);

    JButton cancelButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CaptureFrame.this.setVisible(false);
        }

    });
    cancelButton.setText("Cancel");
    capturePanel.add(cancelButton, BorderLayout.CENTER);

    getContentPane().add(capturePanel, BorderLayout.CENTER);

    capturePanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));

    if (captureConfig.getRecordingRectangle() == null) {
        setSize(400, 300);
        setLocationRelativeTo(null);
    } else {
        setBounds(captureConfig.getRecordingRectangle());
    }

    Insets dragInsets = new Insets(5, 5, 5, 5);
    new ComponentResizer(dragInsets, this);

    ComponentMover cm = new ComponentMover();
    cm.registerComponent(this);
    cm.setDragInsets(dragInsets);

    addComponentListener(new ComponentListener() {

        @Override
        public void componentShown(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentResized(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentMoved(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentHidden(ComponentEvent e) {
            if (capturing.get()) {
                capturing.set(false);
                try {
                    capture();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else if (recording.get()) {
                recording.set(false);
                record();
            }
        }
    });

}

From source file:it.unibas.spicygui.vista.TGDTabbedPane.java

public TGDTabbedPane(ConstantFORule fORuleParameter, Scenario scenarioParameter, MappingTask mappingTask) {
    this.constantFORule = fORuleParameter;
    this.scenario = scenarioParameter;
    initComponents();//from   w  w w. j a  v  a2 s  .  com
    initArea(fORuleParameter.toLogicalString(mappingTask));
    this.setVisible(true);
    this.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent e) {
            scenario.setSelectedFORule(null);
            scenario.setSelectedConstantFORule(constantFORule);
            scenario.getTGDCorrespondencesTopComponent().drawConnections();
        }
    });
    //        creaPopUp();
}

From source file:JavaXWin.java

public JavaXWin() {
    setTitle("JavaXWin");
    m_count = m_tencount = 0;/* w  ww  . j  a v a  2 s. c  o  m*/
    m_desktop = new JDesktopPane();

    JScrollPane scroller = new JScrollPane();
    m_wm = new WindowManager(m_desktop);
    m_desktop.setDesktopManager(m_wm);
    m_desktop.add(m_wm.getWindowWatcher(), JLayeredPane.PALETTE_LAYER);
    m_wm.getWindowWatcher().setBounds(555, 5, 200, 150);

    viewport = new JViewport() {
        public void setViewPosition(Point p) {
            super.setViewPosition(p);
            m_wm.getWindowWatcher().setLocation(m_wm.getWindowWatcher().getX() + (getViewPosition().x - m_wmX),
                    m_wm.getWindowWatcher().getY() + (getViewPosition().y - m_wmY));
            m_wmX = getViewPosition().x;
            m_wmY = getViewPosition().y;
        }
    };
    viewport.setView(m_desktop);
    scroller.setViewport(viewport);

    ComponentAdapter ca = new ComponentAdapter() {
        JViewport view = viewport;

        public void componentResized(ComponentEvent e) {
            m_wm.getWindowWatcher().setLocation(
                    view.getViewPosition().x + view.getWidth() - m_wm.getWindowWatcher().getWidth() - 15,
                    view.getViewPosition().y + 5);
        }
    };
    viewport.addComponentListener(ca);

    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newFrame();
        }
    });

    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", scroller);

    topPanel.add(m_newFrame);

    Dimension dim = getToolkit().getScreenSize();
    setSize(800, 600);
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    m_desktop.setPreferredSize(new Dimension(1600, 1200));
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
}

From source file:view.ImagePanel.java

public ImagePanel() {
    super();//ww  w  . ja va  2s  . c  om
    this.addComponentListener(new ComponentAdapter() {
        @Override
        public synchronized void componentResized(ComponentEvent e) {
            if (svList != null) {
                refreshSignatureValidationListPanels();
            }
        }
    });
}

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

public LyapunovManager(LyapunovComponent component) {

    super((ManagerListener2) component);
    this.component = component;
    this.model = component.getModel();
    this.form = (LyapunovControlForm2) component.getControlForm();

    /* defaults */
    setGridlines(true);//w ww. ja  v a 2  s .  c om
    crosshair = false;

    this.type = LyapunovControlForm2.TYPE_VS_TIME;

    renderer = new LyapunovRenderer(plot, model, component);
    plot.setPlotRenderer(renderer);

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

    chart.setLegend(new StandardLegend());

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

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

From source file:Bouncer.java

public Bouncer() {
    previousTimes = new long[128];
    previousTimes[0] = System.currentTimeMillis();
    previousIndex = 1;/*  w  w w.  j  a v  a2 s  .  c o  m*/
    previousFilled = false;

    mN = 38;
    mPoints = new float[mN];
    mDeltas = new float[mN];
    Random random = new Random();
    for (int i = 0; i < mN; i++) {
        mPoints[i] = random.nextFloat() * 500;
        mDeltas[i] = random.nextFloat() * 3;
    }

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent ce) {
            Dimension d = getSize();
            for (int i = 0; i < mN; i++) {
                int limit = ((i % 2) == 0) ? d.width : d.height;
                if (mPoints[i] < 0)
                    mPoints[i] = 0;
                else if (mPoints[i] >= limit)
                    mPoints[i] = limit - 1;
            }
        }
    });
}