You can not make a canvas flicker while recycling just outside of intellectual interest.
Expands public class flickr avat canvas {public static zero main (string [] args) {frame F = new frame (str); // This line does not change anything / JFrame f = new gefram (str); F.add (new flickr (ftc); f.pack (); int framewidth = f.getWidth (); int frameshite = f.getHeight (); dimension screenshot = toolkit.get defaulttoolkit (). GetScreenSize (); F .setLocation (Screensized width / 2 - framewidth / 2, screen size.heath / 2 - frameshit / 2); f.setVisible (true); F.addWindowListener (new window adapter) {Public Zero Window Closure (WindowEnd E) {System.exit (0);} public holiday window expired (windowEd E) {} public Zero Window Displayed (and Personalized color content color; font f = new font ("Georgia", font. BA, 16); Stable string str = "AWT canvas resizing flickering"; public flickr () (Random) = Random (); BG color = new color (RNXIt (256), R. NXtint (256), RNXInt (256); Contentcolor = new color (r.nextInt (256) , R.nextInt (256), r.nextInt (256));} Public dimension getPreferredSize () {font matrix FM = matching-font matrix (F); New Dimensions Return (fm.stringWidth (str) + 20, fm.getHeight () + 10); } Public Zero Color (Java.A.T. Graphics G) {G. Seat color (bg color); G.fillRect (0, 0, getWidth (), getHeight ()); G.setColor (contentColor); G.setFont (f); Fontmatrix fm = g.getfontmetrics (f); Int dx = getWidth () / 2 - (fm.stringWidth (str) / 2); Int dy = getHeight () / 2 + (fm.getHeight () / 2); G.drawString (str, dx, dy); }} You can copy paste in java editor and run example.
You can add it to the beginning of your main method to avoid background flicker:
System.setProperty ("sun.awt.noerasebackground", "true");
Comments
Post a Comment