List of usage examples for java.awt.event ComponentEvent getComponent
public Component getComponent()
From source file:ComponentEventDemo.java
public void componentShown(ComponentEvent e) { displayMessage("componentShown event from " + e.getComponent().getClass().getName()); }
From source file:ComponentEventDemo.java
public void componentHidden(ComponentEvent e) { displayMessage("componentHidden event from " + e.getComponent().getClass().getName()); }
From source file:it.unibas.spicygui.controllo.datasource.ActionViewInstances.java
public ActionViewInstances() { executeInjection();/* w w w . ja v a2 s. c o m*/ componentAdapter = new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { InstancesTopComponent instancesTopComponent = (InstancesTopComponent) e.getComponent(); instancesTopComponent.setSplitPaneDivider(); } }; this.putValue(SHORT_DESCRIPTION, NbBundle.getMessage(Costanti.class, Costanti.ACTION_VIEW_INSTANCES_TOOLTIP)); this.setEnabled(false); registraAzione(); }
From source file:com.intel.stl.ui.monitor.view.PSEventsCardView.java
@Override protected JComponent getMainComponent() { if (mainPanel != null) { return mainPanel; }//from w ww. ja v a2 s . c o m mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 5)); GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.weightx = 0; piePanel = new NodeStatesPie(false); piePanel.setOpaque(false); mainPanel.add(piePanel, gc); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.weighty = 1; gc.gridwidth = GridBagConstraints.REMAINDER; barPanel = new ChartPanel(null); barPanel.setPreferredSize(new Dimension(60, 20)); barPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { barPanel.setMaximumDrawHeight(e.getComponent().getHeight()); barPanel.setMaximumDrawWidth(e.getComponent().getWidth()); barPanel.setMinimumDrawWidth(e.getComponent().getWidth()); barPanel.setMinimumDrawHeight(e.getComponent().getHeight()); } }); barPanel.setOpaque(false); mainPanel.add(barPanel, gc); return mainPanel; }
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); }// w ww . j a v a 2 s . 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:com.intel.stl.ui.main.view.HealthHistoryView.java
@Override protected JPanel getMainComponent() { if (mainPanel != null) { return mainPanel; }/*w w w .j a va 2 s . co m*/ mainPanel = new JPanel(); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.weighty = 1; gc.gridwidth = GridBagConstraints.REMAINDER; chartPanel = new ChartPanel(null); // chart.PanelsetBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, // UIConstants.INTEL_BORDER_GRAY)); chartPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { chartPanel.setMaximumDrawHeight(e.getComponent().getHeight()); chartPanel.setMaximumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawHeight(e.getComponent().getHeight()); } }); mainPanel.add(chartPanel, gc); gc.gridwidth = 1; gc.insets = new Insets(0, 5, 0, 5); gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.WEST; gc.weighty = 0; startTimeLabel = ComponentFactory.getH5Label("start", Font.PLAIN); mainPanel.add(startTimeLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.anchor = GridBagConstraints.EAST; endTimeLabel = ComponentFactory.getH5Label("end", Font.PLAIN); mainPanel.add(endTimeLabel, gc); return mainPanel; }
From source file:be.ac.ua.comp.scarletnebula.gui.SSHPanel.java
public SSHPanel(final Server server) { super();/*www. j a v a2 s. c om*/ final JCTermSwing term = new JCTermSwing(); term.setCompression(7); term.setAntiAliasing(true); setLayout(new BorderLayout()); addComponentListener(new ComponentListener() { @Override public void componentShown(final ComponentEvent e) { } @Override public void componentResized(final ComponentEvent e) { final Component c = e.getComponent(); int cw = c.getWidth(); int ch = c.getHeight(); final JPanel source = ((JPanel) c); final int cwm = source.getBorder() != null ? source.getBorder().getBorderInsets(c).left + source.getBorder().getBorderInsets(c).right : 0; final int chm = source.getBorder() != null ? source.getBorder().getBorderInsets(c).bottom + source.getBorder().getBorderInsets(c).top : 0; cw -= cwm; ch -= chm; term.setBorder(BorderFactory.createMatteBorder(0, 0, term.getTermHeight() - c.getHeight(), term.getTermWidth() - c.getWidth(), Color.BLACK)); term.setSize(cw, ch); term.setPreferredSize(new Dimension(cw, ch)); // term.setMinimumSize(new Dimension(cw, ch)); term.setMaximumSize(new Dimension(cw, ch)); term.redraw(0, 0, term.getTermWidth(), term.getTermHeight()); } @Override public void componentMoved(final ComponentEvent e) { // TODO // Auto-generated // method // stub } @Override public void componentHidden(final ComponentEvent e) { // TODO // Auto-generated // method // stub } }); add(term, BorderLayout.CENTER); setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20), BorderFactory.createBevelBorder(BevelBorder.LOWERED))); final Thread connectionThread = new Thread() { @Override public void run() { Connection connection = null; try { final SSHCommandConnection commandConnection = (SSHCommandConnection) server .newCommandConnection(new NotPromptingJschUserInfo()); connection = commandConnection.getJSchTerminalConnection(); term.requestFocusInWindow(); term.start(connection); } catch (final Exception e) { for (final ExceptionListener listener : exceptionListeners) { listener.exceptionThrown(e); } log.warn("Exception thrown by SSHPanel", e); } finally { } } }; connectionThread.start(); }
From source file:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes *///from w ww . j av a 2 s .c o m public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }
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 w w . j a v a2s . 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") 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: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); }// w w w . j a v a 2 s .co 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(); }