Java Code Examples for java.awt.Dimension#equals()
The following examples show how to use
java.awt.Dimension#equals() .
These examples are extracted from open source projects.
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 Project: dragonwell8_jdk File: TextAreaTwicePack.java License: GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) { final Frame frame = new Frame(); final TextArea ta = new TextArea(); frame.add(ta); frame.pack(); frame.setVisible(true); sleep(); final Dimension before = frame.getSize(); frame.pack(); final Dimension after = frame.getSize(); if (!after.equals(before)) { throw new RuntimeException( "Expected size: " + before + ", actual size: " + after); } frame.dispose(); }
Example 2
Source Project: openjdk-8-source File: TextAreaTwicePack.java License: GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) { final Frame frame = new Frame(); final TextArea ta = new TextArea(); frame.add(ta); frame.pack(); frame.setVisible(true); sleep(); final Dimension before = frame.getSize(); frame.pack(); final Dimension after = frame.getSize(); if (!after.equals(before)) { throw new RuntimeException( "Expected size: " + before + ", actual size: " + after); } frame.dispose(); }
Example 3
Source Project: ghidra File: FGVertexListingPanel.java License: Apache License 2.0 | 6 votes |
@Override public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); if (preferredSize.equals(lastParentPreferredSize) && preferredSizeCache != null) { return preferredSizeCache; } lastParentPreferredSize = preferredSize; LayoutModel layoutModel = getLayoutModel(); List<Layout> layouts = getAllLayouts(layoutModel); int largestWidth = 0; for (Layout layout : layouts) { int width = layout.getCompressableWidth(); if (width > largestWidth) { largestWidth = width; } } preferredSize.width = largestWidth; preferredSizeCache = preferredSize; return preferredSize; }
Example 4
Source Project: jdk8u-jdk File: MaximizedNormalBoundsUndecoratedTest.java License: GNU General Public License v2.0 | 6 votes |
boolean doTest() { Dimension beforeMaximizeCalled = new Dimension(300,300); frame = new Frame("Test Frame"); frame.setUndecorated(true); frame.setFocusable(true); frame.setSize(beforeMaximizeCalled); frame.setVisible(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setExtendedState(Frame.NORMAL); Dimension afterMaximizedCalled= frame.getBounds().getSize(); frame.dispose(); if (beforeMaximizeCalled.equals(afterMaximizedCalled)) { return true; } return false; }
Example 5
Source Project: openjdk-jdk9 File: IsToolkitUseTheMainScreen.java License: GNU General Public License v2.0 | 6 votes |
private static void testHeadful() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); Dimension gcSize = gc.getBounds().getSize(); ColorModel gcCM = gc.getColorModel(); Dimension toolkitSize = Toolkit.getDefaultToolkit().getScreenSize(); ColorModel toolkitCM = Toolkit.getDefaultToolkit().getColorModel(); if (!gcSize.equals(toolkitSize)) { System.err.println("Toolkit size = " + toolkitSize); System.err.println("GraphicsConfiguration size = " + gcSize); throw new RuntimeException("Incorrect size"); } if (!gcCM.equals(toolkitCM)) { System.err.println("Toolkit color model = " + toolkitCM); System.err.println("GraphicsConfiguration color model = " + gcCM); throw new RuntimeException("Incorrect color model"); } }
Example 6
Source Project: openjdk-jdk8u File: TextAreaTwicePack.java License: GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) { final Frame frame = new Frame(); final TextArea ta = new TextArea(); frame.add(ta); frame.pack(); frame.setVisible(true); sleep(); final Dimension before = frame.getSize(); frame.pack(); final Dimension after = frame.getSize(); if (!after.equals(before)) { throw new RuntimeException( "Expected size: " + before + ", actual size: " + after); } frame.dispose(); }
Example 7
Source Project: openjdk-jdk9 File: MaximizedNormalBoundsUndecoratedTest.java License: GNU General Public License v2.0 | 6 votes |
boolean doTest() { Dimension beforeMaximizeCalled = new Dimension(300,300); frame = new Frame("Test Frame"); frame.setUndecorated(true); frame.setFocusable(true); frame.setSize(beforeMaximizeCalled); frame.setVisible(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setExtendedState(Frame.NORMAL); Dimension afterMaximizedCalled= frame.getBounds().getSize(); frame.dispose(); if (beforeMaximizeCalled.equals(afterMaximizedCalled)) { return true; } return false; }
Example 8
Source Project: openjdk-8 File: TextAreaTwicePack.java License: GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) { final Frame frame = new Frame(); final TextArea ta = new TextArea(); frame.add(ta); frame.pack(); frame.setVisible(true); sleep(); final Dimension before = frame.getSize(); frame.pack(); final Dimension after = frame.getSize(); if (!after.equals(before)) { throw new RuntimeException( "Expected size: " + before + ", actual size: " + after); } frame.dispose(); }
Example 9
Source Project: netbeans File: CompletionLayoutPopup.java License: Apache License 2.0 | 5 votes |
/** * Create and display the popup at the given bounds. * * @param popupBounds location and size of the popup. * @param displayAboveCaret whether the popup is displayed above the anchor * bounds or below them (it does not be right above them). */ private void show(Rectangle popupBounds, boolean displayAboveCaret) { // Hide the original popup if exists if (popup != null) { popup.hide(); popup = null; } // Explicitly set the preferred size Dimension origPrefSize = getPreferredSize(); Dimension newPrefSize = popupBounds.getSize(); JComponent contComp = getContentComponent(); if (contComp == null){ return; } contComp.setPreferredSize(newPrefSize); showRetainedPreferredSize = newPrefSize.equals(origPrefSize); PopupFactory factory = PopupFactory.getSharedInstance(); // Lightweight completion popups don't work well on the Mac - trying // to click on its scrollbars etc. will cause the window to be hidden, // so force a heavyweight parent by passing in owner==null. (#96717) JTextComponent owner = getEditorComponent(); if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N owner = null; } // #76648: Autocomplete box is too close to text if(displayAboveCaret && Utilities.isMac()) { popupBounds.y -= 10; } popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y); popup.show(); this.popupBounds = popupBounds; this.displayAboveCaret = displayAboveCaret; }
Example 10
Source Project: jdk8u-jdk File: FullScreenInsets.java License: GNU General Public License v2.0 | 5 votes |
private static void testSize(final Dimension actual, final Dimension exp) { if (!exp.equals(actual)) { System.err.println(" Wrong window size:" + " Expected: " + exp + " Actual: " + actual); passed = false; } }
Example 11
Source Project: jdk8u60 File: FullScreenInsets.java License: GNU General Public License v2.0 | 5 votes |
private static void testSize(final Dimension actual, final Dimension exp) { if (!exp.equals(actual)) { System.err.println(" Wrong window size:" + " Expected: " + exp + " Actual: " + actual); passed = false; } }
Example 12
Source Project: netbeans File: NbPresenter.java License: Apache License 2.0 | 5 votes |
private void initBounds() { Window w = findFocusedWindow(); if( null != w ) { //#133235 - dialog windows should be centered on the main app window, not the whole screen setLocationRelativeTo( w ); Rectangle screen = Utilities.getUsableScreenBounds( w.getGraphicsConfiguration() ); Rectangle bounds = getBounds(); int dx = bounds.x; int dy = bounds.y; // bottom if (dy + bounds.height > screen.y + screen.height) { dy = screen.y + screen.height - bounds.height; } // top if (dy < screen.y) { dy = screen.y; } // right if (dx + bounds.width > screen.x + screen.width) { dx = screen.x + screen.width - bounds.width; } // left if (dx < screen.x) { dx = screen.x; } setLocation( dx, dy ); } else { //just center the dialog on the screen and let's hope it'll be //the correct one in multi-monitor setup Dimension size = getSize(); Rectangle centerBounds = Utilities.findCenterBounds(size); if(size.equals(centerBounds.getSize())) { setLocation(centerBounds.x, centerBounds.y); } else { setBounds(centerBounds); } } }
Example 13
Source Project: openjdk-8-source File: FullScreenInsets.java License: GNU General Public License v2.0 | 5 votes |
private static void testSize(final Dimension actual, final Dimension exp) { if (!exp.equals(actual)) { System.err.println(" Wrong window size:" + " Expected: " + exp + " Actual: " + actual); passed = false; } }
Example 14
Source Project: netbeans File: CompletionLayoutPopup.java License: Apache License 2.0 | 5 votes |
/** * Create and display the popup at the given bounds. * * @param popupBounds location and size of the popup. * @param displayAboveCaret whether the popup is displayed above the anchor * bounds or below them (it does not be right above them). */ private void show(Rectangle popupBounds, boolean displayAboveCaret) { // Hide the original popup if exists if (popup != null) { popup.hide(); popup = null; } // Explicitly set the preferred size Dimension origPrefSize = getPreferredSize(); Dimension newPrefSize = popupBounds.getSize(); JComponent contComp = getContentComponent(); if (contComp == null){ return; } contComp.setPreferredSize(newPrefSize); showRetainedPreferredSize = newPrefSize.equals(origPrefSize); PopupFactory factory = PopupFactory.getSharedInstance(); // Lightweight completion popups don't work well on the Mac - trying // to click on its scrollbars etc. will cause the window to be hidden, // so force a heavyweight parent by passing in owner==null. (#96717) JTextComponent owner = layout.getEditorComponent(); if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { owner = null; } // #76648: Autocomplete box is too close to text if(displayAboveCaret && Utilities.isMac()) { popupBounds.y -= 10; } popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y); popup.show(); this.popupBounds = popupBounds; this.displayAboveCaret = displayAboveCaret; }
Example 15
Source Project: rapidminer-studio File: ProcessRendererView.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * Update preferred size of this {@link JComponent} and updates the subprocess extension buttons * as well. */ private void updateComponentSize() { Dimension newSize = new Dimension((int) controller.getTotalWidth(), (int) controller.getTotalHeight()); updateExtensionButtons(); if (!newSize.equals(getPreferredSize())) { setPreferredSize(newSize); revalidate(); } }
Example 16
Source Project: dragonwell8_jdk File: SortItem.java License: GNU General Public License v2.0 | 4 votes |
/** * Paint the array of numbers as a list * of horizontal lines of varying lengths. */ @Override public void paint(Graphics g) { int a[] = arr; int y = 0; int deltaY = 0, deltaX = 0, evenY = 0; Dimension currentSize = getSize(); int currentHeight = currentSize.height; int currentWidth = currentSize.width; // Check to see if the applet has been resized since it // started running. If so, need the deltas to make sure // the applet is centered in its containing panel. // The evenX and evenY are because the high and low // watermarks are calculated from the top, but the rest // of the lines are calculated from the bottom, which // can lead to a discrepancy if the window is not an // even size. if (!currentSize.equals(initialSize)) { evenY = (currentHeight - initialSize.height) % 2; deltaY = (currentHeight - initialSize.height) / 2; deltaX = (currentWidth - initialSize.width) / 2; if (deltaY < 0) { deltaY = 0; evenY = 0; } if (deltaX < 0) { deltaX = 0; } } // Erase old lines g.setColor(getBackground()); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX + arr[i], y, currentWidth, y); } // Draw new lines g.setColor(Color.black); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX, y, deltaX + arr[i], y); } if (h1 >= 0) { g.setColor(Color.red); y = deltaY + evenY + h1 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } if (h2 >= 0) { g.setColor(Color.blue); y = deltaY + evenY + h2 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } }
Example 17
Source Project: TencentKona-8 File: SortItem.java License: GNU General Public License v2.0 | 4 votes |
/** * Paint the array of numbers as a list * of horizontal lines of varying lengths. */ @Override public void paint(Graphics g) { int a[] = arr; int y = 0; int deltaY = 0, deltaX = 0, evenY = 0; Dimension currentSize = getSize(); int currentHeight = currentSize.height; int currentWidth = currentSize.width; // Check to see if the applet has been resized since it // started running. If so, need the deltas to make sure // the applet is centered in its containing panel. // The evenX and evenY are because the high and low // watermarks are calculated from the top, but the rest // of the lines are calculated from the bottom, which // can lead to a discrepancy if the window is not an // even size. if (!currentSize.equals(initialSize)) { evenY = (currentHeight - initialSize.height) % 2; deltaY = (currentHeight - initialSize.height) / 2; deltaX = (currentWidth - initialSize.width) / 2; if (deltaY < 0) { deltaY = 0; evenY = 0; } if (deltaX < 0) { deltaX = 0; } } // Erase old lines g.setColor(getBackground()); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX + arr[i], y, currentWidth, y); } // Draw new lines g.setColor(Color.black); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX, y, deltaX + arr[i], y); } if (h1 >= 0) { g.setColor(Color.red); y = deltaY + evenY + h1 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } if (h2 >= 0) { g.setColor(Color.blue); y = deltaY + evenY + h2 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } }
Example 18
Source Project: jdk8u60 File: SortItem.java License: GNU General Public License v2.0 | 4 votes |
/** * Paint the array of numbers as a list * of horizontal lines of varying lengths. */ @Override public void paint(Graphics g) { int a[] = arr; int y = 0; int deltaY = 0, deltaX = 0, evenY = 0; Dimension currentSize = getSize(); int currentHeight = currentSize.height; int currentWidth = currentSize.width; // Check to see if the applet has been resized since it // started running. If so, need the deltas to make sure // the applet is centered in its containing panel. // The evenX and evenY are because the high and low // watermarks are calculated from the top, but the rest // of the lines are calculated from the bottom, which // can lead to a discrepancy if the window is not an // even size. if (!currentSize.equals(initialSize)) { evenY = (currentHeight - initialSize.height) % 2; deltaY = (currentHeight - initialSize.height) / 2; deltaX = (currentWidth - initialSize.width) / 2; if (deltaY < 0) { deltaY = 0; evenY = 0; } if (deltaX < 0) { deltaX = 0; } } // Erase old lines g.setColor(getBackground()); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX + arr[i], y, currentWidth, y); } // Draw new lines g.setColor(Color.black); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX, y, deltaX + arr[i], y); } if (h1 >= 0) { g.setColor(Color.red); y = deltaY + evenY + h1 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } if (h2 >= 0) { g.setColor(Color.blue); y = deltaY + evenY + h2 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } }
Example 19
Source Project: openjdk-jdk8u-backup File: SortItem.java License: GNU General Public License v2.0 | 4 votes |
/** * Paint the array of numbers as a list * of horizontal lines of varying lengths. */ @Override public void paint(Graphics g) { int a[] = arr; int y = 0; int deltaY = 0, deltaX = 0, evenY = 0; Dimension currentSize = getSize(); int currentHeight = currentSize.height; int currentWidth = currentSize.width; // Check to see if the applet has been resized since it // started running. If so, need the deltas to make sure // the applet is centered in its containing panel. // The evenX and evenY are because the high and low // watermarks are calculated from the top, but the rest // of the lines are calculated from the bottom, which // can lead to a discrepancy if the window is not an // even size. if (!currentSize.equals(initialSize)) { evenY = (currentHeight - initialSize.height) % 2; deltaY = (currentHeight - initialSize.height) / 2; deltaX = (currentWidth - initialSize.width) / 2; if (deltaY < 0) { deltaY = 0; evenY = 0; } if (deltaX < 0) { deltaX = 0; } } // Erase old lines g.setColor(getBackground()); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX + arr[i], y, currentWidth, y); } // Draw new lines g.setColor(Color.black); y = currentHeight - deltaY - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(deltaX, y, deltaX + arr[i], y); } if (h1 >= 0) { g.setColor(Color.red); y = deltaY + evenY + h1 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } if (h2 >= 0) { g.setColor(Color.blue); y = deltaY + evenY + h2 * 2 + 1; g.drawLine(deltaX, y, deltaX + initialSize.width, y); } }
Example 20
Source Project: NBANDROID-V2 File: SdksCustomizer.java License: Apache License 2.0 | 4 votes |
private void selectPlatform(Node pNode) { Component active = null; for (Component c : cards.getComponents()) { if (c.isVisible() && (c == jPanel1 || c == messageArea)) { active = c; break; } } final Dimension lastSize = active == null ? null : active.getSize(); this.clientArea.removeAll(); this.messageArea.removeAll(); this.removeButton.setEnabled(false); if (pNode == null) { ((CardLayout) cards.getLayout()).last(cards); return; } JComponent target = messageArea; JComponent owner = messageArea; selectedPlatform = pNode.getLookup().lookup(AndroidSdk.class); if (pNode != getExplorerManager().getRootContext()) { if (selectedPlatform != null) { mkDefault.setEnabled(!selectedPlatform.isDefaultSdk()); this.removeButton.setEnabled(!selectedPlatform.isDefaultSdk()); if (!selectedPlatform.getInstallFolders().isEmpty()) { this.platformName.setText(pNode.getDisplayName()); for (FileObject installFolder : selectedPlatform.getInstallFolders()) { File file = FileUtil.toFile(installFolder); if (file != null) { this.platformHome.setText(file.getAbsolutePath()); } } target = clientArea; owner = jPanel1; } } else { removeButton.setEnabled(false); mkDefault.setEnabled(false); } Component component = null; if (pNode.hasCustomizer()) { component = pNode.getCustomizer(); } if (component == null) { final PropertySheet sp = new PropertySheet(); sp.setNodes(new Node[]{pNode}); component = sp; } addComponent(target, component); } if (lastSize != null) { final Dimension newSize = owner.getPreferredSize(); final Dimension updatedSize = new Dimension( Math.max(lastSize.width, newSize.width), Math.max(lastSize.height, newSize.height)); if (!newSize.equals(updatedSize)) { owner.setPreferredSize(updatedSize); } } target.revalidate(); CardLayout cl = (CardLayout) cards.getLayout(); if (target == clientArea) { cl.first(cards); } else { cl.last(cards); } }