Example usage for java.awt.event ComponentAdapter ComponentAdapter

List of usage examples for java.awt.event ComponentAdapter ComponentAdapter

Introduction

In this page you can find the example usage for java.awt.event ComponentAdapter ComponentAdapter.

Prototype

ComponentAdapter

Source Link

Usage

From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java

/**
 * Creates a {@link JGraphXVisualizer} object.
 *///from   w  w w  .  j  a  v a2s .co  m
public JGraphXVisualizer() {

    graph = new mxGraph();
    graph.setCellsEditable(false);
    graph.setAllowDanglingEdges(false);
    graph.setAllowLoops(false);
    graph.setCellsDeletable(false);
    graph.setCellsCloneable(false);
    graph.setCellsDisconnectable(false);
    graph.setDropEnabled(false);
    graph.setSplitEnabled(false);
    graph.setCellsBendable(false);
    graph.setConnectableEdges(false);
    graph.setCellsMovable(false);
    graph.setCellsResizable(false);
    graph.setAutoSizeCells(true);

    component = new mxGraphComponent(graph);
    component.setConnectable(false);

    component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    nodeLookupMap = new DualHashBidiMap<>();
    connToEdgeLookupMap = new MultiValueMap<>();
    edgeToConnLookupMap = new HashMap<>();
    vertexLingerTriggerMap = new HashMap<>();

    textOutputArea = new JTextArea();
    textOutputArea.setLineWrap(false);
    textOutputArea.setEditable(false);
    JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea);
    textOutputScrollPane.setPreferredSize(new Dimension(0, 100));

    frame = new JFrame("Visualizer");
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane);
    splitPane.setResizeWeight(1.0);

    frame.setContentPane(splitPane);

    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            zoomFit();
        }
    });

    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            Recorder<A> rec = recorder.get();
            if (rec != null) {
                IOUtils.closeQuietly(rec);
            }

            VisualizerEventListener veListener = listener.get();
            if (veListener != null) {
                veListener.closed();
            }
        }
    });

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    splitPane.setDividerLocation(0.2);
}

From source file:es.emergya.ui.gis.HistoryMapViewer.java

/**
 * // w  ww .j a  v  a2s .c  o  m
 * @see MapViewer#reset()
 */
@Override
public void setup() {
    log.trace("setup()");
    super.setup();

    gpxToggleButton = null;
    ListaCapas.quitListaCapas();
    this.mapView.layerControls.add(getGPXButton());
    this.mapView.layerControls.add(getResultadoHistoricos());

    this.mapView.setInitAdapter(this.mapView.new InitAdapter() {

        @Override
        protected void initControlPanels() {
            super.initControlPanels();
            mapView.add(createHistoryControls());
        }

        @Override
        protected void setResizeListeners() {
            super.setResizeListeners();
            mapView.addComponentListener(new ComponentAdapter() {

                @Override
                public void componentResized(ComponentEvent e) {
                    controls.setBounds(50, 5, 400, 50);
                }
            });
        }
    });
}

From source file:mulavito.gui.components.GraphPanel.java

protected GraphPanel() {
    super(new BorderLayout());
    layout = new MyGridLayout(1, 1);

    contentPane = new JPanel();
    add(contentPane);/*from w w w.j a  v a2s.  co  m*/
    contentPane.setLayout(layout);

    vvs = new LinkedList<LV>();

    verticalScrollBar = new JScrollBar(JScrollBar.VERTICAL);
    verticalScrollBar.setValues(0, 0, 0, 0);
    add(verticalScrollBar, BorderLayout.EAST);

    horizontalScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    horizontalScrollBar.setValues(0, 0, 0, 0);

    south = new JPanel(new BorderLayout());
    south.add(horizontalScrollBar);
    add(south, BorderLayout.SOUTH);
    setCorner(new SatelliteMultiViewerCorner());

    // for layer stack
    stackListener = new ChangeListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void stateChanged(ChangeEvent e) {
            // handle layer change
            if (e instanceof LayerChangedEvent<?>) {
                LayerChangedEvent<L> lce = (LayerChangedEvent<L>) e;
                if (lce.remove) {
                    if (lce.g != null)// remove layer
                        removeLayer(getViewer(lce.g));
                    else
                        // clear layers
                        while (vvs.size() > 0)
                            removeLayer(vvs.get(0));
                } else if (lce.g != null) // add layer
                    addLayer(lce.g);

                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    // To ensure correct behavior when several layers are
                    // added at the same time, we slightly delay these
                    // calls.
                    @Override
                    public void run() {
                        configureScrollBars();
                        configureSpinner();
                        arrangeViewers();
                        autoZoomToFit();
                    }
                });
            }
            // else removed vertices

            updateUI();
        }
    };
    // configure contexts
    contexts = new LinkedList<ViewerContext<L, LV>>();
    //
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            arrangeViewers();
            autoZoomToFit();
        }
    });
}

