javax.swing.JComponent#addHierarchyListener ( )源码实例Demo

下面列出了javax.swing.JComponent#addHierarchyListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: visualvm   文件: PackagesView.java
private void initListeners(final JComponent view) {
    view.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (view.isShowing()) {
                    view.removeHierarchyListener(this);
                    loadPackages(view);
                }
            }
        }
    });
    controller.addListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            refreshState(view);
        }
    });
}
 
源代码2 项目: ghidra   文件: ProviderToggleAction.java
private void installVisibilityTracker( final ComponentProviderAdapter provider ) {
    JComponent component = provider.getComponent();
    component.addHierarchyListener( new HierarchyListener() {
        
        public void hierarchyChanged( HierarchyEvent e ) {
            long changeFlags = e.getChangeFlags();
            if ( HierarchyEvent.SHOWING_CHANGED ==
                (changeFlags & HierarchyEvent.SHOWING_CHANGED) ) {
                setSelected( provider.isVisible() );
            }
        }
    } );
}
 
源代码3 项目: arcusplatform   文件: Oculus.java
public static void showDialog(String title, String message, int style) {
   JTextArea area = new JTextArea(message);
   area.setBackground(UIManager.getColor("OptionPane.background"));
   area.setEditable(false);
   JComponent content = area;

   // If the message is too long then wrap it in
   // a scrollable text area and make the font
   // fixed width.
   if (message.length() >= 128) {
      area.setFont(new Font("monospaced", Font.PLAIN, 12));

      JScrollPane jp = new JScrollPane(area);
      jp.getViewport().add(area);

      //area.setColumns(80);
      area.setLineWrap(true);

      jp.setPreferredSize(new Dimension(800,600));
      content = jp;
   }

   // Make the dialog resizable:
   // https://blogs.oracle.com/scblog/entry/tip_making_joptionpane_dialog_resizable
   final JComponent pane = content;
   pane.addHierarchyListener(new HierarchyListener() {
      public void hierarchyChanged(HierarchyEvent e) {
         Window window = SwingUtilities.getWindowAncestor(pane);
         if (window instanceof Dialog) {
            Dialog dialog = (Dialog)window;
            if (!dialog.isResizable()) {
               dialog.setResizable(true);
            }
         }
      }
   });

   JOptionPane.showMessageDialog(MAIN, pane, title, style);
}
 
源代码4 项目: arcusplatform   文件: Oculus.java
public static int showOKCancelDialog(String title, String message) {
   JTextArea area = new JTextArea(message);
   area.setBackground(UIManager.getColor("OptionPane.background"));
   area.setEditable(false);
   JComponent content = area;

   // If the message is too long then wrap it in
   // a scrollable text area and make the font
   // fixed width.
   if (message.length() >= 128) {
      area.setFont(new Font("monospaced", Font.PLAIN, 12));

      JScrollPane jp = new JScrollPane(area);
      jp.getViewport().add(area);

      //area.setColumns(80);
      area.setLineWrap(true);

      jp.setPreferredSize(new Dimension(800,600));
      content = jp;
   }

   // Make the dialog resizable:
   // https://blogs.oracle.com/scblog/entry/tip_making_joptionpane_dialog_resizable
   final JComponent pane = content;
   pane.addHierarchyListener(new HierarchyListener() {
      public void hierarchyChanged(HierarchyEvent e) {
         Window window = SwingUtilities.getWindowAncestor(pane);
         if (window instanceof Dialog) {
            Dialog dialog = (Dialog)window;
            if (!dialog.isResizable()) {
               dialog.setResizable(true);
            }
         }
      }
   });
   Object[] options = {"Cancel", "OK"};
   return JOptionPane.showOptionDialog(MAIN, pane, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
}
 
源代码5 项目: pumpernickel   文件: RootPaneListener.java
/**
 * This adds this listener to the argument <code>JComponent</code>.
 * 
 * @param jc
 *            the component added to this hierarchy tree.
 */
public void add(JComponent jc) {
	jc.addHierarchyListener(hierarchyListener);
	Object value = jc.getRootPane();
	if (value == null)
		value = NULL_VALUE;
	rootPanes.put(jc, value);
}
 
源代码6 项目: pumpernickel   文件: BasicAudioPlayerUI.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	getFields(c).install();
	c.addPropertyChangeListener(AudioPlayerComponent.SOURCE_KEY,
			updateSourceListener);
	c.addHierarchyListener(hierarchyListener);
}
 
源代码7 项目: littleluck   文件: SwingSet3.java
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName.equals("demoComponent")) {
        Demo demo = (Demo)e.getSource();
        JComponent demoComponent = (JComponent)e.getNewValue();
        if (demoComponent != null) {
            demoComponent.putClientProperty("swingset3.demo", demo);
            demoComponent.addHierarchyListener(new DemoVisibilityListener());
            registerPopups(demoComponent);
        }
    } 
}
 
源代码8 项目: beautyeye   文件: SwingSet3.java
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName.equals("demoComponent")) {
        Demo demo = (Demo)e.getSource();
        JComponent demoComponent = (JComponent)e.getNewValue();
        if (demoComponent != null) {
            demoComponent.putClientProperty("swingset3.demo", demo);
            demoComponent.addHierarchyListener(new DemoVisibilityListener());
            registerPopups(demoComponent);
        }
    } 
}