Refine search
frame.add(tip1Null, BorderLayout.CENTER); frame.setLocation(150, 150); frame.setPreferredSize(new Dimension(310, 75)); frame.setLocationRelativeTo(null); frame.pack(); ((Graphics2D) g).setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(color); g.drawRoundRect(x, y, width, height, MARGIN, MARGIN); final Color color1 = new Color(230, 255, 255, 0); final Color color2 = new Color(255, 230, 255, 64); final Color alphaColor = new Color(200, 200, 230, 64); super.paint(g, c); Graphics2D g2D = (Graphics2D) g; GradientPaint gradient1 = new GradientPaint( g2D.setPaint(gradient1); g2D.fill(rec1); GradientPaint gradient2 = new GradientPaint( public void paintButtonPressed(Graphics g, AbstractButton b) { paintText(g, b, b.getBounds(), b.getText()); g.setColor(Color.red.brighter());
protected Paint createPaint(Polygon polygon) { if (fillPaint instanceof GradientPaint) { GradientPaint gradientPaint = (GradientPaint)fillPaint; Point2D point1 = new Point(0, getLowestY(polygon)); Point2D point2 = new Point(0, getHeight()); return new GradientPaint(point1, gradientPaint.getColor1(), point2, gradientPaint.getColor2(), false); } else { return fillPaint; } }
private void redrawGradient() { Color primaryRight = Color.getHSBColor(1f - this.selectedY / (float) (size - 1), 1, 1); Graphics2D g = image.createGraphics(); GradientPaint primary = new GradientPaint( 0f, 0f, Color.WHITE, size - 1, 0f, primaryRight); GradientPaint shade = new GradientPaint( 0f, 0f, new Color(0, 0, 0, 0), 0f, size - 1, Color.BLACK); g.setPaint(primary); g.fillRect(0, 0, size, size); g.setPaint(shade); g.fillRect(0, 0, size, size); g.dispose(); forceRedraw = true; }
BufferedImage.TYPE_INT_RGB); Graphics2D imageGraphics = image.createGraphics(); GradientPaint gp = new GradientPaint( 20f, 20f, 280f, Color.orange); imageGraphics.setPaint(gp); imageGraphics.fillRect(0, 0, 400, 300); textLabel.setSize(textLabel.getPreferredSize()); Dimension d = textLabel.getPreferredSize(); BufferedImage bi = new BufferedImage( d.width, JLabel imageLabel = new JLabel(ii); f.getContentPane().add(imageLabel); f.pack(); f.setLocationByPlatform(true); f.setVisible(true);
new Color(203, 203, 197), new Color(192, 142, 60) }; static final int WHITE = 0, BLACK = 1; g.setColor(pieceColors[side]); Color baseColor = pieceColors[side]; if (gradient) { Color c1 = baseColor.brighter(); Color c2 = baseColor; GradientPaint gp = new GradientPaint( sz/2-(r.width/4), sz/2-(r.height/4), c1, sz/2+(r.width/4), sz/2+(r.height/4), c2, g.setColor(baseColor); g.setColor(outlineColor); new ImageIcon(getImageForChessPiece(piece, side, gradient)), JLabel.CENTER); l.setBackground(bg); l.setOpaque(true); c.add(l); Color bg = (initialSquareColor++ % 2 == BLACK ? Color.BLACK : Color.WHITE); l.setBackground(bg); l.setOpaque(true); c.add(l);
public final static Color BUTTON_TOP_GRADIENT = new Color(176, 176, 176); public final static Color BUTTON_BOTTOM_GRADIENT = new Color(156, 156, 156); Graphics2D g2 = (Graphics2D)g.create(); RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHints(qualityHints); g2.setPaint(new GradientPaint(new Point(0, 0), BUTTON_TOP_GRADIENT, new Point(0, getHeight()), BUTTON_BOTTOM_GRADIENT)); g2.fillRoundRect(0, 0, getWidth(), getHeight(), 20, 20); g2.dispose(); JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new ControlButton("Hello, World")); frame.pack(); frame.setVisible(true);
imageLabel = new JLabel(new ImageIcon(convertToFromBytes(getImage()))); memory = new JProgressBar(0, (int) Runtime.getRuntime().maxMemory()); p.add(imageLabel, BorderLayout.CENTER); p.add(memory, BorderLayout.SOUTH); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(p); f.setLocation(150, 150); f.pack(); f.setVisible(true); Runnable r = new Runnable() { GradientPaint gp = new GradientPaint(0f, 0f, new Color(127 + random.nextInt(128), 127 + random.nextInt(128), 127 + random.nextInt(128)), (float) halfScreenSize.width, (float) halfScreenSize.width, new Color(random.nextInt(128), random.nextInt(128), random.nextInt(128))); BufferedImage bi = new BufferedImage(halfScreenSize.width, halfScreenSize.height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = bi.createGraphics(); g2d.setPaint(gp); g2d.fillRect(0, 0, halfScreenSize.width, halfScreenSize.height); g2d.setFont(bigFont); g2d.setColor(Color.BLACK); if (maxMem < ((int) Runtime.getRuntime().freeMemory())) { maxMem = ((int) Runtime.getRuntime().freeMemory()); g2d.drawString("" + ++count, 20, 100); g2d.drawString("JVM memory status ---> ", 20, 195); g2d.drawString("tot. memory ---> " + ((int) Runtime.getRuntime().totalMemory()), 20, 240); g2d.drawString("max. memory ---> " + ((int) Runtime.getRuntime().maxMemory()), 20, 270);
JFrame frame = new JFrame("BottomBar"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JPanel() { frame.add(new BottomBar(), BorderLayout.SOUTH); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint gradient = new GradientPaint( 0, 0, new Color(185, 185, 185), 0, getHeight(), new Color(151, 151, 151)); g2.setPaint(gradient); g2.fillRect(0, 0, getWidth(), getHeight()); g2.setColor(new Color(64, 64, 64)); g2.drawLine(0, 0, getWidth(), 0); g2.setColor(new Color(215, 215, 215)); g2.drawLine(0, 1, getWidth(), 1);
JFrame frame = new JFrame("A Little Something"); JLayer<JComponent> aLittleSomething = new JLayer<>(new ALittleSomethingPanel(), new ALittleSomethingUI()); frame.getContentPane().add(aLittleSomething); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(800, 450)); frame.setLocationRelativeTo(null); // Center frame.pack(); frame.setVisible(true); add(aLittleSomethingLabel); aLittleSomethingLabel.setFont(aLittleSomethingLabel.getFont().deriveFont(42f)); Graphics2D g2 = (Graphics2D) g.create(); super.paint(g2, c); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); int height = c.getHeight(); int width = c.getWidth(); g2.setPaint(new GradientPaint(15, 0, new Color(90, 97, 105), 15, 30, new Color(132, 142, 152))); g2.setStroke(new BasicStroke(5)); g2.draw(circle); g2.dispose();
@Override protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(thumbBounds.x + 1, thumbBounds.y + 2); g2.setColor(Color.BLACK); Paint paint = g2.getPaint(); g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); g2.fill(casing); g2.setPaint(paint); Paint paint = g2.getPaint(); g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); g2.fill(casing); g2.setPaint(paint);
gradientHeight = height - 16; g.translate(gradientX, gradientY); for (int i = 0, n = colors.size() == 1 ? 1 : colors.size() - 1; i < n; i++) { Color color1 = colors.get(i); int point1 = (int)(percent1 * gradientWidth); int point2 = (int)Math.ceil(percent2 * gradientWidth); g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false)); g.fillRect(point1, 0, point2 - point1, gradientHeight); g.setPaint(null);
private static final Color gradientEndingColor = new Color(0xc0c0c0); private static final Color borderColor = new Color(0x736a60); private static final Color disabledBorderColor = new Color(0xbebebe); update(getGraphics()); int w = displayWidth != 0 ? displayWidth - 1 : getWidth() - 1; int h = displayHeight != 0 ? displayHeight - 1 : getHeight() - 1; gradient = new GradientPaint(0.0f, 0.0f, Color.WHITE, 0.0f, h, gradientEndingColor); if (isOpaque()) { g2d.setColor(getBackground()); g2d.fillRect(0, 0, getWidth(), getHeight()); g2d.translate(x, y); FontMetrics fm = g.getFontMetrics(); int stringW = 0; int stringH = 0; stringH = ((h - fm.getHeight()) / 2) + fm.getAscent(); g2d.drawString(DISABLED_PERCENT_STRING, w - stringW, stringH);
sp3.setViewportView(jTable3); JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayout(3, 0, 10, 10)); panel1.add(sp1); panel1.add(sp2); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); Color background = new Color(168, 210, 241); Color controlColor = new Color(230, 240, 230); Graphics2D g2 = (Graphics2D) g; Paint oldPaint = g2.getPaint(); g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor)); g2.fillRect(0, 0, width, height); g2.setPaint(oldPaint); for (int row : getSelectedRows()) { Rectangle start = getCellRect(row, 0, true); Rectangle end = getCellRect(row, getColumnCount() - 1, true); g2.setPaint(new GradientPaint(start.x, 0, controlColor, (int) ((end.x + end.width - start.x) * 1.25), 0, Color.orange)); g2.fillRect(start.x, start.y, end.x + end.width - start.x, start.height);
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { final UPolygon shape = (UPolygon) ushape; g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness())); paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr.getColor2())); } else if (policy == '\\') { paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2())); } else if (policy == '-') { paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()), mapper.getMappedColor(gr.getColor2())); } else { paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr .getColor2())); g2d.setPaint(paint); g2d.fill(path); } else if (back!=null) { g2d.setColor(mapper.getMappedColor(back));
window.setLocationByPlatform(true); window.setVisible(true); private Color pInterfaceColour = new Color(255, 245, 62); protected int iDegreeWhite = 180; protected int iDegreeBlack = 0; setSize(iWidth, iHeight); pGraphicsGradientRender.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint pGradient = new GradientPaint(0, 0, new Color(255, 255, 255, iDegreeWhite), 0, getHeight(), new Color(0, 0, 0, iDegreeBlack)); pGraphicsGradientRender.setPaint(pGradient); pGraphicsGradientRender.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(pGraphics); pGradientPane.setPreferredSize(new Dimension(iWidth - 16, iHeight - 62)); add(pGradientPane);
int h = getHeight(); Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); g2.setColor( border ); g2.fillOval( 0, 0, w, h ); g2.setPaint( new GradientPaint( 0, 0, top, 0, h-borderSize, bottom ) ); g2.fillOval( borderSize, borderSize, w-2*borderSize, h-2*borderSize ); g2.setPaint( new GradientPaint( 0, 0, new Color( 150, 150, 150 ), 0, h/2, Color.WHITE )); g2.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_ATOP, 0.4f ) );
gui.add(quality, BorderLayout.WEST); dithering = new JCheckBox("Dithering", false); controls.add(antialiasing); controls.add(fractionalMetrics); GradientPaint gp = new GradientPaint( 0f, 0f, Color.red, (float)width, (float)height, Color.orange); g2d.setPaint(gp); g2d.fillRect(0,0, width, height); g2d.setColor(Color.blue); for (int ii=0; ii<width; ii+=10) { g2d.drawLine(ii, 0, ii, height); g2d.setColor(Color.green); g2dText.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { g2dText.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
xp = new int[]{x, x, x + w, x + w, x}; yp = new int[]{y, y + h - 3, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, Color.ORANGE); break; case RIGHT: xp = new int[]{x, x, x + w - 2, x + w - 2, x}; yp = new int[]{y, y + h - 3, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, new Color(153, 186, 243)); break; case BOTTOM: xp = new int[]{x, x, x + 3, x + w - inclTab - 6, x + w - inclTab - 2, x + w - inclTab, x + w - 3, x}; yp = new int[]{y, y + h - 3, y + h, y + h, y + h - 1, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, Color.BLUE); break; case TOP: xp = new int[]{x, x, x + 3, x + w - inclTab - 6, x + w - inclTab - 2, x + w - inclTab, x + w - inclTab, x}; yp = new int[]{y + h, y + 3, y, y, y + 1, y + 3, y + h, y + h}; gradientShadow = new GradientPaint(0, 0, Color.ORANGE, 0, y + h / 2, new Color(240, 255, 210)); break; GradientPaint gradientShadowTmp = new GradientPaint(0, 0, new Color(255, 255, 200), 0, y + h / 2, new Color(240, 255, 210)); g2D.setPaint(gradientShadowTmp); } else { GradientPaint gradientShadowTmp = new GradientPaint(0, 0, new Color(240, 255, 210), 0, y + 15 + h / 2, new Color(204, 204, 204)); g2D.setPaint(gradientShadowTmp);
protected void paintComponent(Graphics g) Graphics2D g2 = (Graphics2D)g.create(); Paint p = new GradientPaint( 0, 0, new Color(200,180,180,200), //Select RGB and Alpha values getWidth(), 0, new Color(0,0,0,0) ); g2.setPaint(p); g2.fillRect(0, 0, getWidth(), getHeight()); g2.dispose(); jf.add(new JPanel()); GlassFrame g = new GlassFrame(); jf.setSize(300,300); jf.setVisible(true);
protected void paintComponent (Graphics graphics) { Graphics2D g = (Graphics2D)graphics; int width = getWidth() - 1; int height = getHeight() - 1; for (int i = 0, n = paletteColors.length - 1; i < n; i++) { Color color1 = paletteColors[i]; Color color2 = paletteColors[i + 1]; float point1 = i / (float)n * width; float point2 = (i + 1) / (float)n * width; g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false)); g.fillRect((int)point1, 0, (int)Math.ceil(point2 - point1), height); } g.setPaint(null); g.setColor(Color.black); g.drawRect(0, 0, width, height); } }