From source file:com.sshtools.appframework.ui.SshToolsApplicationFrame.java

/**
 * @param application//from ww  w. j av  a2 s. c  om
 * @param panel
 * 
 * @throws SshToolsApplicationException
 */

public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    log.debug("Initialising frame");
    this.panel = panel;
    this.application = application;
    if (application != null) {
        setTitle(application.getApplicationName() + " - " + application.getApplicationVersion());
    }
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    // Register the File menu
    panel.registerActionMenu(new ActionMenu("File", "File", 'f', 0));
    // Register the Exit action
    if (showExitAction && application != null) {
        panel.registerAction(exitAction = new ExitAction(application, this));
        // Register the New Window Action
    }
    if (showNewWindowAction && application != null) {
        panel.registerAction(newWindowAction = new NewWindowAction(application));
        // Register the Help menu
    }
    panel.registerActionMenu(new ActionMenu("Help", "Help", 'h', 99));
    // Register the About box action
    if (showAboutBox && application != null) {
        panel.registerAction(aboutAction = new AboutAction(this, application));
    }

    getApplicationPanel().rebuildActionComponents();
    // JPanel p = new JPanel(new ToolBarLayout());
    JPanel p = new JPanel(new BorderLayout(0, 0));
    JPanel center = new JPanel(new BorderLayout(0, 0));
    if (panel.getJMenuBar() != null) {
        setJMenuBar(panel.getJMenuBar());
    }

    if (panel.getToolBar() != null) {
        // center.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL),
        // BorderLayout.NORTH);
        // toolSeparator.setVisible(panel.getToolBar().isVisible());
        // panel.getToolBar().addComponentListener(new ComponentAdapter() {
        // public void componentShown(ComponentEvent e) {
        // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible());
        // }
        //
        // public void componentHidden(ComponentEvent e) {
        // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible());
        // }
        //
        // });
        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {

            public void componentHidden(ComponentEvent evt) {
                // toolSeparator.setVisible(pnl.getToolBar().isVisible());

            }

        });
        p.add(panel.getToolBar(), BorderLayout.NORTH);
    }
    center.add(panel, BorderLayout.CENTER);
    p.add(center, BorderLayout.CENTER);
    getContentPane().setLayout(new GridLayout(1, 1, 0, 0));
    getContentPane().add(p);
    // Watch for the frame closing
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent evt) {
            if (application != null) {
                application.closeContainer(SshToolsApplicationFrame.this);
            } else {
                int confirm = JOptionPane.showOptionDialog(SshToolsApplicationFrame.this,
                        "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);
                if (confirm == 0) {
                    hide();
                }
            }

        }

    });
    // If this is the first frame, center the window on the screen
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    boolean found = false;
    if (application != null && application.getContainerCount() != 0) {
        for (int i = 0; (i < application.getContainerCount()) && !found; i++) {
            SshToolsApplicationContainer c = application.getContainerAt(i);
            if (c instanceof SshToolsApplicationFrame) {
                SshToolsApplicationFrame f = (SshToolsApplicationFrame) c;
                setSize(f.getSize());
                Point newLocation = new Point(f.getX(), f.getY());
                newLocation.x += 48;
                newLocation.y += 48;
                if (newLocation.x > (screenSize.getWidth() - 64)) {
                    newLocation.x = 0;
                }
                if (newLocation.y > (screenSize.getHeight() - 64)) {
                    newLocation.y = 0;
                }
                setLocation(newLocation);
                found = true;
            }
        }
    }
    if (!found) {
        // Is there a previous stored geometry we can use?
        if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) {
            setBounds(PreferencesStore.getRectangle(PREF_LAST_FRAME_GEOMETRY, getBounds()));
        } else {
            pack();
            setSize(800, 600);
            UIUtil.positionComponent(SwingConstants.CENTER, this);
        }
    }
    log.debug("Initialisation of frame complete");
}

From source file:eu.delving.sip.Application.java

