List of usage examples for java.awt.event ComponentAdapter ComponentAdapter
ComponentAdapter
From source file:org.geopublishing.atlasViewer.swing.ClickInfoDialog.java
/** * This Dialog wraps a {@link ClickInfoPanel} that shows information when * the mouse clicked inside the {@link Map} and has hit a visible features. * /*from w w w.ja v a 2 s . c o m*/ * @param parentGUI * A {@link Component} that links to the parent GUI * * @param modal * * @param atlasConfig * may be <code>null</code> if not in atlas context * * @param layerManager * A {@link MapContextManagerInterface} to communicate with the * geotools {@link MapContext} */ public ClickInfoDialog(final Component parentGUI, final boolean modal, final MapContextManagerInterface layerManager, AtlasConfig atlasConfig) { super(SwingUtil.getParentWindow(parentGUI)); this.atlasConfig = atlasConfig; if (layerManager == null) { throw new IllegalArgumentException("MapContextManagerInterface may not be null!"); } setModal(modal); clickInfoPanel = new ClickInfoPanel(layerManager, ClickInfoDialog.this, this.atlasConfig); // **************************************************************************** // Ensure, that the VideoPlayer is never left unattended. // **************************************************************************** addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // clickInfoPanel.disposeVideoPlayer(); super.windowClosing(e); } }); addComponentListener(new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { userMovedTheWindow = true; // LOGGER.debug("Userinteraction TRUE!"); checkGlue(e); } @Override public void componentResized(ComponentEvent e) { final int newWidth = e.getComponent().getWidth(); final int newHeight = e.getComponent().getHeight(); /* * If rightGlue and the new width is less, move the window * right! */ if (rightGlue && newWidth < lastWidth) { int dif = (lastWidth - newWidth); setLocation(getLocation().x + dif, getLocation().y); } /* * If leftGlue all is automatically OK */ if (bottomGlue && newHeight < lastHeight) { int dif = (lastHeight - newHeight); setLocation(getLocation().x, getLocation().y + dif); } lastHeight = newHeight; lastWidth = newWidth; checkGlue(e); } private void checkGlue(final ComponentEvent e) { if ((e.getComponent().getWidth() + getLocation().x) == getToolkit().getScreenSize().width) { /** * The Window is now glued to the right. */ rightGlue = true; } else rightGlue = false; /** * Bottom GLUE is not yet supported because we can't properly * determine the bottom insets for windows + ubuntu */ // // int bottom = getToolkit().getScreenInsets( // ClickInfoDialog.this.getGraphicsConfiguration()).bottom; // // if ((e.getComponent().getHeight() + getLocation().y) == // (getToolkit() // .getScreenSize().height - bottom)) { // /** // * The Window is now glued to the bottom // */ // bottomGlue = true; // } else // bottomGlue = false; // // LOGGER.debug(bottom + "sd" // + getToolkit().getScreenSize().height + " sds " // + (e.getComponent().getHeight() + getLocation().y)); } }); final JPanel cp = new JPanel(new BorderLayout()); /** * Adding the Panel with a JScrollPane */ cp.add(new JScrollPane(clickInfoPanel), BorderLayout.CENTER); setContentPane(cp); setDefaultCloseOperation(HIDE_ON_CLOSE); }
From source file:utybo.branchingstorytree.swing.editor.StoryNodesEditor.java
public StoryNodesEditor() { setLayout(new MigLayout("", "[:33%:300px][grow 150]", "[grow][]")); JScrollPane scrollPane = new JScrollPane(); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollPane, "cell 0 0,grow"); jlist = new JList<>(); jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jlist.setCellRenderer(new SubstanceDefaultListCellRenderer() { @Override/*from w w w . j a v a 2s . co m*/ public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, o, index, isSelected, cellHasFocus); if (o instanceof StorySingleNodeEditor) { if (((StorySingleNodeEditor) o).getStatus() == Status.ERROR) label.setForeground(Color.RED.darker()); if (o instanceof StoryLogicalNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("LogicalNode", 16))); else if (o instanceof StoryTextNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("TextNode", 16))); else if (o instanceof StoryVirtualNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("VirtualNode", 16))); } return label; } }); jlist.addListSelectionListener(e -> { if (jlist.getSelectedValue() instanceof JComponent) { container.removeAll(); container.add(jlist.getSelectedValue()); container.revalidate(); container.repaint(); } }); JScrollablePanel pan = new JScrollablePanel(new BorderLayout(0, 0)); jlist.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { scrollPane.revalidate(); pan.revalidate(); jlist.revalidate(); revalidate(); repaint(); } }); pan.setScrollableWidth(ScrollableSizeHint.FIT); pan.setScrollableHeight(ScrollableSizeHint.STRETCH); pan.add(jlist, BorderLayout.CENTER); scrollPane.setViewportView(pan); container = new JPanel(); add(container, "cell 1 0,grow"); container.setLayout(new BorderLayout(0, 0)); container.add(new JPanel(), BorderLayout.CENTER); // TODO JPanel panel = new JPanel(); add(panel, "cell 0 1 2 1,alignx leading,growy"); JButton btnAddNode = new JButton(Lang.get("editor.panel.add"), new ImageIcon(Icons.getImage("Add Subnode", 16))); btnAddNode.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { createMenu().show(btnAddNode, e.getX(), e.getY()); } }); panel.add(btnAddNode); JButton btnRemoveNode = new JButton(Lang.get("editor.panel.remove"), new ImageIcon(Icons.getImage("Delete Subnode", 16))); btnRemoveNode.addActionListener(e -> removeNode()); panel.add(btnRemoveNode); }
From source file:TextBouncer.java
public TextBouncer(String s, Font f) { previousTimes = new long[128]; previousTimes[0] = System.currentTimeMillis(); previousIndex = 1;/* w w w . j av a 2 s . co m*/ previousFilled = false; mString = s; setFont(f); Random random = new Random(); mX = random.nextFloat() * 500; mY = random.nextFloat() * 500; mDeltaX = random.nextFloat() * 3; mDeltaY = random.nextFloat() * 3; mShearX = random.nextFloat() / 2; mShearY = random.nextFloat() / 2; mShearDeltaX = mShearDeltaY = .05f; FontRenderContext frc = new FontRenderContext(null, true, false); Rectangle2D bounds = getFont().getStringBounds(mString, frc); mWidth = (float) bounds.getWidth(); mHeight = (float) bounds.getHeight(); // 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:AnimatedMetadataGraph.java
@Override public void init() { //create a graph Graph<String, String> ig = Graphs .<String, String>synchronizedDirectedGraph(new DirectedSparseMultigraph<String, String>()); ObservableGraph<String, String> og = new ObservableGraph<String, String>(ig); og.addGraphEventListener(new GraphEventListener<String, String>() { public void handleGraphEvent(GraphEvent<String, String> evt) { System.err.println("got " + evt); }/*from ww w .jav a2s .c o m*/ }); this.g = og; //create a graphdraw layout = new FRLayout<String, String>(g); layout.setSize(new Dimension(600, 600)); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); Layout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); vv = new VisualizationViewer<String, String>(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<String>()); vv.setForeground(Color.black); 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<String, String>(g, new ConstantTransformer(EDGE_LENGTH)); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); LayoutTransition<String, String> lt = new LayoutTransition<String, String>(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<String, String>(g, d); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); LayoutTransition<String, String> lt = new LayoutTransition<String, String>(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:de.mprengemann.intellij.plugin.androidicons.forms.AndroidIconsImporter.java
public AndroidIconsImporter(@Nullable final Project project, Module module) { super(project, true); this.project = project; setTitle("Android Icons Importer"); setResizable(false);// w ww . j a v a2 s . co m AndroidResourcesHelper.initResourceBrowser(project, module, "Select res root", this.resRoot); assetRoot = SettingsHelper.getAssetPath(IconPack.ANDROID_ICONS); colorSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { assetColor = (String) colorSpinner.getSelectedItem(); updateImage(); } }); AssetSpinnerRenderer renderer = new AssetSpinnerRenderer(); //noinspection GtkPreferredJComboBoxRenderer assetSpinner.setRenderer(renderer); assetSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { assetName = (String) assetSpinner.getSelectedItem(); updateImage(); } }); fillComboBoxes(); resExportName.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent keyEvent) { super.keyTyped(keyEvent); if (!exportNameChanged && keyEvent != null && keyEvent.getKeyCode() > -1) { exportNameChanged = true; } } @Override public void keyPressed(KeyEvent keyEvent) { super.keyPressed(keyEvent); } @Override public void keyReleased(KeyEvent keyEvent) { super.keyReleased(keyEvent); } }); imageContainer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); updateImage(); } }); init(); }
From source file:com.sshtools.sshvnc.SshVncFullScreenWindowContainer.java
public void init(final SshToolsApplication application, SshToolsApplicationPanel panel) throws SshToolsApplicationException { getContentPane().invalidate();// ww w . ja va 2s . co m //setUndecorated(true); this.panel = panel; this.application = application; setJMenuBar(((SshVNCPanel) panel).getJMenuBar()); // We dont want the status bar, menu bar or tool bar showing in full screen mode by default ((SshVNCPanel) 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(changelogAction = new ChangelogAction(this, application)); panel.registerAction(faqAction = new FAQAction()); panel.registerAction(beginnerAction = new BeginnerAction()); panel.registerAction(advancedAction = new AdvancedAction()); 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(SshVncFullScreenWindowContainer.this); } }); getContentPane().validate(); }
From source file:es.emergya.ui.plugins.LayerSelectionDialog.java
public LayerSelectionDialog(CustomMapView gmv) { super();/*from ww w. j a va 2s . com*/ self = this; this.setTitle("Otras Capas"); actualizando = new JLabel(LogicConstants.getIcon("anim_actualizando")); this.setAlwaysOnTop(true); this.mv = gmv; this.layers = new ArrayList<LayerElement>(); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getIconImage()); } catch (Throwable e1) { LOG.error("Couldn't find icon image", e1); } JPanel base = new JPanel(); base.setPreferredSize(new Dimension(240, 150)); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.add(new JLabel(i18n.getString("map.layers.avaliable"))); list = new JPanel(); list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS)); list.add(actualizando); list.setBackground(Color.WHITE); // list.setPreferredSize(new Dimension(100, 100)); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setBackground(Color.WHITE); base.add(scrollPane); mv.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { } }); add(base); pack(); }
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 ww w . j av a2s . com*/ public void bind(final JDialog dialog, int initialWidth, int initialHeight) { updateSize(dialog, initialWidth, initialHeight); dialog.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { setWidth(new Integer(dialog.getWidth())); setHeight(new Integer(dialog.getHeight())); } }); }
From source file:org.tsho.dmc2.managers.ManifoldsManager.java
public ManifoldsManager(final DifferentiableMap model, final ManifoldsControlForm2 form, final ManagerListener2 frame, final DmcChartPanel otherPanel) { super(frame); this.model = model; this.form = form; /* defaults */ setGridlines(true);//from ww w.j av a 2 s . co m crosshair = false; xAxis = (NumberAxis) ((DmcRenderablePlot) otherPanel.getChart().getPlot()).getDomainAxis(); yAxis = (NumberAxis) ((DmcRenderablePlot) otherPanel.getChart().getPlot()).getRangeAxis(); plot = new DmcRenderablePlot(xAxis, yAxis); plotRenderer = new ManifoldsRenderer(model, plot); plot.setPlotRenderer(plotRenderer); plot.addCoreStatusListener(new CoreStatusListener() { public void sendCoreStatus(final CoreStatusEvent event) { if (event.getType() == CoreStatusEvent.REDRAW) { launchThread(); } else if (event.getType() == CoreStatusEvent.REPAINT) { chartPanel.repaint(); } } }); chart = new JFreeChart(model.getName(), plot); chartPanel = new DmcChartPanel(chart); chartPanel.setMouseZoomable(true, false); // stop everything on resizing chartPanel.addComponentListener(new ComponentAdapter() { public void componentResized(final ComponentEvent e) { ManifoldsManager.this.stopRendering(); } }); setCrosshair(crosshair); }
From source file:com.sshtools.sshterm.SshTermFullScreenWindowContainer.java
public void init(final SshToolsApplication application, SshToolsApplicationPanel panel) throws SshToolsApplicationException { // getContentPane().invalidate(); invalidate();// w ww. j a v a2s . c o m try { Method m = getClass().getMethod("setUndecorated", new Class[] { boolean.class }); m.invoke(this, new Object[] { Boolean.TRUE }); } catch (Exception e) { e.printStackTrace(); } this.panel = panel; this.application = application; // We dont want the status bar, menu bar or tool bar showing in full screen mode by default ((SshTerminalPanel) 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(changelogAction = new ChangelogAction(this, application)); panel.registerAction(faqAction = new FAQAction()); panel.registerAction(beginnerAction = new BeginnerAction()); panel.registerAction(advancedAction = new AdvancedAction()); 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); } JPanel x = new JPanel(new BorderLayout()); x.add(((SshTerminalPanel) panel).getJMenuBar(), BorderLayout.NORTH); x.add(p, BorderLayout.CENTER); getContentPane().setLayout(new GridLayout(1, 1)); getContentPane().add(x); // Watch for the frame closing addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { application.closeContainer(SshTermFullScreenWindowContainer.this); } }); validate(); }