Tabnine Logo
Graphics.dispose
Code IndexAdd Tabnine to your IDE (free)

How to use
dispose
method
in
java.awt.Graphics

Best Java code snippets using java.awt.Graphics.dispose (Showing top 20 results out of 2,997)

Refine searchRefine arrow

  • Window.setVisible
  • JFrame.setDefaultCloseOperation
  • Container.add
  • JFrame.<init>
  • Window.pack
  • Dimension.<init>
  • Window.setLocationRelativeTo
origin: stackoverflow.com

return new Dimension(image.getWidth(), image.getHeight());
int y = fm.getHeight();
g2d.drawString(s, x, y);
g2d.dispose();
return img;
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new TextOverlay());
f.pack();
f.setVisible(true);
origin: stackoverflow.com

JScrollPane screenScroll = new JScrollPane(screenLabel);
screenScroll.setPreferredSize(new Dimension(
    (int)(screen.getWidth()/3),
    (int)(screen.getHeight()/3)));
panel.add(screenScroll, BorderLayout.CENTER);
panel.add(selectionLabel, BorderLayout.SOUTH);
    Point end = me.getPoint();
    captureRect = new Rectangle(start,
        new Dimension(end.x-start.x, end.y-start.y));
    repaint(screen, screenCopy);
    screenLabel.repaint();
  g.fill(captureRect);
g.dispose();
origin: stackoverflow.com

