javax.swing.JFrame.paint()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中javax.swing.JFrame.paint()方法的一些代码示例,展示了JFrame.paint()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.paint()方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:paint

JFrame.paint介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

/**
 * Use this method to create a screenshot of the JFrame object argFrame.
 *
 * Author(s):
 *   Dejan Lekic
 * License: 
 *   Public Domain
 *
 * @param argFrame JFrame you want to make screenshot of.
 */
public static final void makeScreenshot(JFrame argFrame) {
  Rectangle rec = argFrame.getBounds();
  BufferedImage bufferedImage = new BufferedImage(rec.width, rec.height,
      BufferedImage.TYPE_INT_ARGB);
  argFrame.paint(bufferedImage.getGraphics());

  try {
    // Create temp file.
    File temp = File.createTempFile("screenshot", ".png");

    // Use the ImageIO API to write the bufferedImage to a temporary file
    ImageIO.write(bufferedImage, "png", temp);

    // Delete temp file when program exits.
    temp.deleteOnExit();
  } catch (IOException ioe) {
    LOGGER.debug(ioe.toString());
  } // catch
} // makeScreenshot method

代码示例来源:origin: opensourceBIM/BIMserver

@Override
  public void paint(Graphics g) {
    super.paint(g);
    g.drawImage(bufferedImage, 0, 0, this);
  }
}

代码示例来源:origin: de.sciss/jacop

/**paints all objects, repaint only if requested to*/
public void paint(Graphics g) {
  super.paint(g);
  g.drawImage(displayImgae, 0, 0, null);
}

代码示例来源:origin: net.sf.jcgrid/jcgrid

public void paint(Graphics g) {
    super.paint(g);

    g.drawImage(renderingFrameBuffer,0,0,Color.BLACK,null);
  }
}

代码示例来源:origin: radsz/jacop

/**
 * paints all objects, repaint only if requested to
 */
public void paint(Graphics g) {
  super.paint(g);
  g.drawImage(displayImgae, 0, 0, null);
}

代码示例来源:origin: javalite/jar-explorer

/**
 * Overridden in order to cause a split panel resize when window shows initially
 *
 * @param g Graphic context passed from JVM
 */
@Override
public void paint(Graphics g) {
  super.paint(g);
  if (!init) {
    mainSp.setDividerLocation(0.5);
    //subSplitPane.setDividerLocation(0.75);
    init = true;
  }
}

代码示例来源:origin: klamonte/jexer

/**
 * Paints this component.
 *
 * @param g the graphics context to use for painting
 */
public void paint(Graphics g) {
  if (frame != null) {
    frame.paint(g);
  } else {
    component.paint(g);
  }
}

代码示例来源:origin: floetteroed.utilities/floetteroed-utilities

public void run() {
    vizFrame.paint(vizFrame.getGraphics());
  }
});

代码示例来源:origin: stackoverflow.com

public static void main(String[] a) throws Exception {

  final JFrame frame = new JFrame("My Frame");
  frame.getContentPane().setBackground(Color.CYAN);
  frame.setSize(400, 400);
  frame.setVisible(true);

  final BufferedImage image = new BufferedImage(frame.getWidth(),
      frame.getHeight(), BufferedImage.TYPE_INT_ARGB);
  frame.paint(image.getGraphics());
  File outputfile = new File("C:/Temp/frame.png");
  ImageIO.write(image, "png", outputfile);
}

代码示例来源:origin: stackoverflow.com

public static final void makeScreenshot(JFrame f) {
  Rectangle rec = f.getBounds();
  BufferedImage bufferedImage = new BufferedImage(rec.width, rec.height,
      BufferedImage.TYPE_INT_ARGB);
  f.paint(bufferedImage.getGraphics());

  try {
    // Create temp file
    File temp = File.createTempFile("screenshot", ".png");

    ImageIO.write(bufferedImage, "png", temp);

    // Delete temp file on exit
    temp.deleteOnExit();
  } catch (IOException ioe) {
    LOGGER.debug(ioe.toString());
  } 
}

代码示例来源:origin: stackoverflow.com

public static BufferedImage getFrameImage(JFrame argFrame){
  int w = argFrame.getWidth();
  int h = argFrame.getHeight();
  BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
  Graphics2D g = bi.createGraphics();
  g.setColor(Color.white);
  g.fillRect(0, 0, w, h);
  argFrame.paint(g);
  paint(g);
  return bi;
}

代码示例来源:origin: stackoverflow.com

