Java Code Examples for javax.swing.JFrame#MAXIMIZED_BOTH
The following examples show how to use
javax.swing.JFrame#MAXIMIZED_BOTH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientUI.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void saveClientBoundsConfig() { final Rectangle bounds = frame.getBounds(); if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0) { configManager.setConfiguration(CONFIG_GROUP, CONFIG_CLIENT_BOUNDS, bounds); configManager.setConfiguration(CONFIG_GROUP, CONFIG_CLIENT_MAXIMIZED, true); } else { if (config.automaticResizeType() == ExpandResizeType.KEEP_GAME_SIZE) { // Try to contract plugin panel if (pluginPanel != null) { bounds.width -= pluginPanel.getWrappedPanel().getPreferredSize().width; } } configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_CLIENT_MAXIMIZED); configManager.setConfiguration(CONFIG_GROUP, CONFIG_CLIENT_BOUNDS, bounds); } }
Example 2
Source File: LuckTitlePanel.java From littleluck with Apache License 2.0 | 6 votes |
/** * update Maximize button icon when window state change. */ private void updateMaximizeBtn() { if((state & JFrame.MAXIMIZED_BOTH) != 0) { maximizeBtn.setIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAXIMIZE_NORMAL_ICON)); maximizeBtn.setRolloverIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAXIMIZE_ROVER_ICON)); maximizeBtn.setPressedIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAXIMIZE_PRESSED_ICON)); } else { maximizeBtn.setIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAX_NORMAL_ICON)); maximizeBtn.setRolloverIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAX_ROVER_ICON)); maximizeBtn.setPressedIcon(UIManager.getIcon(LuckRootPaneUIBundle.MAX_PRESSED_ICON)); } }
Example 3
Source File: LuckTitlePanel.java From littleluck with Apache License 2.0 | 6 votes |
@Override public void mouseClicked(MouseEvent e) { Window window = getWindow(); if(window instanceof JFrame) { JFrame frame = ((JFrame)window); // 必须先禁用按钮否则无法取消焦点事件 // must set enable false here. maximizeBtn.setEnabled(false); if ((state & JFrame.ICONIFIED) != 0) { frame.setExtendedState(state & ~JFrame.ICONIFIED); } else if((state & JFrame.MAXIMIZED_BOTH) != 0) { frame.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { frame.setExtendedState(state | Frame.MAXIMIZED_BOTH); } maximizeBtn.setEnabled(true); } }
Example 4
Source File: CampaignEditor.java From open-ig with GNU Lesser General Public License v3.0 | 6 votes |
/** * Load the window state from the specified XML element. * @param w the target frame * @param xml the xml element */ public static void loadWindowState(Frame w, XElement xml) { if (xml == null) { return; } int state = xml.getInt("window-state", w.getExtendedState()); if (state != JFrame.MAXIMIZED_BOTH) { int x = xml.getInt("window-x", w.getX()); int y = xml.getInt("window-y", w.getY()); int width = xml.getInt("window-width", w.getWidth()); int height = xml.getInt("window-height", w.getHeight()); w.setExtendedState(state); w.setBounds(x, y, width, height); } else { w.setExtendedState(state); } }
Example 5
Source File: JFrame_Main.java From MobyDroid with Apache License 2.0 | 5 votes |
/** * */ private void maximizeHandle() { if ((this.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH) { this.setExtendedState(this.getExtendedState() & ~JFrame.MAXIMIZED_BOTH); } else { this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); } }
Example 6
Source File: JFrame_Main.java From MobyDroid with Apache License 2.0 | 5 votes |
@Override public void mousePressed(MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON1) { prevX = me.getXOnScreen(); prevY = me.getYOnScreen(); if ((outcode = getOutcode(me.getPoint(), new Rectangle(me.getComponent().getSize()))) != 0) { resizing = true; prevR = me.getComponent().getBounds(); } else if (jPanel_TitleBar.contains(me.getPoint()) && ((getExtendedState() & JFrame.MAXIMIZED_BOTH) != JFrame.MAXIMIZED_BOTH)) { dragging = true; } } }
Example 7
Source File: LuckWindowAdapter.java From littleluck with Apache License 2.0 | 5 votes |
public void windowStateChanged(WindowEvent e) { Window window = (Window) e.getSource(); if (window instanceof JFrame) { JFrame frame = (JFrame) window; JRootPane rootPane = frame.getRootPane(); if(rootPane.getUI() instanceof LuckRootPaneUI) { LuckRootPaneUI rootPaneUI = (LuckRootPaneUI) rootPane.getUI(); rootPaneUI.getTitlePane().setState(e.getNewState()); } if (e.getNewState() == JFrame.MAXIMIZED_BOTH) { rootPane.setBorder(null); } else if (e.getNewState() == JFrame.NORMAL) { rootPane.setBorder(UIManager.getBorder(LuckRootPaneUIBundle.FRAME_BORDER)); } } }
Example 8
Source File: CampaignEditor.java From open-ig with GNU Lesser General Public License v3.0 | 5 votes |
/** * Save the window state into the given XML element. * @param w the window * @param xml the output */ public static void saveWindowState(Frame w, XElement xml) { int state = w.getExtendedState(); xml.set("window-state", state); if (state != JFrame.MAXIMIZED_BOTH) { xml.set("window-x", w.getX()); xml.set("window-y", w.getY()); xml.set("window-width", w.getWidth()); xml.set("window-height", w.getHeight()); } }
Example 9
Source File: WindowMouseHandler.java From littleluck with Apache License 2.0 | 4 votes |
/** * 处理JFrame的双击标题面板缩放事件 */ public void mouseClicked(MouseEvent e) { Window window = (Window) e.getSource(); if(window instanceof JFrame) { JFrame frame = (JFrame) window; JRootPane root = frame.getRootPane(); // 不包含窗体装饰直接返回 if (root.getWindowDecorationStyle() == JRootPane.NONE) { return; } // 不在标题栏覆盖区域直接返回 if(!titleArea.contains(e.getPoint())) { return; } if ((e.getClickCount() % 2) == 0 && ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { int state = frame.getExtendedState(); if (frame.isResizable()) { if ((state & JFrame.MAXIMIZED_BOTH) != 0) { frame.setExtendedState(state & ~JFrame.MAXIMIZED_BOTH); } else { frame.setExtendedState(state | JFrame.MAXIMIZED_BOTH); } } } } }
Example 10
Source File: WindowMouseHandler.java From littleluck with Apache License 2.0 | 4 votes |
/** * v1.0.1:修复自定义拖拽区域BUG, 增加边界判断 */ public void mousePressed(MouseEvent e) { Window window = (Window) e.getSource(); JRootPane root = LuckWindowUtil.getRootPane(window); // 不包含窗体装饰直接返回 if (root == null || root.getWindowDecorationStyle() == JRootPane.NONE) { return; } if (window != null) { window.toFront(); } // 如果是单击标题栏, 则标记接下来的拖动事件为移动窗口, 判断当前鼠标是否超出边界 if (dragArea.contains(e.getPoint()) && dragCursor == Cursor.DEFAULT_CURSOR) { if(window instanceof JFrame) { JFrame frame = (JFrame)window; // 如果当前窗体是全屏状态则直接返回 if(frame.getExtendedState() == JFrame.MAXIMIZED_BOTH) { return; } } // 设置为可以移动并记录当前坐标 isMovingWindow = true; dragOffsetX = e.getPoint().x; dragOffsetY = e.getPoint().y; } else if(LuckWindowUtil.isResizable(window)) { dragOffsetX = e.getPoint().x; dragOffsetY = e.getPoint().y; dragWidth = window.getWidth(); dragHeight = window.getHeight(); JRootPane rootPane = LuckWindowUtil.getRootPane(window); if(rootPane != null && LuckWindowUtil.isResizable(window)) { dragCursor = getCursor(dragWidth, dragHeight, e.getPoint(), rootPane.getInsets()); } } }
Example 11
Source File: MagicStickyFrame.java From magarena with GNU General Public License v3.0 | 4 votes |
private boolean isFullScreen() { return getExtendedState() == JFrame.MAXIMIZED_BOTH && this.isUndecorated(); }
Example 12
Source File: WindowPosition.java From Luyten with Apache License 2.0 | 4 votes |
public void readPositionFromWindow(JFrame window) { isFullScreen = (window.getExtendedState() == JFrame.MAXIMIZED_BOTH); if (!isFullScreen) { this.readPositionFromComponent(window); } }
Example 13
Source File: NMONVisualizerGui.java From nmonvisualizer with Apache License 2.0 | 4 votes |
/** * Gracefully exits the application. This method asks the user for confirmation through a JOptionPane before * continuing. If the user selects "Yes", the application saves all preferences and calls dispose() on the main * frame. */ void exit() { int confirm = JOptionPane.showConfirmDialog(mainFrame, "Are you sure you want to Exit?", "Exit?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == 0) { // save the window sizes to the Preferences // if the window is maximized, do not save the sizes -- keep // the old ones so the user can un-maximize later if ((mainFrame.getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0) { getPreferences().putBoolean("WindowMaximized", true); } else { getPreferences().putBoolean("WindowMaximized", false); getPreferences().putInt("WindowPosX", mainFrame.getX()); getPreferences().putInt("WindowPosY", mainFrame.getY()); getPreferences().putInt("WindowSizeX", (int) mainFrame.getSize().getWidth()); getPreferences().putInt("WindowSizeY", (int) mainFrame.getSize().getHeight()); } // close any open custom report windows for (java.awt.Frame frame : java.awt.Frame.getFrames()) { if (frame.getClass() == com.ibm.nmon.gui.report.ReportFrame.class) { ((com.ibm.nmon.gui.report.ReportFrame) frame).setVisible(false); ((com.ibm.nmon.gui.report.ReportFrame) frame).dispose(); } } getPreferences().put("systemsNamedBy", getProperty("systemsNamedBy")); getPreferences().put("scaleProcessesByCPUs", getProperty("scaleProcessesByCPUs")); getPreferences().put("showStatusBar", getProperty("showStatusBar")); getPreferences().put("lineChartLegend", getProperty("lineChartLegend")); logViewer.dispose(); mainFrame.dispose(); try { preferences.sync(); } catch (java.util.prefs.BackingStoreException e) { logger.warn("could not save preferences", e); } } }