/** * Maximise the Project-Window within the AgenGUI-Application */ public void setMaximized() { MainWindow mainWindow = Application.getMainWindow(); if (mainWindow != null) { // --- Validate the main application window ----------------- mainWindow.validate(); // --- Be sure that everything is there as needed ----------- if (this.getParent() != null) { ((BasicInternalFrameUI) this.getUI()).setNorthPane(null); DesktopManager dtm = mainWindow.getJDesktopPane4Projects().getDesktopManager(); if (dtm != null) { dtm.maximizeFrame(this); } } mainWindow.setCloseButtonPosition(true); } }
/** * Tab maximize. */ private void tabMaximize() { // --- Maximize the main window --------------------------------------- // Application.getMainWindow().setExtendedState(JFrame.MAXIMIZED_BOTH); // --- Open a new JInteraFrame with the current tab enlarged ---------- SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDesktopPane appDesktop = Application.getMainWindow().getJDesktopPane4Projects(); if (maxTab == null) { appDesktop.add(getMaximizedTab()); Application.getMainWindow().addJToolbarComponent(getMaximizedTab().getJButtonRestore4MainToolBar()); } DesktopManager dtm = Application.getMainWindow().getJDesktopPane4Projects().getDesktopManager(); if (dtm != null) { dtm.activateFrame(getMaximizedTab()); dtm.maximizeFrame(getMaximizedTab()); } } }); }
/** * This method is called when the mouse is pressed. * * @param e The MouseEvent. */ public void mousePressed(MouseEvent e) { activateFrame(frame); DesktopManager dm = getDesktopManager(); int x = e.getX(); int y = e.getY(); Insets insets = frame.getInsets(); if (e.getSource() == frame && frame.isResizable()) { direction = sectionOfClick(x, y); dm.beginResizingFrame(frame, direction); } else if (e.getSource() == titlePane) { Rectangle tBounds = titlePane.getBounds(); xOffset = e.getX() - tBounds.x + insets.left; yOffset = e.getY() - tBounds.y + insets.top; dm.beginDraggingFrame(frame); } }
/** * This method is called when the mouse is released. * * @param e The MouseEvent. */ public void mouseReleased(MouseEvent e) { DesktopManager dm = getDesktopManager(); xOffset = 0; yOffset = 0; if (e.getSource() == frame && frame.isResizable()) dm.endResizingFrame(frame); else if (e.getSource() == titlePane) { dm.endDraggingFrame(frame); frame.putClientProperty("bufferedDragging", null); } setCursor(e); }
public void testGetDesktopManager() { frame.setUI(ui); // no desktop pane, the default desktop manager is created DesktopManager manager1 = ui.getDesktopManager(); assertTrue("not null", manager1 != null); DesktopManager manager2 = ui.getDesktopManager(); assertTrue("the same object", manager1 == manager2); assertNull("no desktop pane", frame.getDesktopPane()); // the desktop pane is set JDesktopPane desktop = new JDesktopPane(); desktop.add(frame); manager2 = ui.getDesktopManager(); assertTrue("not null", manager2 != null); assertTrue("is taken from desktop pane", manager2 == frame.getDesktopPane() .getDesktopManager()); assertTrue("another object", manager2 != manager1); }
/** * This method returns the DesktopManager to use with the JInternalFrame. * * @return The DesktopManager to use with the JInternalFrame. */ protected DesktopManager getDesktopManager() { DesktopManager value = null; JDesktopPane pane = frame.getDesktopPane(); if (pane != null) value = frame.getDesktopPane().getDesktopManager(); if (value == null) value = createDesktopManager(); return value; }
protected DesktopManager getDesktopManager() { JDesktopPane desktop = frame.getDesktopPane(); if (desktop != null) { return desktop.getDesktopManager(); } if (defaultDesktopManager == null) { defaultDesktopManager = createDesktopManager(); } return defaultDesktopManager; }
/** * This method is called when the mouse is dragged. This method is * responsible for resizing or dragging the JInternalFrame. * * @param e The MouseEvent. */ public void mouseDragged(MouseEvent e) { // If the frame is maximized, there is nothing that // can be dragged around. if (frame.isMaximum()) return; DesktopManager dm = getDesktopManager(); Rectangle b = frame.getBounds(); Dimension min = frame.getMinimumSize(); if (min == null) min = new Dimension(0, 0); Insets insets = frame.getInsets(); int x = e.getX(); int y = e.getY(); if (e.getSource() == frame && frame.isResizable()) { switch (direction) { case Cursor.N_RESIZE_CURSOR: cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height - min.height), b.width, b.height - y); break; case Cursor.NE_RESIZE_CURSOR: cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height - min.height), x + 1, b.height - y); break; case Cursor.E_RESIZE_CURSOR: cacheRect.setBounds(b.x, b.y, x + 1, b.height); break; case Cursor.SE_RESIZE_CURSOR: cacheRect.setBounds(b.x, b.y, x + 1, y + 1); break; case Cursor.S_RESIZE_CURSOR: cacheRect.setBounds(b.x, b.y, b.width, y + 1); break; case Cursor.SW_RESIZE_CURSOR: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width), b.y, b.width - x, y + 1); break; case Cursor.W_RESIZE_CURSOR: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width), b.y, b.width - x, b.height); break; case Cursor.NW_RESIZE_CURSOR: cacheRect.setBounds( Math.min(b.x + x, b.x + b.width - min.width), Math.min(b.y + y, b.y + b.height - min.height), b.width - x, b.height - y); break; } dm.resizeFrame(frame, cacheRect.x, cacheRect.y, Math.max(min.width, cacheRect.width), Math.max(min.height, cacheRect.height)); setCursor(e); } else if (e.getSource() == titlePane) { Rectangle fBounds = frame.getBounds(); frame.putClientProperty("bufferedDragging", Boolean.TRUE); dm.dragFrame(frame, e.getX() - xOffset + b.x, e.getY() - yOffset + b.y); } }
protected void autoScrollingStep(AutoScrollTimerTask asTask) { if (autoscrollingPane != null && autoscrollingDirection != null && asTask != null) { JScrollPane lautoscrollingPane = autoscrollingPane; Component lviewComp = lautoscrollingPane.getViewport().getView(); if (lviewComp instanceof JComponent) { JComponent lview = (JComponent) lviewComp; Point lautoscrollingDirection = autoscrollingDirection; Rectangle viewRect = lautoscrollingPane.getViewport().getViewRect(); Rectangle viewRectBeforeMovement = (Rectangle) viewRect.clone(); viewRect.translate(lautoscrollingDirection.x, lautoscrollingDirection.y); lview.scrollRectToVisible(viewRect); Rectangle viewRectAfterMovement = lautoscrollingPane.getViewport().getViewRect(); lautoscrollingDirection.x = viewRectAfterMovement.x - viewRectBeforeMovement.x; lautoscrollingDirection.y = viewRectAfterMovement.y - viewRectBeforeMovement.y; if (lautoscrollingDirection.x != 0 || lautoscrollingDirection.y != 0) { MouseEvent e = asTask.getEvent(); if (e != null && dragTarget != null) { JDesktopPane ldp = null; DesktopManager ldm = null; JInternalFrame lif = null; JDesktopIcon ldi = null; lif = iifInternalFrame(dragTarget); if (lif != null && lif.getDesktopPane() != null) { ldp = lif.getDesktopPane(); ldm = ldp.getDesktopManager(); } else { ldi = iifDesktopIcon(dragTarget); if (ldi != null && ldi.getDesktopPane() != null) { ldp = ldi.getDesktopPane(); ldm = ldp.getDesktopManager(); } } if (ldp != null && ldm != null && (lif != null || ldi != null)) { MouseListener[] mlisteners = dragTarget.getMouseListeners(); MouseMotionListener[] mmlisteners = dragTarget.getMouseMotionListeners(); if (mlisteners != null && mmlisteners != null) { ldp.setDesktopManager(dummyDesktopManager); try { for (int i = 0; i < mlisteners.length; i++) { mlisteners[i].mousePressed(cloneMouseEvent(e, dragTarget, e.getID(), dragTargetInnerPt)); } } finally { ldp.setDesktopManager(ldm); } asTask.incEvent(lautoscrollingDirection); MouseEvent afterMoveE = asTask.getEvent(); Point afterMovePt = convertPoint(afterMoveE.getPoint(), dragTarget); Dimension beforeDragSize = dragTarget.getSize(); int lbeforeWidth = dragTarget.getWidth(); int lbeforeHeight = dragTarget.getHeight(); for (int i = 0; i < mmlisteners.length; i++) { mmlisteners[i].mouseDragged(cloneMouseEvent(e, dragTarget, e.getID(), afterMovePt)); } Dimension afterDragSize = dragTarget.getSize(); if (beforeDragSize != null && afterDragSize != null && !beforeDragSize.equals(afterDragSize) && dragTarget != null && dragTarget instanceof JComponent) { int ldx = afterDragSize.width - beforeDragSize.width; int ldy = afterDragSize.height - beforeDragSize.height; JComponent jDragTarget = (JComponent) dragTarget; Insets insts = jDragTarget.getInsets(); if (dragTargetInnerPt.x >= lbeforeWidth - insts.right) { dragTargetInnerPt.x += ldx; } if (dragTargetInnerPt.y >= lbeforeHeight - insts.bottom) { dragTargetInnerPt.y += ldy; } } } } } } } else { cancelAutoScrolling(); } } }
protected DesktopManager createDesktopManager() { return new DefaultDesktopManager(); }
public void testCreateDesktopManager() { DesktopManager manager1 = ui.createDesktopManager(); assertTrue("not null", manager1 != null); DesktopManager manager2 = ui.createDesktopManager(); assertTrue("other object", manager1 != manager2); }
/** * This method returns a default DesktopManager that can be used with this * JInternalFrame. * * @return A default DesktopManager that can be used with this * JInternalFrame. */ protected DesktopManager createDesktopManager() { return new DefaultDesktopManager(); }