JFrame f = frameA; // or frameB
BufferedImage bi = new BufferedImage(f.getWidth(), f.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
f.paint(g);
g.dispose();
lab.setIcon(new IconImage(bi));

代码示例来源:origin: stackoverflow.com

public class TestPanel1 {
  JPanel panel1;
  JButton next;

  public TestPanel1(final JFrame frame, TestPanel2 tp2) { // was: JPanel panel1() {
    panel1 = new JPanel();
    next = new JButton("Next");
    final JPanel panel2 = tp2.panel2; // line created
    next.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        panel2.removeAll(); // was: new TestPanel2().panel2.removeAll();
        frame.validate(); // line created
        frame.paint(); // line created
      }
    });
    panel1.add(next);
             // was: return panel1;
  }
}

代码示例来源:origin: stackoverflow.com

BufferedImage img = new BufferedImage (size.width, size.height, BufferedImage.TYPE_3BYTE_BGR);
Graphics g = img.getGraphics ();
frame.paint (g);
g.dispose ();
try

代码示例来源:origin: org.tentackle/tentackle-swing

/**
 * {@inheritDoc}
 * <p>
 * Overridden in order to bring modal windows
 * to front in case accidently covered by another window.
 * This is the case whenever a modal dialog is not owned
 * by the window covering it.
 * It solves the problem of "freezing" an application because
 * the user clicked on another window.
 */
@Override
public void paint(Graphics g) {
 super.paint(g);
 FormUtilities.getInstance().modalToFront();
}

代码示例来源:origin: io.ultreia.gc/gc-doom

@Override
public void paint(Graphics g) {
  super.paint(g);
  Rectangle zone = this.zone;
  if (zone == null) {
    return;
  }
  int x = (int) zone.getX();
  int y = (int) zone.getY();
  int width = (int) zone.getWidth();
  int height = (int) zone.getHeight();
  int xprime = x + width;
  int yprime = y + height;
  log.debug(String.format("Detected zone: x: %d, y: %d, w: %d, h: %d", x, y, width, height));
  g.setColor(new Color(0, 0, 0, 0));
  g.clearRect(x, y, getWidth(), getHeight());
  g.setColor(new Color(255, 0, 0, 55));
  g.drawLine(x, y, xprime, y);
  g.drawLine(x, y, x, yprime);
  g.drawLine(xprime, y, xprime, yprime);
  g.drawLine(x, yprime, xprime, yprime);
}

代码示例来源:origin: Killerardvark/CryodexSource

@Override
public void paint(Graphics g) {
  super.paint(g);
  
  Font labelFont = getBigClockLabel().getFont();
  String labelText = getBigClockLabel().getText();
  int stringWidth = getBigClockLabel().getFontMetrics(labelFont).stringWidth(labelText);
  int componentWidth = getBigClockLabel().getWidth();
  // Find out how much the font can grow in width.
  double widthRatio = (double)componentWidth / (double)stringWidth;
  int newFontSize = (int)(labelFont.getSize() * widthRatio);
  int componentHeight = getBigClockLabel().getHeight();
  // Pick a new font size so it will not be larger than the height of label.
  int fontSizeToUse = Math.min(newFontSize, componentHeight)-2;
  // Set the label's font size to the newly determined size.
  getBigClockLabel().setFont(new Font(labelFont.getName(), Font.PLAIN, fontSizeToUse));
}

代码示例来源:origin: stackoverflow.com

frame.paint(g2);
return Printable.PAGE_EXISTS;

代码示例来源:origin: ArlindNocaj/power-voronoi-diagram

@Override
public void paint(Graphics g2) {
  super.paint(g2);

代码示例来源:origin: geogebra/geogebra

@Override
public void paint(Graphics g) {
  super.paint(g);
  Graphics2D g2 = (Graphics2D) g;
  Graphics2DD g2d = new Graphics2DD(g2);
  String[] texts = {
      "\\text{AVAVAVAVAVA}",
      "\\text{AV\\bgcolor{red}{AVAVA}VAVA}",
      "\\text{ffs}",
      "\\text{A\\bgcolor{RED}{ff}f\\bgcolor{blue}{f}"
  };
  int y = 100;
  for (String text : texts) {
    TeXFormula formula = new TeXFormula(text);
    Image im = formula.createBufferedImage(TeXConstants.STYLE_DISPLAY,
        30, ColorUtil.BLACK, ColorUtil.WHITE);
    g2d.drawImage(im, 100, y);
    y += im.getHeight() + 10;
  }
}

相关文章

JFrame类方法