private Application(final File storageDir) throws StorageException {
    GroovyCodeResource groovyCodeResource = new GroovyCodeResource(getClass().getClassLoader());
    final ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/delving-background.png"));
    desktop = new JDesktopPane() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(backgroundIcon.getImage(), 0, 0, desktop);
        }/*from  w w  w  .j  a  va  2 s.  c o  m*/
    };
    desktop.setMinimumSize(new Dimension(MINIMUM_DESKTOP_SIZE));
    resizeTimer = new Timer(DEFAULT_RESIZE_INTERVAL, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            resizeTimer.stop();
            for (JInternalFrame frame : desktop.getAllFrames()) {
                if (frame instanceof FrameBase) {
                    ((FrameBase) frame).ensureOnScreen();
                }
            }
        }
    });
    desktop.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent componentEvent) {
            resizeTimer.restart();
        }
    });
    Preferences preferences = Preferences.userNodeForPackage(SipModel.class);
    feedback = new VisualFeedback(home, desktop, preferences);
    HttpClient httpClient = createHttpClient(storageDir);
    SchemaRepository schemaRepository;
    try {
        schemaRepository = new SchemaRepository(new SchemaFetcher(httpClient));
    } catch (IOException e) {
        throw new StorageException("Unable to create Schema Repository", e);
    }
    ResolverContext context = new ResolverContext();
    Storage storage = new StorageImpl(storageDir, schemaRepository, new CachedResourceResolver(context));
    context.setStorage(storage);
    context.setHttpClient(httpClient);
    sipModel = new SipModel(desktop, storage, groovyCodeResource, feedback, preferences);
    CultureHubClient cultureHubClient = isStandalone(storageDir) ? null
            : new CultureHubClient(sipModel, httpClient);
    if (cultureHubClient != null)
        uploadAction = new UploadAction(sipModel, cultureHubClient);
    expertMenu = new ExpertMenu(desktop, sipModel, cultureHubClient, allFrames);
    statusPanel = new StatusPanel(sipModel);
    home = new JFrame(titleString());
    home.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent componentEvent) {
            allFrames.getViewSelector().refreshView();
        }
    });
    JPanel content = (JPanel) home.getContentPane();
    content.setFocusable(true);
    FrameBase dataSetFrame = cultureHubClient != null ? new DataSetHubFrame(sipModel, cultureHubClient)
            : new DataSetStandaloneFrame(sipModel, schemaRepository);
    LogFrame logFrame = new LogFrame(sipModel);
    feedback.setLog(logFrame.getLog());
    allFrames = new AllFrames(sipModel, content, dataSetFrame, logFrame);
    desktop.setBackground(new Color(190, 190, 200));
    content.add(desktop, BorderLayout.CENTER);
    sipModel.getMappingModel().addChangeListener(new MappingModel.ChangeListener() {
        @Override
        public void lockChanged(MappingModel mappingModel, final boolean locked) {
            sipModel.exec(new Swing() {
                @Override
                public void run() {
                    unlockMappingAction.setEnabled(locked);
                }
            });
        }

        @Override
        public void functionChanged(MappingModel mappingModel, MappingFunction function) {
        }

        @Override
        public void nodeMappingChanged(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping,
                NodeMappingChange change) {
        }

        @Override
        public void nodeMappingAdded(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) {
        }

        @Override
        public void nodeMappingRemoved(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) {
        }

        @Override
        public void populationChanged(MappingModel mappingModel, RecDefNode node) {
        }
    });
    importAction = new ImportAction(desktop, sipModel);
    attachAccelerator(importAction, home);
    validateAction = new ValidateAction(sipModel, allFrames.prepareForInvestigation(desktop));
    unlockMappingAction = new UnlockMappingAction(sipModel);
    attachAccelerator(unlockMappingAction, home);
    selectAnotherMappingAction = new SelectAnotherMappingAction(sipModel);
    attachAccelerator(selectAnotherMappingAction, home);
    content.add(createStatePanel(), BorderLayout.SOUTH);
    content.add(allFrames.getSidePanel(), BorderLayout.WEST);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    screen.height -= 30;
    home.setSize(screen);
    home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ImageIcon logo = new ImageIcon(getClass().getResource("/sip-creator-logo.png"));
    home.setIconImage(logo.getImage());
    home.setJMenuBar(createMenuBar());
    home.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
            quit();
        }
    });
    home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    sipModel.getDataSetModel().addListener(new DataSetModel.SwingListener() {
        @Override
        public void stateChanged(DataSetModel model, DataSetState state) {
            statusPanel.setState(state);
            switch (state) {
            case ABSENT:
                sipModel.exec(new Work() {
                    @Override
                    public void run() {
                        sipModel.getDataSetFacts().set(null);
                        sipModel.getStatsModel().setStatistics(null);
                    }

                    @Override
                    public Job getJob() {
                        return Job.CLEAR_FACTS_STATS;
                    }
                });
                home.setTitle(titleString());
                sipModel.seekReset();
                break;
            default:
                DataSetModel dataSetModel = sipModel.getDataSetModel();
                home.setTitle(String.format(titleString() + " - [%s -> %s]",
                        dataSetModel.getDataSet().getSpec(), dataSetModel.getPrefix().toUpperCase()));
                sipModel.getReportFileModel().refresh();
                break;
            }
        }
    });
    attachAccelerator(new QuitAction(), home);
    attachAccelerator(statusPanel.getButtonAction(), home);
}

