frameGraphics = frame.getGraphics();
public static void main (String[]args) { JFrame frame= new JFrame (); frame.setSize(400, 400); Graphics g = frame.getGraphics(); drawShape(g); frame.setVisible(true); }
JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.add(panel); frame.setVisible(true); Graphics frameContext = frame.getGraphics(); Graphics panelContext = panel.getGraphics(); if (frameContext.equals(panelContext)){ System.out.println("The contexts are the same."); } else { System.out.println("The contexts are different."); }
public void run() { if (window != null) { if (window instanceof JFrame) { JFrame frame = (JFrame) window; frame.update(frame.getGraphics()); } } } });
public void run() { vizFrame.paint(vizFrame.getGraphics()); } });
/** * Creates a graphics context for this component. This method will return * null if this component is currently not displayable. * * @return a graphics context for this component, or null if it has none */ public Graphics getGraphics() { if (frame != null) { return frame.getGraphics(); } else { return component.getGraphics(); } }
public void updateProteinProcessedCound( final int newCount ) { if ( progressBar == null ) { throw new NullPointerException( "The progress bar hasn't been created." ); } // update current element current = newCount; currentLabel.setText( "Current: " + current ); currentLabel.update( frame.getGraphics() ); // update the progress bar progressBar.setValue( current ); frame.setTitle( getWindowsTitle() ); }
public void updateProteinProcessedCound( final int newCount ) { if ( progressBar == null ) { throw new NullPointerException( "The progress bar hasn't been created." ); } // update current element current = newCount; currentLabel.setText( "Current: " + current ); currentLabel.update( frame.getGraphics() ); // update the progress bar progressBar.setValue( current ); frame.setTitle( getWindowsTitle() ); }
public void updateProteinProcessedCound( final int newCount ) { if ( progressBar == null ) { throw new NullPointerException( "The progress bar hasn't been created." ); } // update current element current = newCount; currentLabel.setText( "Current: " + current ); currentLabel.update( frame.getGraphics() ); // update the progress bar progressBar.setValue( current ); frame.setTitle( getWindowsTitle() ); }
public void setStatus( final String status ) { // update status statusLabel.setText( status ); statusLabel.update( frame.getGraphics() ); frame.setTitle( getWindowsTitle() ); }
public void setStatus( final String status ) { // update status statusLabel.setText( status ); statusLabel.update( frame.getGraphics() ); frame.setTitle( getWindowsTitle() ); }
public void setStatus( final String status ) { // update status statusLabel.setText( status ); statusLabel.update( frame.getGraphics() ); frame.setTitle( getWindowsTitle() ); }
JFrame workingManager = new JFrame("Hello"); Graphics g = workingManager.getGraphics(); JPanel jp = (JPanel) workingManager.getContentPane(); workingManager.paintComponents(g); g.fillOval(0, 0, 30, 30); g.drawOval(0, 50, 30, 30); g.setColor(Color.CYAN); workingManager.setSize(500, 500); workingManager.setVisible(true);
setDefaultCloseOperation(3); setVisible(true); timer(getGraphics()); //call the timer from here, so there's only one running
@Override public void actionPerformed(ActionEvent e) { drawARectangle(frame.getGraphics());
printAll(getGraphics());//Extort print all content
public void mouseClicked(MouseEvent e) { paintStuff(frame.getGraphics(),e.getX(), e.getY()); public void mouseEntered(MouseEvent e) { PaintRectangleAtPoint(frame.getGraphics(),100, e.getY(), "entered");
import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; public class Polygon extends JFrame { public static void main(String args[]){ Test a = new Test(); a.drawAPolygon(); } public Polygon(){ setSize(300,300); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } void drawAPolygon(int[] xPoints, int[] yPoints, int numPoints){ Graphics g = getGraphics(); g.drawPolygon(xPoints, yPoints, numPoints); } //@override public void paint(Graphics g){ super.paint(g); //could also do painting in here. } }
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setVisible(true); Graphics2D g = (Graphics2D) frame.getGraphics(); for (int i = 0; i < 3000; i++) { char c = (char) i; TextLayoutD ld = new TextLayoutD(c + "", frame.getFont(), g.getFontRenderContext()); System.out.println(i + " (" + c + ") : " + ld.getBounds().getY() / ld.getBounds().getHeight()); } } }
splashFrame.setVisible(true); splashFrame.setAlwaysOnTop(false); splashFrame.update(splashFrame.getGraphics());