enum Color { BLACK, WHITE }; Color nothing = null; if (nothing == Color.BLACK); // runs fine if (nothing.equals(Color.BLACK)); // throws NullPointerException
@Override public void setCursorPosition (int x, int y) { if (robot != null) { robot.mouseMove(canvas.getLocationOnScreen().x + x, canvas.getLocationOnScreen().y + y); } }
public SettingsGroup(String title) { setBorder(BorderFactory.createTitledBorder(title)); setLayout(new GridBagLayout()); c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.weighty = 1.0; }
@Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); try { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); super.paint(g2d); } finally { g2d.dispose(); } } }
protected void setFontSize(Component component, int fontSize) { Font oldFont = component.getFont(); Font newFont = new Font(oldFont.getFontName(), oldFont.getStyle(), fontSize); component.setFont(newFont); }
@Override public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) { return new Color(0); } }
public Node (int x, int y, int width, int height, Node leftChild, Node rightChild, String leaveName) { this.rect = new Rectangle(x, y, width, height); this.leftChild = leftChild; this.rightChild = rightChild; this.leaveName = leaveName; }
public static DisplayMode getDesktopDisplayMode () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode mode = device.getDisplayMode(); return new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()); }
private void applyRenderHints(Graphics g) { if (g instanceof Graphics2D) { Graphics2D g2d = (Graphics2D) g; if (DESKTOP_HINTS != null) { g2d.setRenderingHints(DESKTOP_HINTS); } else { g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); } } }
Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y;
public void setLocationAndPosition() { if (this.settings.loadWindowPos(this)) { return; } GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); DisplayMode mode = gd.getDisplayMode(); int w = mode.getWidth(); int h = mode.getHeight(); setLocation((int) (w * BORDER_RATIO), (int) (h * BORDER_RATIO)); setSize((int) (w * WINDOW_RATIO), (int) (h * WINDOW_RATIO)); }
public static void registerBundledFonts() { GraphicsEnvironment grEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (Utils.FONT_HACK != null) { grEnv.registerFont(Utils.FONT_HACK); } }
public <K> K getCurrentCard(Container container){ Component c[] = container.getComponents(); int i = 0; int j = c.length; while (i < j) { if (c[i].isVisible()) { return (K)c[i]; } else i ++; } return null; }
void log (final String text) { EventQueue.invokeLater(new Runnable() { public void run () { ui.textArea.append(text + "\n"); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } }); }
public Node (int x, int y, int width, int height, Node leftChild, Node rightChild, String leaveName) { this.rect = new Rectangle(x, y, width, height); this.leftChild = leftChild; this.rightChild = rightChild; this.leaveName = leaveName; }
public static DisplayMode getDesktopDisplayMode () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode mode = device.getDisplayMode(); return new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()); }
public <K> K getCurrentCard(Container container){ Component c[] = container.getComponents(); int i = 0; int j = c.length; while (i < j) { if (c[i].isVisible()) { return (K)c[i]; } else i ++; } return null; }
@Override public void setCursorPosition (int x, int y) { if (robot != null) { robot.mouseMove(canvas.getLocationOnScreen().x + x, canvas.getLocationOnScreen().y + y); } }