From source file:com.sshtools.common.ui.SshToolsApplicationInternalFrame.java

/**
 *
 *
 * @param application//from   w w  w  . j a va2  s  . c o m
 * @param panel
 *
 * @throws SshToolsApplicationException
 */
public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    this.panel = panel;
    this.application = application;

    if (application != null) {
        setTitle(ConfigurationLoader.getVersionString(application.getApplicationName(),
                application.getApplicationVersion())); // + " " + application.getApplicationVersion());
    }

    // Register the File menu
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0));
    // Register the Exit action
    if (showExitAction && application != null) {
        panel.registerAction(exitAction = new ExitAction(application, this));

        // Register the New Window Action
    }
    if (showNewWindowAction && application != null) {
        panel.registerAction(newWindowAction = new NewWindowAction(application));

        // Register the Help menu
    }
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 99));

    // Register the About box action
    if (showAboutBox && application != null) {
        panel.registerAction(aboutAction = new AboutAction(this, application));

    }
    // Register the Changelog box action
    if (showChangelogBox && application != null) {
        panel.registerAction(changelogAction = new ChangelogAction(this, application));

    }
    panel.registerAction(faqAction = new FAQAction());
    panel.registerAction(beginnerAction = new BeginnerAction());
    panel.registerAction(advancedAction = new AdvancedAction());

    getApplicationPanel().rebuildActionComponents();

    JPanel p = new JPanel(new BorderLayout());

    if (panel.getJMenuBar() != null) {
        setJMenuBar(panel.getJMenuBar());
    }

    if (panel.getToolBar() != null) {
        JPanel t = new JPanel(new BorderLayout());
        t.add(panel.getToolBar(), BorderLayout.NORTH);
        t.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
        toolSeparator.setVisible(panel.getToolBar().isVisible());

        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {
            public void componentHidden(ComponentEvent evt) {
                log.debug("Tool separator is now " + pnl.getToolBar().isVisible());
                toolSeparator.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
    //setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);

    addVetoableChangeListener(new VetoableChangeListener() {

        public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {

            if (application != null) {
                application.closeContainer(SshToolsApplicationInternalFrame.this);
            } else {
                if (evt.getPropertyName().equals(IS_CLOSED_PROPERTY)) {
                    boolean changed = ((Boolean) evt.getNewValue()).booleanValue();
                    if (changed) {
                        int confirm = JOptionPane.showOptionDialog(SshToolsApplicationInternalFrame.this,
                                "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE, null, null, null);
                        if (confirm == 0) {
                            SshToolsApplicationInternalFrame.this.getDesktopPane()
                                    .remove(SshToolsApplicationInternalFrame.this);
                        }
                    }
                }
            }
        }
    });

    /*this.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) {
        if(application!=null)
          application.closeContainer(SshToolsApplicationFrame.this);
        else
          hide();
      }
         });
            
    // If this is the first frame, center the window on the screen
    /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
         boolean found = false;
         if (application!=null && application.getContainerCount() != 0) {
      for (int i = 0; (i < application.getContainerCount()) && !found;
           i++) {
        SshToolsApplicationContainer c = application.getContainerAt(i);
        if (c instanceof SshToolsApplicationFrame) {
          SshToolsApplicationFrame f = (SshToolsApplicationFrame) c;
          setSize(f.getSize());
          Point newLocation = new Point(f.getX(), f.getY());
          newLocation.x += 48;
          newLocation.y += 48;
          if (newLocation.x > (screenSize.getWidth() - 64)) {
    newLocation.x = 0;
          }
          if (newLocation.y > (screenSize.getHeight() - 64)) {
    newLocation.y = 0;
          }
          setLocation(newLocation);
          found = true;
        }
      }
         }
         if (!found) {
      // Is there a previous stored geometry we can use?
      if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) {
        setBounds(PreferencesStore.getRectangle(
    PREF_LAST_FRAME_GEOMETRY, getBounds()));
      }
      else {
        pack();
        UIUtil.positionComponent(SwingConstants.CENTER, this);
      }
         }*/

    pack();
}

From source file:com.sshtools.common.ui.SshToolsApplicationFrame.java

/**
 *
 *
 * @param application/*from   w ww  .  j a  v  a 2  s  . c  om*/
 * @param panel
 *
 * @throws SshToolsApplicationException
 */
public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    this.panel = panel;
    this.application = application;

    if (application != null) {
        setTitle(ConfigurationLoader.getVersionString(application.getApplicationName(),
                application.getApplicationVersion())); // + " " + application.getApplicationVersion());
    }

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // Register the File menu
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0));
    // Register the Exit action
    if (showExitAction && application != null) {
        panel.registerAction(exitAction = new ExitAction(application, this));

        // Register the New Window Action
    }
    if (showNewWindowAction && application != null) {
        panel.registerAction(newWindowAction = new NewWindowAction(application));

        // Register the Help menu
    }
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 99));

    // Register the About box action
    if (showAboutBox && application != null) {
        panel.registerAction(aboutAction = new AboutAction(this, application));

    }

    // Register the Changelog box action
    if (showChangelogBox && application != null) {
        panel.registerAction(changelogAction = new ChangelogAction(this, application));

    }
    panel.registerAction(faqAction = new FAQAction());
    panel.registerAction(beginnerAction = new BeginnerAction());
    panel.registerAction(advancedAction = new AdvancedAction());

    getApplicationPanel().rebuildActionComponents();

    JPanel p = new JPanel(new BorderLayout());

    if (panel.getJMenuBar() != null) {
        setJMenuBar(panel.getJMenuBar());
    }

    if (panel.getToolBar() != null) {
        JPanel t = new JPanel(new BorderLayout());
        t.add(panel.getToolBar(), BorderLayout.NORTH);
        t.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
        toolSeparator.setVisible(panel.getToolBar().isVisible());

        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {
            public void componentHidden(ComponentEvent evt) {
                log.debug("Tool separator is now " + pnl.getToolBar().isVisible());
                toolSeparator.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
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            if (application != null) {
                application.closeContainer(SshToolsApplicationFrame.this);
            } else {
                int confirm = JOptionPane.showOptionDialog(SshToolsApplicationFrame.this,
                        "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);
                if (confirm == 0) {
                    hide();
                }

            }
        }
    });

    // If this is the first frame, center the window on the screen
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    boolean found = false;

    if (application != null && application.getContainerCount() != 0) {
        for (int i = 0; (i < application.getContainerCount()) && !found; i++) {
            SshToolsApplicationContainer c = application.getContainerAt(i);

            if (c instanceof SshToolsApplicationFrame) {
                SshToolsApplicationFrame f = (SshToolsApplicationFrame) c;
                setSize(f.getSize());

                Point newLocation = new Point(f.getX(), f.getY());
                newLocation.x += 48;
                newLocation.y += 48;

                if (newLocation.x > (screenSize.getWidth() - 64)) {
                    newLocation.x = 0;
                }

                if (newLocation.y > (screenSize.getHeight() - 64)) {
                    newLocation.y = 0;
                }

                setLocation(newLocation);
                found = true;
            }
        }
    }

    if (!found) {
        // Is there a previous stored geometry we can use?
        if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) {
            setBounds(PreferencesStore.getRectangle(PREF_LAST_FRAME_GEOMETRY, getBounds()));
        } else {
            pack();
            UIUtil.positionComponent(SwingConstants.CENTER, this);
        }
    }
}

From source file:com.intel.stl.ui.monitor.view.PSEventsCardView.java

@Override
protected JComponent getMainComponent() {

    if (mainPanel != null) {
        return mainPanel;
    }//from  ww w. ja v  a  2s . 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:com.intel.stl.ui.main.view.HealthHistoryView.java

@Override
protected JPanel getMainComponent() {
    if (mainPanel != null) {
        return mainPanel;
    }//from w w  w  .j av a  2s. c o  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:mergedoc.ui.MergeDocFrame.java

/**
 * ????/*from   www. java 2  s  . c  om*/
 */
private void initListener() {

    // ?
    buttonBar.setRunListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mergeExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    execute();
                }
            });
        }
    });

    // ?
    buttonBar.setCancelListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            buttonBar.setEnabled(false);
            mergeManager.getWorkingState().cancel();
        }
    });

    // ?
    buttonBar.setBackListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            back();
        }
    });

    // ?
    buttonBar.setEndListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            end();
        }
    });

    // ??
    mergeManager.setChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            WorkingState state = mergeManager.getWorkingState();
            progressPanel.addListText(state.getWorkingText());
            setTitle(progressPanel.getBarText());
        }
    });

    // ?
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            persistent();
        }
    });

    // ?
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            end();
        }
    });
}