/** * Gerenciador de JInternalFrames * * @param jIFrame JInternalFrame : InternalFrame que se deseja gerenciar */ public void manager(JInternalFrame jIFrame) { boolean isActive = false; JInternalFrame[] frames = dPane.getAllFrames(); for (JInternalFrame jif : frames) { if (!reply) { if (jif.getClass().equals(jIFrame.getClass())) { isActive = true; jif.moveToFront(); try { jif.setMaximum(true); jif.setMaximum(false); } catch (PropertyVetoException e) { e.printStackTrace(); } } } } if (!isActive) { if (frames.length > 0) { cascata(jIFrame, frames[0]); jIFrame.setLocation(x, y); } else { jIFrame.setLocation(minX, minY); } dPane.add(jIFrame); jIFrame.setVisible(true); } }
private static void centerWindow(JInternalFrame w, Component owner) { // center based on the owner component, if it is not null // otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth() / 2; p.y += owner.getHeight() / 2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
/** * Abre el Caso de Uso e inicia su ejecución para las ventanas * VentanaActualizarTiposGenericoContable y VentanaActualizarTiposGenerico * * @param nombreClaseVentana Nombre de la Clase de la Ventana que se va a mostrar. * @param nombreClaseGenerica Nombre de la Clase que se va a actualizar. * @param titulo Nombre de la parte del título que indica actividad (no poner todo completo, solo * lo que se está actualizando). La ventana mostrará: "Actualizar " + titulo. * @return Referencia a la ventana creada. */ public JInternalFrame iniciarCUGenerico(Class claseVentana, Class claseGenerica, String titulo) { JInternalFrame ventana = null; try { // Instanciar el CU. ventana = (JInternalFrame) claseVentana.newInstance(); VentanaMenuPrincipal.getInstancia().getPanelPrincipal().add(ventana); // Establece la posicion de la ventana. generarPosicionVentana(); ventana.setLocation(getPosicionXVentana(), getPosicionYVentana()); // Muestra la ventana. ventana.setVisible(true); // Intenta establecer a la ventana como seleccionada, // Si no puede, lanza imprime la excepcion en la salida estandar. try { ventana.setSelected(true); } catch (java.beans.PropertyVetoException e) { log.warn("Error al establecer ventana como seleccionada.", e); } InterfazTipoGenerico tg = (InterfazTipoGenerico) claseGenerica.newInstance(); ((VentanaActualizarTipos) ventana).opcionActualizarTipos(titulo, tg); log.debug( "Iniciado CU Genérico: " + claseVentana.getName() + " - Para la Clase: " + claseGenerica.getName()); } catch (InstantiationException ex) { log.error("No se pudo instanciar la clase", ex); } catch (IllegalAccessException ex) { log.error("No se pudo instanciar la clase", ex); } return ventana; }
public Component add(JInternalFrame frame) { JInternalFrame[] array = getAllFrames(); Point p; int w; int h; Component retval = super.add(frame); checkDesktopSize(); if (array.length > 0) { p = array[0].getLocation(); p.x = p.x + FRAME_OFFSET; p.y = p.y + FRAME_OFFSET; } else { p = new Point(0, 0); } frame.setLocation(p.x, p.y); if (frame.isResizable()) { w = getWidth() - (getWidth() / 3); h = getHeight() - (getHeight() / 3); if (w < frame.getMinimumSize().getWidth()) w = (int) frame.getMinimumSize().getWidth(); if (h < frame.getMinimumSize().getHeight()) h = (int) frame.getMinimumSize().getHeight(); frame.setSize(w, h); } moveToFront(frame); frame.setVisible(true); try { frame.setSelected(true); } catch (PropertyVetoException e) { frame.toBack(); } return retval; }
public void xtestTiming() { final JDialog dialog = new JDialog((JFrame) null, "TestTiming"); JDesktopPane pane = new JDesktopPane(); dialog.setContentPane(pane); final Object[] f = {null}; for (int i = 99; i >= 0; i--) { JInternalFrame frame = new JInternalFrame("Internal Frame - " + i, true, true, true, true); JButton s = new JButton("button" + i); s.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { final long start = System.currentTimeMillis(); System.err.println("TestMarathonNamingStrategy.testTiming(): " + start); namingStrategy.setTopLevelComponent(dialog, true); String name = namingStrategy.getName((Component) e.getSource()); System.err.println( "TestMarathonNamingStrategy.testTiming(): name = " + name + "::" + (System.currentTimeMillis() - start)); } }); f[0] = s; frame.getContentPane().add(s); frame.pack(); frame.setLocation(i, i); frame.setVisible(true); pane.add(frame); } dialog.setSize(500, 500); dialog.setModal(true); dialog.setVisible(true); System.err.println( "TestMarathonNamingStrategy.testTiming(): " + ((Component) f[0]).isVisible()); }
public void centrarFrm(JInternalFrame hijo, VistaMDI padre) { hijo.setLocation( padre.getWidth() / 2 - hijo.getWidth() / 2, padre.getHeight() / 2 - hijo.getHeight() / 2 - 20); // CENTRA EL FORMULARIO }
private synchronized void display(ExtSed sed) { manageAssociatedManagerWindows(sed); try { SpectrumContainer container = (SpectrumContainer) sed.getAttachment(IrisDisplayManager.FIT_MODEL); // There is no Sed attachment, so build a model manager and attach it. if (container == null) { if (buildAttachment(sed)) { return; } } // VAOPD-879: spectrum name must be identical with Sed name. if (container != null) { container.getSpectrum().setName(sed.getId()); } // Now display the Sed. idm.display(sed, sed.getId()); // and add its frame to the workspace. JInternalFrame frame = idm.getInternalFrame(); // VAOPD-863 frame.setTitle(sed.getId()); if (container != null) { JFrame modelManagerFrame = container.getModelManager().getFrame(); if (modelManagerFrame != null) { modelManagerFrame.setTitle(sed.getId()); } } if (frame != currentFrame) { lastLocation = null; disposeCurrentFrame(); currentFrame = frame; currentFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE); if (lastLocation != null) { currentFrame.setLocation(lastLocation); } frame.setTitle("Iris Visualizer"); ws.addFrame(frame); } } catch (Exception ex) { LogEvent.getInstance().fire(this, new LogEntry("Error: " + ex.getMessage(), sed)); Logger.getLogger("IrisVisualizer").log(Level.SEVERE, null, ex); } }
public Object showWindow(final MkWindow macWindow, String title, boolean isModal) { listMkWindow.add(macWindow); if (isModal) { JDialog modalFrame = new JDialog(this, title, true); // macWindow.setJanela(modalFrame); final MkRun onCloseWindow = macWindow.onCloseWindow; modalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); modalFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (onCloseWindow != null) { onCloseWindow.execute(); } disposeWindow(macWindow); } }); modalFrame.setLayout(new BorderLayout()); modalFrame.add(macWindow, BorderLayout.CENTER); modalFrame.pack(); Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - modalFrame.getWidth()) / 2; int y = (desktopSize.height - modalFrame.getHeight()) / 2; modalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); if (macWindow.panelButton != null) { modalFrame.getRootPane().setDefaultButton((JButton) macWindow.panelButton.getComponent(0)); } modalFrame.setVisible(true); return modalFrame; } else { JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true); internalFrame.setContentPane(macWindow); internalFrame.pack(); // internalFrame.setBounds(internalFrame.getBounds()); //pq? desktopPane.add(internalFrame); internalFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final MkRun onCloseWindow = macWindow.onCloseWindow; if (onCloseWindow != null) { internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); internalFrame.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { onCloseWindow.execute(); } }); } Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - internalFrame.getWidth()) / 2; int y = (desktopSize.height - internalFrame.getHeight()) / 2; internalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); internalFrame.setVisible(true); return internalFrame; } }
private void mItemClenteActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemClenteActionPerformed // TODO add your handling code here: JInternalFrame clientView = new clientWindow("Clientes"); clientView.setLocation( (this.getSize().width - clientView.getSize().width) / 2, (this.getSize().height - clientView.getSize().height) / 2); this.add(clientView); clientView.setVisible(true); } // GEN-LAST:event_mItemClenteActionPerformed
private void mItemGasPriceReportActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemGasPriceReportActionPerformed // TODO add your handling code here: JInternalFrame gasPriceReport = new gasPriceReportWindow(); gasPriceReport.setLocation( (this.getSize().width - gasPriceReport.getSize().width) / 2, (this.getSize().height - gasPriceReport.getSize().height) / 2); this.add(gasPriceReport); gasPriceReport.setVisible(true); } // GEN-LAST:event_mItemGasPriceReportActionPerformed
private void mItemRealTimeActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemRealTimeActionPerformed // TODO add your handling code here: JInternalFrame mapView = new realTimeMapWindow(); mapView.setLocation( (this.getSize().width - mapView.getSize().width) / 2, (this.getSize().height - mapView.getSize().height) / 2); this.add(mapView); mapView.setVisible(true); } // GEN-LAST:event_mItemRealTimeActionPerformed
private void mItemUserActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemUserActionPerformed // TODO add your handling code here: JInternalFrame user = new userWindow(); user.setLocation( (this.getSize().width - user.getSize().width) / 2, (this.getSize().height - user.getSize().height) / 2); this.add(user); user.setVisible(true); } // GEN-LAST:event_mItemUserActionPerformed
private void menuItemNuevoActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_menuItemNuevoActionPerformed // TODO add your handling code here: JInternalFrame truck = new truckWindow(); truck.setLocation( (this.getSize().width - truck.getSize().width) / 2, (this.getSize().height - truck.getSize().height) / 2); this.add(truck); truck.setVisible(true); } // GEN-LAST:event_menuItemNuevoActionPerformed
private void mItemProductActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemProductActionPerformed // TODO add your handling code here: JInternalFrame product = new productWindow(); product.setLocation( (this.getSize().width - product.getSize().width) / 2, (this.getSize().height - product.getSize().height) / 2); this.add(product); product.setVisible(true); } // GEN-LAST:event_mItemProductActionPerformed
private void mItemReportHistoryActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemReportHistoryActionPerformed // TODO add your handling code here: JInternalFrame reportHistory = new reportHistoryWindow(); reportHistory.setLocation( (this.getSize().width - reportHistory.getSize().width) / 2, (this.getSize().height - reportHistory.getSize().height) / 2); this.add(reportHistory); reportHistory.setVisible(true); } // GEN-LAST:event_mItemReportHistoryActionPerformed
private void mItemEditUsersActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemEditUsersActionPerformed // TODO add your handling code here: JInternalFrame editUsers = new editUsersPassWindow(); editUsers.setLocation( (this.getSize().width - editUsers.getSize().width) / 2, (this.getSize().height - editUsers.getSize().height) / 2); this.add(editUsers); editUsers.setVisible(true); } // GEN-LAST:event_mItemEditUsersActionPerformed
private void mItemCargaDatosActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mItemCargaDatosActionPerformed // TODO add your handling code here: JInternalFrame batchLoad = new loadWindow("Nueva Carga de Datos"); batchLoad.setLocation( (this.getSize().width - batchLoad.getSize().width) / 2, (this.getSize().height - batchLoad.getSize().height) / 2); this.add(batchLoad); batchLoad.setVisible(true); } // GEN-LAST:event_mItemCargaDatosActionPerformed
private void agregarAPanel(JInternalFrame internal, int ancho, int largo) { if (!this.desktopPane.isAncestorOf(internal)) { this.desktopPane.add(internal); internal.setSize(ancho, largo); internal.setVisible(true); Dimension desktopSize = desktopPane.getSize(); Dimension jInternalFrameSize = internal.getSize(); internal.setLocation( (desktopSize.width - jInternalFrameSize.width) / 2, (desktopSize.height - jInternalFrameSize.height) / 2); } }
/** * Creates a new JInternalFrame based on the contents of an existing JFrame * * @param f the JFrame that will be used to create the JInternalFrame * @param desktop the JDesktopPane that will receive the JInternalFrame, if null it only retunrs * the internal frame * @return a new JInternalFrame */ public JInternalFrame transformToInternalFrame(JFrame f, JDesktopPane desktop) { JInternalFrame jif = new JInternalFrame(f.getTitle(), true, true, true, true); if (f.getIconImage() != null) jif.setFrameIcon(new ImageIcon(f.getIconImage())); if (desktop != null) desktop.add(jif); jif.setSize(f.getSize()); jif.setContentPane(f.getContentPane()); if (desktop != null) SwingUtilities.convertPointFromScreen(f.getLocation(), desktop); jif.setLocation(new Point(0, 0)); jif.setBounds(f.getBounds()); f.dispose(); jif.setVisible(true); return (jif); }
// aqui se añade los internalframe al destop pane private void agregarMarcoInterno(JInternalFrame marco) { marco.setLocation(xSigMarco, ySigMarco); marco.setVisible(true); jDesktopPane.add(marco); try { marco.setSelected(true); } catch (PropertyVetoException ex) { } if (distanciaEntreMarcos == 0) distanciaEntreMarcos = marco.getHeight() - marco.getContentPane().getHeight(); xSigMarco += distanciaEntreMarcos; ySigMarco += distanciaEntreMarcos; if (xSigMarco + marco.getWidth() > jDesktopPane.getWidth()) xSigMarco = 0; if (ySigMarco + marco.getHeight() > jDesktopPane.getHeight()) ySigMarco = 0; }
/** * Open the internal frame for the given {@link BuildOutput} (or bring it to the front, if it is * already open) * * @param buildOutput The {@link BuildOutput} */ private void openBuildOutputFrame(BuildOutput buildOutput) { JInternalFrame buildOutputFrame = openedBuildOutputFrames.get(buildOutput); if (buildOutputFrame != null) { buildOutputFrame.toFront(); return; } buildOutputFrame = new JInternalFrame(buildOutput.getProjectName(), true, true, true, true); openedBuildOutputFrames.put(buildOutput, buildOutputFrame); buildOutputFrame.addInternalFrameListener( new InternalFrameAdapter() { @Override public void internalFrameClosed(InternalFrameEvent e) { openedBuildOutputFrames.remove(buildOutput); } }); buildOutputFrame.getContentPane().add(new BuildOutputPanel(buildOutput)); desktopPane.add(buildOutputFrame); buildOutputFrame.setLocation(0, 0); buildOutputFrame.setSize(desktopPane.getSize()); buildOutputFrame.setVisible(true); }
/** * MouseListener implementation. Shows an internal frame with the picture of the player whose * label was clicked. */ public void mouseClicked(MouseEvent evt) { Object source = evt.getSource(); if ((source == whiteLabel) || (source == blackLabel)) { String name = (source == whiteLabel ? getGame().getWhiteName() : getGame().getBlackName()); URL url; try { url = new URL("http://www.chessclub.com/mugshots/" + name + ".jpg"); } catch (MalformedURLException e) { e.printStackTrace(); return; } JInternalFrame frame = new UserImageInternalFrame(url, name); frame.setLocation(0, 0); JDesktopPane desktop = boardManager.getPluginContext().getMainFrame().getDesktop(); desktop.add(frame, JLayeredPane.PALETTE_LAYER); frame.setSize(frame.getPreferredSize()); frame.setVisible(true); frame.toFront(); } }
/** * Method to handle hyper link events. * * @param event hyper link event */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { setCursor(cbusy); try { URL url = event.getURL(); int ind1 = event.getDescription().indexOf("["); int ind2 = event.getDescription().lastIndexOf("]"); String search = ""; if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2); else { ind1 = event.getDescription().indexOf("=") + 1; // genedb if (ind1 > -1) search = event.getDescription().substring(ind1); } if (desktop != null) { if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search); if (BigPane.srsWin.isSelected()) { int hgt = (2 * desktop.getHeight()) / 3; Annotation edPane = new Annotation(url); JScrollPane jsp = new JScrollPane(edPane); JInternalFrame jif = new JInternalFrame( "SRS " + search, true, // resizable true, // closable true, // maximizable true); // iconifiable); JMenuBar menuBar = new JMenuBar(); menuBar.add(new CommonMenu(jif)); jif.setJMenuBar(menuBar); jif.getContentPane().add(jsp); jif.setLocation(0, 0); jif.setSize(800, hgt); jif.setVisible(true); desktop.add(jif); } if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription()); } else { setPage(url); back.add(url); } } catch (IOException ioe) { String msg = event.getDescription(); if (msg.length() > 50) msg = msg.substring(0, 50) + "...."; JOptionPane.showMessageDialog( this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE); // ioe.printStackTrace(); // ("Can't follow link to " + // event.getURL().toExternalForm() ); } setCursor(cdone); } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(event.getDescription()); } catch (Exception exp) { } } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(""); } catch (Exception exp) { } } }
/** * Sets the location for the 3 internal frames * * @author susiefu * @param direction * @param tilt * @param x * @param y */ protected void setFrameGeometry(String direction, int tilt, int x, int y) { Dimension editwindowsize = editFrame.getSize(); Dimension trisize = triangleFrame.getSize(); int tribase = (Math.round((Math.min(editwindowsize.width, editwindowsize.height))) / 10 > 15) ? Math.round((Math.min(editwindowsize.width, editwindowsize.height))) / 10 : 15; // How // wide // the // base // of // the // triangle // is int fudge = 1; // For the different directions if (direction == "SE") { // Default location if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } else if (direction == "S") { // SAME AS "SE" DIRECTION if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } else if (direction == "W") { if (tilt == 0) { triangleFrame.setLocation( x + editwindowsize.width - fudge, y + 24 - trisize.height + tribase); } else { triangleFrame.setLocation(x + editwindowsize.width - fudge, y + 24); } } else if (direction == "NW") { if (tilt == 0) { triangleFrame.setLocation( x + editwindowsize.width - trisize.width, y + 24 + editwindowsize.height - 2 * fudge); } else { triangleFrame.setLocation( x + editwindowsize.width - tribase, y + 25 + editwindowsize.height - 2 * fudge); } } else if (direction == "N") { if (tilt == 0) { triangleFrame.setLocation( x - trisize.width + tribase, y + 24 + editwindowsize.height - 2 * fudge); } else { triangleFrame.setLocation(x, y + 24 + editwindowsize.height - 2 * fudge); } } else if (direction == "E") { if (tilt == 0) { // Pointing up triangleFrame.setLocation(x - trisize.width + fudge, y + 24 - trisize.height + tribase); } else { triangleFrame.setLocation(x - trisize.width + fudge, y + 24); } } else if (direction == "NONE") { if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } editFrame.setLocation(x, y + 24); buttonFrame.setLocation( x + editwindowsize.width - buttonFrame.getWidth() + fudge, y + buttonFrame.getHeight() / 2 + fudge * 2); }
public void actionPerformed(ActionEvent e) { JDesktopPane dp = (JDesktopPane) e.getSource(); String key = getName(); if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key || RESTORE == key) { setState(dp, key); } else if (ESCAPE == key) { if (sourceFrame == dp.getSelectedFrame() && focusOwner != null) { focusOwner.requestFocus(); } moving = false; resizing = false; sourceFrame = null; focusOwner = null; } else if (MOVE == key || RESIZE == key) { sourceFrame = dp.getSelectedFrame(); if (sourceFrame == null) { return; } moving = (key == MOVE) ? true : false; resizing = (key == RESIZE) ? true : false; focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) { focusOwner = null; } sourceFrame.requestFocus(); } else if (LEFT == key || RIGHT == key || UP == key || DOWN == key || SHRINK_RIGHT == key || SHRINK_LEFT == key || SHRINK_UP == key || SHRINK_DOWN == key) { JInternalFrame c = dp.getSelectedFrame(); if (sourceFrame == null || c != sourceFrame || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != sourceFrame) { return; } Insets minOnScreenInsets = UIManager.getInsets("Desktop.minOnScreenInsets"); Dimension size = c.getSize(); Dimension minSize = c.getMinimumSize(); int dpWidth = dp.getWidth(); int dpHeight = dp.getHeight(); int delta; Point loc = c.getLocation(); if (LEFT == key) { if (moving) { c.setLocation( loc.x + size.width - MOVE_RESIZE_INCREMENT < minOnScreenInsets.right ? -size.width + minOnScreenInsets.right : loc.x - MOVE_RESIZE_INCREMENT, loc.y); } else if (resizing) { c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y); c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height); } } else if (RIGHT == key) { if (moving) { c.setLocation( loc.x + MOVE_RESIZE_INCREMENT > dpWidth - minOnScreenInsets.left ? dpWidth - minOnScreenInsets.left : loc.x + MOVE_RESIZE_INCREMENT, loc.y); } else if (resizing) { c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height); } } else if (UP == key) { if (moving) { c.setLocation( loc.x, loc.y + size.height - MOVE_RESIZE_INCREMENT < minOnScreenInsets.bottom ? -size.height + minOnScreenInsets.bottom : loc.y - MOVE_RESIZE_INCREMENT); } else if (resizing) { c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT); c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT); } } else if (DOWN == key) { if (moving) { c.setLocation( loc.x, loc.y + MOVE_RESIZE_INCREMENT > dpHeight - minOnScreenInsets.top ? dpHeight - minOnScreenInsets.top : loc.y + MOVE_RESIZE_INCREMENT); } else if (resizing) { c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT); } } else if (SHRINK_LEFT == key && resizing) { // Make sure we don't resize less than minimum size. if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) { delta = MOVE_RESIZE_INCREMENT; } else { delta = size.width - minSize.width; } // Ensure that we keep the internal frame on the desktop. if (loc.x + size.width - delta < minOnScreenInsets.left) { delta = loc.x + size.width - minOnScreenInsets.left; } c.setSize(size.width - delta, size.height); } else if (SHRINK_RIGHT == key && resizing) { // Make sure we don't resize less than minimum size. if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) { delta = MOVE_RESIZE_INCREMENT; } else { delta = size.width - minSize.width; } // Ensure that we keep the internal frame on the desktop. if (loc.x + delta > dpWidth - minOnScreenInsets.right) { delta = (dpWidth - minOnScreenInsets.right) - loc.x; } c.setLocation(loc.x + delta, loc.y); c.setSize(size.width - delta, size.height); } else if (SHRINK_UP == key && resizing) { // Make sure we don't resize less than minimum size. if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) { delta = MOVE_RESIZE_INCREMENT; } else { delta = size.height - minSize.height; } // Ensure that we keep the internal frame on the desktop. if (loc.y + size.height - delta < minOnScreenInsets.bottom) { delta = loc.y + size.height - minOnScreenInsets.bottom; } c.setSize(size.width, size.height - delta); } else if (SHRINK_DOWN == key && resizing) { // Make sure we don't resize less than minimum size. if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) { delta = MOVE_RESIZE_INCREMENT; } else { delta = size.height - minSize.height; } // Ensure that we keep the internal frame on the desktop. if (loc.y + delta > dpHeight - minOnScreenInsets.top) { delta = (dpHeight - minOnScreenInsets.top) - loc.y; } c.setLocation(loc.x, loc.y + delta); c.setSize(size.width, size.height - delta); } } else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) { dp.selectFrame((key == NEXT_FRAME) ? true : false); } else if (NAVIGATE_NEXT == key || NAVIGATE_PREVIOUS == key) { boolean moveForward = true; if (NAVIGATE_PREVIOUS == key) { moveForward = false; } Container cycleRoot = dp.getFocusCycleRootAncestor(); if (cycleRoot != null) { FocusTraversalPolicy policy = cycleRoot.getFocusTraversalPolicy(); if (policy != null && policy instanceof SortingFocusTraversalPolicy) { SortingFocusTraversalPolicy sPolicy = (SortingFocusTraversalPolicy) policy; boolean idc = sPolicy.getImplicitDownCycleTraversal(); try { sPolicy.setImplicitDownCycleTraversal(false); if (moveForward) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(dp); } else { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(dp); } } finally { sPolicy.setImplicitDownCycleTraversal(idc); } } } } }