buttonLayout.setHgap(hGap); gui.setBorder(new EmptyBorder(vBorder,hBorder,vBorder,hBorder)); Container c = gui.getTopLevelAncestor(); if (c instanceof Window) { Window w = (Window)c;
private void popupAlternate(URI uri) { JOptionPane.showMessageDialog(sourceComponent.getTopLevelAncestor(), "Please visit burpco2.com for assistance"); } }
@Override public void actionPerformed(ActionEvent e) { ((Frame) ((JComponent) m_mainApp).getTopLevelAncestor()).dispose(); System.exit(0); } });
@Override public void actionPerformed(ActionEvent e) { ((Frame) ((JComponent) m_mainApp).getTopLevelAncestor()).dispose(); System.exit(0); } });
private void update(final Graph graph, final JTextArea textArea, final List<Node> nodes1, final List<Node> nodes2, final String method) { Window owner = (Window) JOptionUtils.centeringComp().getTopLevelAncestor(); final WatchedProcess process = new WatchedProcess(owner) { public void watch() { if ("Directed Paths".equals(method)) { textArea.setText(""); allDirectedPaths(graph, textArea, nodes1, nodes2); } else if ("Semidirected Paths".equals(method)) { textArea.setText(""); allSemidirectedPaths(graph, textArea, nodes1, nodes2); } else if ("Treks".equals(method)) { textArea.setText(""); allTreks(graph, textArea, nodes1, nodes2); } else if ("Adjacents".equals(method)) { textArea.setText(""); adjacentNodes(graph, textArea, nodes1, nodes2); } } }; }
@Override public void actionPerformed(ActionEvent e) { try { Frame ancestor = (Frame) JOptionUtils.centeringComp().getTopLevelAncestor(); JComponent comp = new HpcJobActivityEditor(); JOptionPane.showMessageDialog(ancestor, comp, TITLE, JOptionPane.PLAIN_MESSAGE); } catch (HeadlessException e1) { // e1.printStackTrace(); } catch (Exception e1) { // e1.printStackTrace(); } }
public static boolean writeToFile(JComponent parent, String source) { JFileChooser fc = new JFileChooser("Saving Data"); int returnVal = fc.showSaveDialog(parent.getTopLevelAncestor()); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile();
public static boolean writeToFile(JComponent parent, BufferedImage image) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showSaveDialog(parent.getTopLevelAncestor()); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile();
/** * Adds this adapter to a <code>JComponent</code>. * <strong>Use this method instead of calling * <code>cmp.addAncestorListener(...)</code></strong> * because this method will automatically detect * the component's window. This is crucial for * <code>JRootPane</code> components, because they are already * attached to a window when you register the * listener. * * @param c the <code>JComponent</code> who will be tracked for * ancestor changes. * @see javax.swing.JComponent#addAncestorListener( AncestorListener ) */ public void addTo( JComponent c ) { if( cmp != null ) throw new IllegalStateException( "Already added" ); cmp = c; c.addAncestorListener( this ); learnWindow( c.getTopLevelAncestor() ); }
public static void startWaitCursor(JComponent component) { RootPaneContainer root = (RootPaneContainer) component.getTopLevelAncestor(); startWaitCursor(root.getGlassPane()); root.getGlassPane().setVisible(true); }
public static void stopWaitCursor(JComponent component) { RootPaneContainer root = (RootPaneContainer) component.getTopLevelAncestor(); stopWaitCursor(root.getGlassPane()); root.getGlassPane().setVisible(false); }
/** * Checks if a component is an excluded component. If a component is an excluded component, clicking on it will not * hide the popup. By default, owner is always the excluded component. * * @param component a component. * @return true if the component is an excluded component. */ public boolean isExcludedComponent(Component component) { boolean contain = _excludedComponents.contains(component); if (!contain) { for (Component c : _excludedComponents) { if (c instanceof Container) { if (((Container) c).isAncestorOf(component)) { return true; } } } if (component instanceof JComponent) { Container c = ((JComponent) component).getTopLevelAncestor(); if (c instanceof RootPaneContainer) { JComponent realParent = getRealParent((RootPaneContainer) c); if (realParent != null && realParent.getTopLevelAncestor() == getTopLevelAncestor()) { return true; } } } } return contain; }
dataLoadingIndicatorBox.add(progressBarBox); Frame ancestor = (Frame) JOptionUtils.centeringComp().getTopLevelAncestor();
@Override public void mouseReleased(MouseEvent e) { JComponent c = (JComponent) e.getSource(); if (c.getTopLevelAncestor().getBounds().contains(e.getLocationOnScreen())) { // do nothing, the drop point is the same frame } else { DragTabFrame dtf = getTargetFrame(e.getLocationOnScreen()); if (dtf == null) { dtf = new DragTabFrame(); dtf.init(); dtf.setLocation(e.getLocationOnScreen()); }// else { DragTabFrame fromFrame = dragTabManager.getCurrentFrame(); fromFrame.removeTabComponent(c); JTabbedPane tp = fromFrame.getTabbedPane(); if (tp.getTabCount() == 0) { fromFrame.setVisible(false); fromFrame.dispose(); } //} dtf.addTabComponent(dragTabManager.getCurrentTitle(), c); dtf.pack(); dtf.setVisible(true); } }
/** * Dismisses this glass box. This causes the glass box to be removed from * it's parent and ensure that the display is correctly updated. */ public void dismiss() { JComponent parent = (JComponent) getParent(); if (parent != null) { Container toplevel = parent.getTopLevelAncestor(); parent.remove(this); toplevel.validate(); toplevel.repaint(); } }
private boolean existsOtherDialog() { Frame ancestor = (Frame) JOptionUtils.centeringComp() .getTopLevelAncestor(); Window[] ownedWindows = ancestor.getOwnedWindows(); for (Window window : ownedWindows) { if (window instanceof Dialog && !(window == getStopDialog()) && !(window == getOwner())) { Dialog dialog = (Dialog) window; if (dialog.isVisible()) { return true; } } } return false; }
Container c = _resizable.getComponent().getTopLevelAncestor(); if (c instanceof JFrame) { ((JFrame) _resizable.getComponent().getTopLevelAncestor()).getGlassPane().setCursor(Cursor.getDefaultCursor()); ((JFrame) _resizable.getComponent().getTopLevelAncestor()).getGlassPane().setVisible(false);
/** * Called when the tracked component or one of * its ancestors gets added in the container hierarchy. * This method checks to see if a change in the * component's top level window occured, and if * so, re-registers window and component listeners * on that window. Also if the window is visible * and the dynamic listener is not yet listening, * its <code>startListening</code> method is invoked. */ public void ancestorAdded( AncestorEvent e ) { if( EventManager.DEBUG_EVENTS ) { System.err.println( "ancestorAdded. cmp = "+(e.getComponent() != null ? e.getComponent().getClass().getName() : null)+ "\n anc = "+(e.getAncestor() != null ? e.getAncestor().getClass().getName() : null)+ "\n par = "+(e.getAncestorParent() != null ? e.getAncestorParent().getClass().getName() : null) ); } Container c = e.getComponent().getTopLevelAncestor(); if( c != win ) { forgetWindow(); learnWindow( c ); } }
private Component getTopLevelAncestor(JComponent s, int x, int y) { // return s.getTopLevelAncestor(); Component r = s.getTopLevelAncestor(); Point p = SwingUtilities.convertPoint(s, x, y, r); Rectangle b = r.getBounds(); b.x = b.y = 0; if (b.contains(p)) { if (r instanceof Frame) ((Frame) r).toFront(); // System.err.println("TOP="+r.getClass()); return r; } p = s.getLocationOnScreen(); p.x += x; p.y += y; if (windows_ == null) windows_ = DndLib.getAllWindows(); if (windows_ != null) for (int i = 0; i < windows_.length; i++) if (windows_[i].isShowing()) { Point q = windows_[i].getLocationOnScreen(); b = windows_[i].getBounds(); b.x = q.x; b.y = q.y; if (b.contains(p)) { windows_[i].toFront(); return windows_[i]; } } return null; }
if (realParent != null && realParent.getTopLevelAncestor() == getTopLevelAncestor()) { return;