List of usage examples for javax.swing.event InternalFrameAdapter InternalFrameAdapter
InternalFrameAdapter
From source file:fxts.stations.trader.ui.frames.ChildFrame.java
/** * Constructor./*from w w w.ja v a2s .c om*/ * * @param aName name of frame * @param aMainFrame main frame */ public ChildFrame(String aName, IMainFrame aMainFrame) { super(aName, true, //resizable true, //closable true); //maximizable setMainFrame(aMainFrame); //sets reaction on closings setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); //adds listener addInternalFrameListener(new InternalFrameAdapter() { //overriden public void internalFrameClosing(InternalFrameEvent aEvent) { //unselects associated menu item setMenuItemState(false); ChildFrame.this.setVisible(false); //checking for existing of visible frames mMainFrame.checkForVisibleChilds(); } }); //sets name of the frame setName(aName); //adds mouse listener addMouseListener(new MouseAdapter() { /** * Invoked when a mouse button has been pressed on a component. */ public void mousePressed(MouseEvent aEvent) { if (!ChildFrame.this.isSelected()) { try { ChildFrame.this.setSelected(true); } catch (Exception e) { e.printStackTrace(); } } } }); }
From source file:com.tag.FramePreferences.java
@SuppressWarnings("serial") public FramePreferences(final JInternalFrame frame, String pathName) { setFrame(new Frame() { @Override//from w ww .java 2 s .c om public synchronized int getExtendedState() { if (frame.isMaximum()) { return Frame.MAXIMIZED_BOTH; } else if (frame.isIcon()) { return Frame.ICONIFIED; } else { return Frame.NORMAL; } } @Override public synchronized void setExtendedState(int state) { try { switch (state) { case Frame.MAXIMIZED_HORIZ: case Frame.MAXIMIZED_VERT: case Frame.MAXIMIZED_BOTH: frame.setMaximum(true); break; case Frame.ICONIFIED: frame.setIcon(true); break; case Frame.NORMAL: frame.setIcon(false); frame.setMaximum(false); break; } } catch (PropertyVetoException e) { e.printStackTrace(); } } @Override public synchronized void addWindowStateListener(final WindowStateListener l) { final Frame source = this; frame.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameIconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED)); } @Override public void internalFrameDeiconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED)); } }); } @Override public synchronized void removeWindowStateListener(WindowStateListener l) { super.removeWindowStateListener(l); } @Override public GraphicsConfiguration getGraphicsConfiguration() { return frame.getGraphicsConfiguration(); } public Point getLocation() { return frame.getLocation(); } @Override public void setLocation(Point p) { frame.setLocation(p); } @Override public Dimension getSize() { return frame.getSize(); } @Override public void setSize(Dimension size) { frame.setSize(size); } @Override public synchronized void addComponentListener(ComponentListener l) { frame.addComponentListener(l); } @Override public synchronized void removeComponentListener(ComponentListener l) { frame.addComponentListener(l); } }); setPathName(pathName); }
From source file:org.eumetsat.metop.visat.SounderInfoView.java
@Override protected JComponent createControl() { overlayListener = new SounderOverlayListener() { @Override/* w w w . ja v a 2 s .c o m*/ public void selectionChanged(SounderOverlay overlay) { updateUI(overlay); } @Override public void dataChanged(SounderOverlay overlay) { updateUI(overlay); } }; internalFrameListener = new InternalFrameAdapter() { @Override public void internalFrameActivated(final InternalFrameEvent e) { final Container contentPane = e.getInternalFrame().getContentPane(); if (contentPane instanceof ProductSceneView) { final ProductSceneView view = (ProductSceneView) contentPane; final SounderLayer layer = getSounderLayer(view); if (layer != null) { layerChanged(layer); } else { final LayerListener layerListener = new AbstractLayerListener() { @Override public void handleLayersAdded(Layer parentLayer, Layer[] childLayers) { final SounderLayer layer = getSounderLayer(view); if (layer != null) { layerChanged(layer); view.getRootLayer().removeListener(this); } } }; view.getRootLayer().addListener(layerListener); } } } @Override public void internalFrameDeactivated(final InternalFrameEvent e) { final Container contentPane = e.getInternalFrame().getContentPane(); if (contentPane instanceof ProductSceneView) { final ProductSceneView view = (ProductSceneView) contentPane; final SounderLayer layer = getSounderLayer(view); if (layer != null) { layer.getOverlay().removeListener(overlayListener); } } } @Override public void internalFrameClosed(InternalFrameEvent e) { if (getSounderLayer() == null) { clearUI(); editor.setModel(null); } } }; VisatApp.getApp().addInternalFrameListener(internalFrameListener); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("Sounder Info", createInfoComponent()); tabbedPane.add("Sounder Spectrum", createSpectrumChartComponent()); tabbedPane.add("Sounder Layer", createSounderLayerComponent()); final SounderLayer layer = getSounderLayer(); if (layer != null) { layerChanged(layer); } final AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false); helpButton.setToolTipText("Help."); /*I18N*/ helpButton.setName("helpButton"); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId()); HelpSys.enableHelpKey(tabbedPane, getDescriptor().getHelpId()); } final JPanel containerPanel = new JPanel(new BorderLayout()); containerPanel.add(tabbedPane, BorderLayout.CENTER); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.add(helpButton, BorderLayout.EAST); containerPanel.add(buttonPanel, BorderLayout.SOUTH); return containerPanel; }
From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java
/** * Creates new form FrequenciesByYearInternalFrame * * @param dtp//from www . j a va 2 s. c o m */ public FrequenciesByYearInternalFrame(JDesktopPane dtp) { this.dtp = dtp; dictionary = CanRegClientApp.getApplication().getDictionary(); initComponents(); initOtherComponents(); localSettings = CanRegClientApp.getApplication().getLocalSettings(); addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameClosing(InternalFrameEvent e) { close(); } }); }
From source file:org.eumetsat.metop.visat.IasiInfoView.java
@Override protected JComponent createControl() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("Sounder Info", createInfoComponent()); tabbedPane.add("Sounder Spectrum", createSpectrumChartComponent()); tabbedPane.add("Radiance Analysis", createRadianceAnalysisComponent()); tabbedPane.add("Sounder Layer", createSounderLayerComponent()); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpKey(tabbedPane, getDescriptor().getHelpId()); }// w w w. j a v a 2 s .co m InternalFrameListener internalFrameListener = new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { final Container contentPane = e.getInternalFrame().getContentPane(); if (contentPane instanceof ProductSceneView) { final ProductSceneView view = (ProductSceneView) contentPane; final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); } else { final LayerListener layerListener = new AbstractLayerListener() { @Override public void handleLayersAdded(Layer parentLayer, Layer[] childLayers) { final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); view.getRootLayer().removeListener(this); } } }; view.getRootLayer().addListener(layerListener); } } } @Override public void internalFrameDeactivated(InternalFrameEvent e) { if (currentOverlay != null) { currentOverlay.removeListener(overlayListener); } updateUI(null); editor.setModel(null); } }; VisatApp.getApp().addInternalFrameListener(internalFrameListener); if (MetopSounderVPI.isValidAvhrrProductSceneViewSelected()) { final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); } } final AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false); helpButton.setToolTipText("Help."); /*I18N*/ helpButton.setName("helpButton"); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId()); HelpSys.enableHelpKey(tabbedPane, getDescriptor().getHelpId()); } final JPanel containerPanel = new JPanel(new BorderLayout()); containerPanel.add(tabbedPane, BorderLayout.CENTER); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.add(helpButton, BorderLayout.EAST); containerPanel.add(buttonPanel, BorderLayout.SOUTH); return containerPanel; }
From source file:au.org.ala.delta.ui.SearchDialog.java
protected void hookInternalFrame(JComponent owner) { JInternalFrame internalFrame = UIUtils.getParentInternalFrame(owner); if (internalFrame != null) { internalFrame.addInternalFrameListener(new InternalFrameAdapter() { @Override/*from w w w .j a va 2 s . co m*/ public void internalFrameClosing(InternalFrameEvent e) { if (isVisible()) { setVisible(false); } } }); } }
From source file:au.org.ala.delta.editor.ui.ItemEditor.java
/** * Adds the event handlers to the UI components. *///from w w w .ja v a 2s.co m private void addEventHandlers(ActionMap map) { spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (_editsDisabled) { return; } updateItemSelection((Integer) spinner.getValue()); } }); rtfEditor.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { itemEditPerformed(); } @Override public void insertUpdate(DocumentEvent e) { itemEditPerformed(); } @Override public void changedUpdate(DocumentEvent e) { itemEditPerformed(); } }); rtfEditor.addKeyListener(new SelectionNavigationKeyListener() { @Override protected void advanceSelection() { _validator.verify(rtfEditor); } }); taxonSelectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taxonSelectionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (_editsDisabled) { return; } _selectedItem = _dataSet.getItem(taxonSelectionList.getSelectedIndex() + 1); updateDisplay(); } }); btnDone.setAction(map.get("itemEditDone")); chckbxTreatAsVariant.setAction(map.get("itemVarianceChanged")); btnSelect.setAction(map.get("selectItemByName")); taxonSelectionList.setSelectionAction(map.get("taxonSelected")); _validator = new TextComponentValidator(new ItemValidator(), this); // Give the item description text area focus. addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { rtfEditor.requestFocusInWindow(); } }); }
From source file:MDIApp.java
public JMFrame(Player player, String title) { super(title, true, true, true, true); getContentPane().setLayout(new BorderLayout()); setSize(320, 10);/* ww w .j a v a2 s .c o m*/ setLocation(50, 50); setVisible(true); mplayer = player; mplayer.addControllerListener((ControllerListener) this); mplayer.realize(); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent ife) { mplayer.close(); } }); }
From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java
BamInternalFrame(BamFileRef ref) { super(ref.bamFile.getName(), true, false, true, true); this.ref = ref; JPanel mainPane = new JPanel(new BorderLayout(5, 5)); setContentPane(mainPane);//from w w w . j a v a 2 s . com JTabbedPane tabbedPane = new JTabbedPane(); mainPane.add(tabbedPane, BorderLayout.CENTER); JPanel pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("BAM", pane); this.tableModel = new BamTableModel(); this.jTable = createTable(tableModel); this.jTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); this.jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll1 = new JScrollPane(this.jTable); this.infoTableModel = new FlagTableModel(); JTable tInfo = createTable(this.infoTableModel); this.genotypeTableModel = new SAMTagAndValueModel(); JTable tGen = createTable(this.genotypeTableModel); this.groupTableModel = new ReadGroupTableModel(); JTable tGrp = createTable(this.groupTableModel); JPanel splitH = new JPanel(new GridLayout(1, 0, 5, 5)); splitH.add(new JScrollPane(tInfo)); splitH.add(new JScrollPane(tGen)); splitH.add(new JScrollPane(tGrp)); JSplitPane splitVert = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll1, splitH); this.jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int row = jTable.getSelectedRow(); SAMRecord ctx; if (row == -1 || (ctx = tableModel.getElementAt(row)) == null) { infoTableModel.setContext(null); genotypeTableModel.setContext(null); groupTableModel.setContext(null); } else { infoTableModel.setContext(ctx); genotypeTableModel.setContext(ctx); groupTableModel.setContext(ctx); } } }); pane.add(splitVert); //header as text pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("Header", pane); JTextArea area = new JTextArea(String.valueOf(ref.header.getTextHeader())); area.setCaretPosition(0); area.setEditable(false); pane.add(new JScrollPane(area), BorderLayout.CENTER); //dict pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("Reference", pane); JTable dictTable = createTable(new SAMSequenceDictionaryTableModel(ref.header.getSequenceDictionary())); dictTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); pane.add(new JScrollPane(dictTable), BorderLayout.CENTER); this.selList = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; listSelectionChanged(); } }; this.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { jTable.getSelectionModel().addListSelectionListener(selList); } @Override public void internalFrameDeactivated(InternalFrameEvent e) { jTable.getSelectionModel().removeListSelectionListener(selList); } }); }
From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.Perspective.java
@Override public IView addView(final IView view) { if (view == null) { throw new IllegalArgumentException("view must not be NULL"); }/*from w ww.j a va 2s. co m*/ final JInternalFrame internalFrame = new JInternalFrame(view.getTitle(), true, true, true, true); internalFrame.setBackground(Color.BLACK); internalFrame.setForeground(Color.GREEN); internalFrame.getContentPane().add(view.getPanel(this)); SizeAndLocation sizeAndLoc = applicationConfig.getViewCoordinates(getUniqueID(view)); if (sizeAndLoc != null) { internalFrame.setSize(sizeAndLoc.getSize()); internalFrame.setLocation(sizeAndLoc.getLocation()); } else { internalFrame.setSize(200, 150); internalFrame.setLocation(0, 0); internalFrame.pack(); } internalFrame.setVisible(true); final InternalFrameWithView frameAndView = new InternalFrameWithView(internalFrame, view); final InternalFrameListener listener = new InternalFrameAdapter() { @Override public void internalFrameClosing(InternalFrameEvent e) { disposeView(view); } }; internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); internalFrame.addInternalFrameListener(listener); views.add(frameAndView); desktop.add(internalFrame); return view; }