JFrame frame = new JFrame("Test");
frame.add(new JTable(new DefaultTableModel() {
  @Override
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
g.dispose();
origin: stackoverflow.com

  g2.drawOval(x, y, w, h);
g2.dispose();
return img;
  g2.drawLine(x1, y1, x2, y2);
g2.dispose();
return img;
return new Dimension(PREF_W, PREF_H);
JFrame frame = new JFrame("TestAlphaComposite");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new TestAlphaComposite());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
return new Dimension(200, 200);
g2d.dispose();
origin: stackoverflow.com

    JFrame frame = new JFrame();
    frame.setLayout(new GridLayout(N, N, N, N));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    for (int i = 0; i < N * N; i++) {
      frame.add(new RotatePanel());
    frame.pack();
    frame.setVisible(true);
this.setPreferredSize(new Dimension(
  image.getWidth(null), image.getHeight(null)));
this.addMouseListener(new MouseAdapter() {
return new Dimension(SIZE, SIZE);
g2d.drawLine(0, size / 2, size, size / 2);
g2d.drawLine(size / 2, 0, size / 2, size);
g2d.dispose();
return bi;
origin: stackoverflow.com

JFrame f = new JFrame("AnimationTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
timer.start();
super(true);
this.setOpaque(false);
this.setPreferredSize(new Dimension(WIDE, HIGH));
this.addMouseListener(new MouseHandler());
this.addComponentListener(new ComponentHandler());
  Dimension d = field.getPreferredSize();
  field.setBounds(e.getX(), e.getY(), d.width, d.height);
  add(field);
    g.drawLine(w / 2, h / 2, r.nextInt(w), r.nextInt(h));
  g.dispose();
  System.out.println("Resized to " + w + " x " + h);
origin: stackoverflow.com

g2d.dispose();
add(usrNameLabel, labCnst);
add(usrNameFeild, txtCnst);
add(passwordLabel, labCnst);
add(passFeild, txtCnst);
g2d.dispose();// disposing the graphics object 
g2d.dispose();
  g2d.dispose();
    JFrame frame = new JFrame("Demo: LogIn Dialogue");
    frame.setSize(new Dimension(500, 300)); 
    MainContainer container = new MainContainer();
    frame.add(new MainContainer());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
origin: stackoverflow.com

g2.fillRect(0, 0, ALTERED.getWidth(), 20);
g2.drawImage(ORIGINAL, 0, 20, null);
g2.dispose();
final JFrame frame = new JFrame("Image Manipulation Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setBackground(Color.BLUE.darker());
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(new JLabel(new ImageIcon(ORIGINAL)));
frame.getContentPane().add(new JLabel(new ImageIcon(ALTERED)));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
return new Dimension(200, 200);
g2d.drawString(text, x, y);
g2d.dispose();
origin: stackoverflow.com

JPanel p = new JPanel(new BorderLayout(4, 4));
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
halfScreenSize = new Dimension(d.width / 2, d.height / 2);
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() {
g2d.drawString("act free memory --->  " + ((int) Runtime.getRuntime().freeMemory()), 20, 410);
g2d.drawString("usage of memory --->  " + useMem, 20, 450);
g2d.dispose();
return bi;
origin: stackoverflow.com

final JFrame frame = new JFrame("Gradient JButton Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new FlowLayout());
frame.add(JGradientButton.newInstance());
frame.setSize(new Dimension(300, 150)); // used for demonstration
frame.setLocationRelativeTo(null);
frame.setVisible(true);
      Color.PINK.darker()));
  g2.fillRect(0, 0, getWidth(), getHeight());
  g2.dispose();
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
return new Dimension(200, 200);
g2d.draw(bounds);
g2d.dispose();
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new JScrollPane(new TestPane()));
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
Dimension size = new Dimension(200, 200);
if (img != null) {            
  size.width = Math.round(img.getWidth() * scale);
  at.scale(scale, scale);
  g2d.drawImage(img, at, this);
  g2d.dispose();
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
return new Dimension(200, 200);
g2d.drawString("Dog", x, y);
g2d.dispose();
origin: stackoverflow.com

g2d.setColor(Color.WHITE);
g2d.drawString("Loading image...", getWidth()/2 - 45, getHeight()/2 + 3 );
g2d.dispose();
  public void run() {
    final MyCanvas canvas = new MyCanvas();
    JFrame frame = new JFrame();
   frame.setSize(new Dimension(500, 500));
   frame.add(canvas);
   frame.setVisible(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
origin: stackoverflow.com

g2d.setBackground(Color.white);
g2d.clearRect(0, 0, BI_WIDTH, BI_HEIGHT);
g2d.dispose();
   g2.setBackground(Color.white);
   g2.clearRect(0, 0, BI_WIDTH, BI_HEIGHT);
   g2.dispose();
   imageLabel.repaint();
btnPanel.add(saveImageBtn);
btnPanel.add(clearImageBtn);
add(imageLabel, BorderLayout.CENTER);
add(btnPanel, BorderLayout.SOUTH);
  g2d.dispose();
JFrame frame = new JFrame("DrawAndSaveImage");
frame.getContentPane().add(new DrawAndSaveImage());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new GridLayout(1, 1));
panel.add(createComponent("Original", image));
panel.add(createComponent("Flipped", createFlipped(image)));
panel.add(createComponent("Rotated", createRotated(image)));
panel.add(createComponent("Inverted", createInverted(image)));
frame.getContentPane().add(panel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Graphics2D g = newImage.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
return newImage;
g.transform(at);
g.drawImage(image, 0, 0, null);
g.dispose();
return newImage;
origin: stackoverflow.com

g.dispose();
  drawNode(x,y,g);
g.dispose();
view.repaint();
JFrame frame = new JFrame();
int vertexes = 0;
int canvasSize = vertexes * vertexes;
frame.setSize(canvasSize, canvasSize);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(canvas.view);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new FadePane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
slider = new JSlider(0, 100);
setLayout(new BorderLayout());
add(slider, BorderLayout.SOUTH);
return new Dimension(200, 200);
g2d.setColor(startColor);
g2d.fillRect(0, 0, width, height);
g2d.dispose();
java.awtGraphicsdispose

Javadoc

Disposes of this graphics context and releases any system resources that it is using. A Graphics object cannot be used after disposehas been called.

When a Java program runs, a large number of Graphics objects can be created within a short time frame. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.

Graphics objects which are provided as arguments to the paint and update methods of components are automatically released by the system when those methods return. For efficiency, programmers should call dispose when finished using a Graphics object only if it was created directly from a component or another Graphics object.

Popular methods of Graphics

  • setColor
  • drawImage
    Draws as much of the specified image as is currently available. The image is drawn with its top-left
  • fillRect
    Fills the specified rectangle. The left and right edges of the rectangle are atx and x + width - 1.
  • drawLine
    Draws a line, using the current color, between the points(x1, y1) and (x2, y2) in this graphics con
  • drawString
    Draws the text given by the specified iterator, using this graphics context's current color. The ite
  • setFont
    Sets this graphics context's font to the specified font. All subsequent text operations using this g
  • drawRect
    Draws the outline of the specified rectangle. The left and right edges of the rectangle are atx and
  • getFontMetrics
  • create
    Creates a new Graphics object based on thisGraphics object, but with a new translation and clip area
  • getColor
    Gets this graphics context's current color.
  • translate
    Translates the origin of the graphics context to the point (x,y) in the current coordinate system. M
  • getClipBounds
    Returns the bounding rectangle of the current clipping area. The coordinates in the rectangle are re
  • translate,
  • getClipBounds,
  • setClip,
  • getFont,
  • fillPolygon,
  • fillOval,
  • drawOval,
  • getClip,
  • drawRoundRect

Popular in Java

  • Reactive rest calls using spring rest template
  • putExtra (Intent)
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now