Example usage for javax.swing JButton getTopLevelAncestor

List of usage examples for javax.swing JButton getTopLevelAncestor

Introduction

In this page you can find the example usage for javax.swing JButton getTopLevelAncestor.

Prototype

@BeanProperty(bound = false)
@SuppressWarnings("deprecation")
public Container getTopLevelAncestor() 

Source Link

Document

Returns the top-level ancestor of this component (either the containing Window or Applet), or null if this component has not been added to any container.

Usage

From source file:net.rptools.maptool.client.ui.AddResourceDialog.java

public void initLocalDirectoryButton() {
    final JButton button = (JButton) getComponent("localDirectoryButton");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            FolderChooser folderChooser = new FolderChooser();
            folderChooser.setCurrentDirectory(MapTool.getFrame().getLoadFileChooser().getCurrentDirectory());
            folderChooser.setRecentListVisible(false);
            folderChooser.setFileHidingEnabled(true);
            folderChooser.setDialogTitle(I18N.getText("msg.title.loadAssetTree"));

            int result = folderChooser.showOpenDialog(button.getTopLevelAncestor());
            if (result == FolderChooser.APPROVE_OPTION) {
                File root = folderChooser.getSelectedFolder();
                getBrowseTextField().setText(root.getAbsolutePath());
            }//from   w ww.  ja  va2 s .c o  m
        }
    });
}

From source file:com.t3.client.ui.AddResourceDialog.java

public void initLocalDirectoryButton() {
    final JButton button = (JButton) getComponent("localDirectoryButton");
    button.addActionListener(new ActionListener() {
        @Override/* w  w w .  j ava  2 s.  co m*/
        public void actionPerformed(ActionEvent e) {

            FolderChooser folderChooser = new FolderChooser();
            folderChooser
                    .setCurrentDirectory(TabletopTool.getFrame().getLoadFileChooser().getCurrentDirectory());
            folderChooser.setRecentListVisible(false);
            folderChooser.setFileHidingEnabled(true);
            folderChooser.setDialogTitle(I18N.getText("msg.title.loadAssetTree"));

            int result = folderChooser.showOpenDialog(button.getTopLevelAncestor());
            if (result == FolderChooser.APPROVE_OPTION) {
                File root = folderChooser.getSelectedFolder();
                getBrowseTextField().setText(root.getAbsolutePath());
            }
        }
    });
}

From source file:tkwatch.Utilities.java

/**
 * Called by a button to close the containing window when actions are done.
 * /*w ww .  j a  va 2s .c  om*/
 * @param thisButton
 *            The button that closes its containing window.
 */
static final void closeFrame(JButton thisButton) {
    ((JFrame) thisButton.getTopLevelAncestor()).dispose();
}