List of usage examples for java.awt.event ComponentAdapter ComponentAdapter
ComponentAdapter
From source file:ProgressDialog.java
private void setupEventHandlers() { addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent event) { final Thread task = new Thread(runnable); task.start();//from ww w. j av a2 s . c om new Thread() { public void run() { try { task.join(); } catch (InterruptedException e) { } SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(false); } }); } }.start(); } }); }
From source file:org.fuin.kickstart4j.ErrorDialog.java
/** * {@inheritDoc}/*www . ja v a 2 s . co m*/ */ public void run() { final ErrorPanel panel = new ErrorPanel(); panel.setMessage(message); panel.setPreferredSize(new Dimension(600, 400)); panel.setCloseListener(new ErrorPanel.CloseListener() { public void onClose(final ErrorPanel panel) { System.exit(exitCode); } }); final JFrame frame = Utils4Swing.createShowAndPosition( new MessagesWrapper(Locale.getDefault()).getErrorMessageDialogTitle(), panel, false, new ScreenCenterPositioner()); frame.addComponentListener(new ComponentAdapter() { public void componentHidden(final ComponentEvent e) { System.exit(exitCode); } }); }
From source file:es.emergya.ui.base.plugins.PluggableJTabbedPane.java
public PluggableJTabbedPane() { super();/*from www. j a va 2s.c o m*/ addFloatingButtons(); this.addMouseListener(this); this.setUI(new MyTabbedPaneUI(this)); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { addFloatingButtons(); } }); }
From source file:org.tsho.dmc2.managers.ManifoldsManager.java
public ManifoldsManager(final DifferentiableMap model, final ManifoldsControlForm2 form, final ManagerListener2 frame) { super(frame); this.model = model; this.form = form; /* defaults */ setGridlines(true);//ww w .jav a 2 s. co m crosshair = false; plotRenderer = new ManifoldsRenderer(model, plot); plot.setPlotRenderer(plotRenderer); plot.setForegroundAlpha(0.2F); plot.setAntialias(false); setCrosshair(crosshair); chart.setTitle(model.getName()); plot.addCoreStatusListener(new CoreStatusListener() { public void sendCoreStatus(final CoreStatusEvent event) { if (event.getType() == CoreStatusEvent.REDRAW) { launchThread(); } else if (event.getType() == CoreStatusEvent.REPAINT) { chartPanel.repaint(); } } }); // stop everything on resizing chartPanel.addComponentListener(new ComponentAdapter() { public void componentResized(final ComponentEvent e) { ManifoldsManager.this.stopRendering(); } }); }
From source file:com.nbt.TileCanvas.java
public TileCanvas(final World world) { Validate.notNull(world, "world must not be null"); this.world = world; setFocusable(true);/*from ww w.j a va 2s . c o m*/ addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { int tileWidth = calculateWidth(); setTileWidth(tileWidth); int tileHeight = calculateHeight(); setTileHeight(tileHeight); save(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { TileCanvas.this.keyPressed(e); } }); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); int x = pixelsToTile(point.x); int z = pixelsToTile(point.y); int tileX = x + getTileX(); int tileZ = z + getTileZ(); int y = getAltitude(); Block block = world.getBlock(tileX, y, tileZ); blockClicked(block); } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int amount = e.getWheelRotation(); int altitude = getAltitude(); setAltitude(amount + altitude); updateXYZ(); doRepaint(); save(); } }); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { updateXYZ(); } }); new MouseDragAndDrop(this) { private int tileX, tileZ; @Override public void selected(MouseEvent e) { this.tileX = getTileX(); this.tileZ = getTileZ(); } @Override public void dragged(MouseEvent e) { MouseEvent startEvent = getStartEvent(); Point startPt = startEvent.getPoint(); Point releasePt = e.getPoint(); int x = tileX + (pixelsToTile(startPt.x) - pixelsToTile(releasePt.x)); int z = tileZ + (pixelsToTile(startPt.y) - pixelsToTile(releasePt.y)); setTileX(x); setTileZ(z); updateXYZ(); doRepaint(); } @Override public void dropped(MouseEvent press, MouseEvent release) { // Point startPt = press.getPoint(); // Point releasePt = release.getPoint(); // int x = getTileX() + pixelsToTile(startPt.x - releasePt.x); // int z = getTileZ() + pixelsToTile(startPt.y - releasePt.y); // setTileX(x); // setTileZ(z); // // updateXYZ(); // doRepaint(); save(); } }.install(); setLayout(null); hud = new HUD(); int width = 200, height = 200; hud.setSize(width, height); add(hud); }
From source file:org.tsho.dmc2.managers.BifurcationManager.java
public BifurcationManager(final Model model, final BifurcationControlForm2 form, final ManagerListener2 frame) { super(frame); this.model = model; this.form = form; /* defaults */ setGridlines(true);//from w w w . j a va 2 s. co m crosshair = false; plot.setForegroundAlpha(0.2F); plot.setAntialias(false); setCrosshair(crosshair); legend = new StandardLegend(); chart.setTitle(model.getName()); chart.setLegend(legend); plot.addCoreStatusListener(new CoreStatusListener() { public void sendCoreStatus(final CoreStatusEvent event) { if (event.getType() == CoreStatusEvent.REDRAW) { launchThread(); } else if (event.getType() == CoreStatusEvent.REPAINT) { chartPanel.repaint(); } } }); // stop everything on resizing chartPanel.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { BifurcationManager.this.stopRendering(); } }); }
From source file:hr.fer.zemris.vhdllab.platform.support.SimplisticEclipseBasedApplicationPage.java
@Override protected JComponent createControl() { projectExplorerPane = new JPanel(new BorderLayout()); editorsPane = new JPanel(new BorderLayout()); viewsTabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); viewsTabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if we're adding a component, ignore change of active // component if (!addingView && getViewsTabbedPane().getSelectedIndex() >= 0) { setActiveComponent(getComponent(getViewsTabbedPane().getSelectedIndex())); }/* ww w . j a va2 s .c o m*/ } }); final double horizontalLocation = 0.15; final double verticalLocation = 0.75; final JSplitPane horizontalPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, projectExplorerPane, editorsPane); horizontalPane.setDividerLocation(horizontalLocation); final JSplitPane verticalPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, horizontalPane, viewsTabbedPane); verticalPane.setDividerLocation(verticalLocation); JPanel maximizedPanel = new JPanel(new BorderLayout()); maximizedPanel.add(verticalPane, BorderLayout.CENTER); JPanel control = new JPanel(new BorderLayout()); control.add(maximizedPanel, BorderLayout.CENTER); control.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { horizontalPane.setDividerLocation(horizontalLocation); verticalPane.setDividerLocation(verticalLocation); } }); this.getPageDescriptor().buildInitialLayout(this); if (viewsTabbedPane.getTabCount() > 0) { viewsTabbedPane.setSelectedIndex(0); } Logger.getRootLogger().addAppender(new AppenderSkeleton() { @Override public boolean requiresLayout() { return false; } @Override public void close() { } @SuppressWarnings("synthetic-access") @Override protected void append(LoggingEvent event) { if (event.getLevel().equals(Level.INFO)) { Object message = event.getMessage(); if (message != null) { getActiveWindow().getStatusBar().setMessage(message.toString()); } } } }); return control; }
From source file:ImageBouncer.java
public ImageBouncer(Image image) { previousTimes = new long[128]; previousTimes[0] = System.currentTimeMillis(); previousIndex = 1;//from w w w .ja v a2 s .c o m previousFilled = false; mOriginalImage = image; setImageType("TYPE_INT_RGB"); Random random = new Random(); mX = random.nextFloat() * 500; mY = random.nextFloat() * 500; mWidth = image.getWidth(this); mHeight = image.getHeight(this); mDeltaX = random.nextFloat() * 3; mDeltaY = random.nextFloat() * 3; // Make sure points are within range. addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent ce) { Dimension d = getSize(); if (mX < 0) mX = 0; else if (mX + mWidth >= d.width) mX = d.width - mWidth - 1; if (mY < 0) mY = 0; else if (mY + mHeight >= d.height) mY = d.height - mHeight - 1; } }); }
From source file:gtu._work.ui.TextScanUI.java
private void initGUI() { try {/*w w w . j a v a 2 s . com*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { thisComponentResized(evt); } }); this.addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent evt) { System.out.println("this.windowStateChanged, event=" + evt); // TODO add your code for this.windowStateChanged } }); this.addWindowListener(new WindowAdapter() { public void windowIconified(WindowEvent evt) { System.out.println("this.windowIconified, event=" + evt); // TODO add your code for this.windowIconified } }); this.setTitle(TITLE); { jPanel1 = new JPanel(); getContentPane().add(jPanel1, BorderLayout.NORTH); GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1.setPreferredSize(new java.awt.Dimension(521, 89)); jPanel1.setBounds(0, 0, 521, 89); { jButton1 = new JButton(); jButton1.setText("File"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jButton2 = new JButton(); jButton2.setText("Clipboard"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } { contentFilter = new JTextField(); contentFilter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } public void removeUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } public void changedUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } }); } { fileFilter = new JTextField(); fileFilter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } public void removeUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } public void changedUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } }); } { totalLabel = new JLabel(); } { matchLabel = new JLabel(); } { jLabel4 = new JLabel(); jLabel4.setText("Match : "); } { jLabel2 = new JLabel(); jLabel2.setText("Total : "); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "All", "Match" }); contextFilter = new JComboBox(); contextFilter.setModel(jComboBox1Model); contextFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jTextField2filterAgain(); } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "Regex", "find" }); fileChk = new JComboBox(); fileChk.setModel(jComboBox1Model); fileChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { fileChkActionPerformed(evt); } }); } { jScrollPane2 = new JScrollPane(); { ListModel groupListModel = new DefaultComboBoxModel(); groupList = new JList(); jScrollPane2.setViewportView(groupList); groupList.setModel(groupListModel); groupList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { groupListKeyPressed(evt); } }); } } jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(16, 16) .addGroup(jPanel1Layout.createParallelGroup() .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(fileFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(fileChk, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(contentFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(contextFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE))) .addContainerGap(12, 12)); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(12, 12) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(contextFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE) .addComponent(fileChk, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE) .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(contentFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE) .addComponent(fileFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE)) .addGap(19) .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) .addContainerGap(16, 16)); } { jScrollPane1 = new JScrollPane(); getContentPane().add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(581, 235)); { ListModel jList1Model = new DefaultComboBoxModel(); matchList = new JList(); jScrollPane1.setViewportView(matchList); // matchList.setPreferredSize(new java.awt.Dimension(575, // 232));// ??? // ?? // XXX // TODO // IMPORT // !!!! matchList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jList1MouseClicked(evt); } }); matchList.setModel(jList1Model); } } this.setSize(697, 440); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.gcsc.vrl.jfreechart.JFXPlotContainerType.java
public JFXPlotContainerType() { setValueName("Plot"); // name of the visualization // Set layout this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.setPreferredSize(new Dimension(300, 200)); this.setMinimumSize(new Dimension(200, 120)); // Get the panel from the xychart chartContainer = new TransparentPanel(); // Set layout chartContainer.setLayout(new BorderLayout()); // Add ruler//from ww w. ja va 2 s . c o m ResizableContainer container = new ResizableContainer(chartContainer); add(container); addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { setValueOptions("width=" + getWidth() + ";" + "height=" + getHeight()); } }); }