Java Code Examples for javax.swing.JFrame#setExtendedState()
The following examples show how to use
javax.swing.JFrame#setExtendedState() .
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: SeaGlassTitlePane.java From seaglass with Apache License 2.0 | 7 votes |
/** * Maximize/Restore the window. * * @param maximize iconify {@code true} if we are to maximize the window, * {@code false} if we are to restore the window. */ private void setParentMaximum(boolean maximize) { if (rootParent instanceof JFrame) { JFrame frame = (JFrame) rootParent; int state = frame.getExtendedState(); if (maximize) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Insets i = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle r = gc.getBounds(); r.x = 0; r.y = 0; r.width -= i.left + i.right; r.height -= i.top + i.bottom; frame.setMaximizedBounds(r); } frame.setExtendedState(maximize ? state | Frame.MAXIMIZED_BOTH : state & ~Frame.MAXIMIZED_BOTH); } }
Example 2
Source File: OurUtil.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** Make the frame visible, non-iconized, and focused. */ public static void show(JFrame frame) { frame.setVisible(true); frame.setExtendedState(frame.getExtendedState() & ~Frame.ICONIFIED); frame.requestFocus(); frame.toFront(); }
Example 3
Source File: UIUtil.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
/** * Restore a frame, possibly minimized, to the front (either normal or maximized) * * @param frame the frame to show * @see #minimize(JFrame) */ public static void unMinimize (JFrame frame) { int state = frame.getExtendedState(); if ((state & ICONIFIED) != 0) { state &= ~ICONIFIED; } frame.setExtendedState(state); frame.setVisible(true); frame.toFront(); }
Example 4
Source File: UI.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
public static JFrame createWindow() { JFrame window = new JFrame(); window.setUndecorated(true); window.setExtendedState(Frame.MAXIMIZED_BOTH); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); return window; }
Example 5
Source File: AbstractDockingTool.java From ghidra with Apache License 2.0 | 6 votes |
@Override public void toFront() { JFrame frame = winMgr.getRootFrame(); if (frame.getExtendedState() == Frame.ICONIFIED) { frame.setExtendedState(Frame.NORMAL); } frame.toFront(); }
Example 6
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 7
Source File: JIntellitypeDemo.java From jintellitype with Apache License 2.0 | 6 votes |
/** * Centers window on desktop. * <p> * * @param aFrame the Frame to center */ private static void center(JFrame aFrame) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final Point centerPoint = ge.getCenterPoint(); final Rectangle bounds = ge.getMaximumWindowBounds(); final int w = Math.min(aFrame.getWidth(), bounds.width); final int h = Math.min(aFrame.getHeight(), bounds.height); final int x = centerPoint.x - (w / 2); final int y = centerPoint.y - (h / 2); aFrame.setBounds(x, y, w, h); if ((w == bounds.width) && (h == bounds.height)) { aFrame.setExtendedState(Frame.MAXIMIZED_BOTH); } aFrame.validate(); }
Example 8
Source File: UserPreferences.java From Spade with GNU General Public License v3.0 | 6 votes |
public static void loadPrefs(JFrame frame, ColourChooser chooser, LayerManager layers) { Preferences prefs = Preferences.userNodeForPackage(UserPreferences.class); if(prefs.getBoolean(WINDOW_MAXIMIZED, false)) { frame.setExtendedState(Frame.MAXIMIZED_BOTH); } windowWidth = prefs.getInt(WINDOW_WIDTH, 800); windowHeight = prefs.getInt(WINDOW_HEIGHT, 600); colourPickerX = prefs.getInt(COLOUR_PICKER_X, 0); colourPickerY = prefs.getInt(COLOUR_PICKER_Y, 0); colourPickerMode = prefs.getInt(COLOUR_PICKER_MODE, 2); layersX = prefs.getInt(LAYERS_X, 0); layersY = prefs.getInt(LAYERS_Y, 0); layersWidth = prefs.getInt(LAYERS_WIDTH, 200); layersHeight = prefs.getInt(LAYERS_HEIGHT, 300); frame.setSize(windowWidth, windowHeight); frame.setLocationRelativeTo(null); chooser.setLocation(colourPickerX, colourPickerY); chooser.setMode(colourPickerMode); if(prefs.getBoolean(COLOUR_PICKER_VISIBLE, false)) { chooser.setVisible(true); } layers.dialog.setVisible(prefs.getBoolean(LAYERS_VISIBLE, false)); layers.dialog.setBounds(layersX, layersY, layersWidth, layersHeight); Menu.DARK_BACKGROUND = prefs.getBoolean(BACKGROUND_DARK, false); }
Example 9
Source File: UI.java From arcgis-runtime-demo-java with Apache License 2.0 | 5 votes |
public static JFrame createWindow() { JFrame window = new JFrame(); window.setUndecorated(true); window.setExtendedState(Frame.MAXIMIZED_BOTH); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); return window; }
Example 10
Source File: OurUtil.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** This method minimizes the window. */ public static void minimize(JFrame frame) { frame.setExtendedState(Frame.ICONIFIED); }
Example 11
Source File: GeometryOfflineApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 5 votes |
/** * Creates a window. * @return a window. */ private JFrame createWindow() { JFrame window = new JFrame(); window.setExtendedState(Frame.MAXIMIZED_BOTH); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); window.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { super.windowClosing(windowEvent); map.dispose(); } }); return window; }
Example 12
Source File: GeometryOnlineApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 5 votes |
public GeometryOnlineApp() { window = new JFrame(); //window.setSize(800, 600); window.setExtendedState(Frame.MAXIMIZED_BOTH); window.setLocationRelativeTo(null); // center on screen window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); // dispose map just before application window is closed. window.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { super.windowClosing(windowEvent); map.dispose(); } }); // center of USA MapOptions mapOptions = new MapOptions(MapType.TOPO, 37.77279077295881, -96.44323104731787, 3); //create a map using the map options map = new JMap(mapOptions); window.getContentPane().add(map); featureLayer = new ArcGISFeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"); map.getLayers().add(featureLayer); // The code below shows how to add a tiled layer if you don't use MapOptions //ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( // "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); // map.getLayers().add(tiledLayer); graphicsLayer = new GraphicsLayer(); map.getLayers().add(graphicsLayer); map.addMapOverlay(onMouseClickOverlay); }
Example 13
Source File: UIUtil.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Minimize the provided frame. * * @param frame the frame to minimize to icon * @see #unMinimize(JFrame) */ public static void minimize (JFrame frame) { int state = frame.getExtendedState(); state &= ICONIFIED; frame.setExtendedState(state); }
Example 14
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 15
Source File: FullScreenUtils.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
public static void makeFullScreen(JFrame frame) { frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setUndecorated(true); frame.setResizable(false); }
Example 16
Source File: NBodyVisualizer.java From gpu-nbody with MIT License | 4 votes |
/** * Creates a new JOCLSimpleGL3 sample. * * @param capabilities * The GL capabilities */ public NBodyVisualizer(final GLCapabilities capabilities) { glComponent = new GLCanvas(capabilities); glComponent.setFocusable(true); glComponent.addGLEventListener(this); // Initialize the mouse and keyboard controls final MouseControl mouseControl = new MouseControl(); glComponent.addMouseMotionListener(mouseControl); glComponent.addMouseWheelListener(mouseControl); final KeyboardControl keyboardControl = new KeyboardControl(); glComponent.addKeyListener(keyboardControl); setFullscreen(); updateModelviewMatrix(); // Create and start an animator animator = new Animator(glComponent); animator.start(); // Create the simulation // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SerializedUniverseGenerator("universes/sphericaluniverse1.universe")); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SerializedUniverseGenerator("universes/montecarlouniverse1.universe")); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RotatingDiskGalaxyGenerator(3.5f, 25, 0)); simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RotatingDiskGalaxyGenerator(3.5f, 1, 1)); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SphericalUniverseGenerator()); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new LonLatSphericalUniverseGenerator()); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RandomCubicUniverseGenerator(5)); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new MonteCarloSphericalUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 2048 * 8, new LonLatSphericalUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 2048, new PlummerUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 128, new SphericalUniverseGenerator()); // Create the main frame frame = new JFrame("NBody Simulation"); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { runExit(); } }); frame.setLayout(new BorderLayout()); frame.add(glComponent, BorderLayout.CENTER); frame.setUndecorated(true); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); frame.setLocationRelativeTo(null); glComponent.requestFocus(); }
Example 17
Source File: WindowMenuItem.java From Logisim with GNU General Public License v3.0 | 4 votes |
public void actionPerformed(ActionEvent event) { JFrame frame = getJFrame(); frame.setExtendedState(Frame.NORMAL); frame.setVisible(true); frame.toFront(); }
Example 18
Source File: OurUtil.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * This method alternatingly maximizes or restores the window. */ public static void zoom(JFrame frame) { int both = Frame.MAXIMIZED_BOTH; frame.setExtendedState((frame.getExtendedState() & both) != both ? both : Frame.NORMAL); }
Example 19
Source File: EdgeSim.java From EdgeSim with MIT License | 4 votes |
/** * Add a controller to the emulator and initialize the main window. In * addition, the main window adds listeners. */ private void initial() { { // Instantiate all components and controller Controller controller = new Controller(); this.map = new Map(); this.operator = new Operator(); this.log = new Log(); this.menu = new MenuBar(); controller.initialController(menu, map, operator, log, controller); } { // Initialize UI JPanel panel = new JPanel(); GridBagLayout variablePanel = new GridBagLayout(); variablePanel.columnWidths = new int[] { 0, 0 }; variablePanel.rowHeights = new int[] { 0, 0, 0 }; variablePanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; variablePanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; panel.setLayout(variablePanel); // Initialize main frame mainFrame = new JFrame(); mainFrame.setTitle("EdgeSim"); mainFrame.setBounds(250, 0, 1400, 1050); mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH); // mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); . mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); ImageIcon icon = new ImageIcon("src/main/resources/images/icon.png"); // xxx����ͼƬ���·����2.pngͼƬ���Ƽ���ʽ mainFrame.setIconImage(icon.getImage()); // Add menu mainFrame.getContentPane().add(menu, BorderLayout.NORTH); // Set the separation panel JSplitPane MainPanel = new JSplitPane(); MainPanel.setContinuousLayout(true); MainPanel.setResizeWeight(1); MainPanel.setDividerLocation(0.9); mainFrame.getContentPane().add(MainPanel, BorderLayout.CENTER); JSplitPane MapAndLogPanel = new JSplitPane( JSplitPane.VERTICAL_SPLIT); MapAndLogPanel.setContinuousLayout(true); MapAndLogPanel.setResizeWeight(0.8); MainPanel.setDividerLocation(0.9); MapAndLogPanel.setLeftComponent(map); MapAndLogPanel.setRightComponent(log); MainPanel.setLeftComponent(MapAndLogPanel); MainPanel.setRightComponent(operator); } // Add listener mainFrame.addWindowListener(new MyActionListener()); }