[ ban17 @ 15.05.2007. 17:44 ] @
Da li neko zna kako mogu da napravim kod za SplashScreen koji ce na progress bar-u pokazivati koliko procenata aplikacije se ucitalo kao i sta se trenutno ucitava????
[ ermones @ 16.05.2007. 07:57 ] @
Ako radis sa jse 6 to je lako.
1. u manifest.mf dodaj SplashScreen-Image: path/imeSplashScreenSlike
2. u main metodi kad napravis main frame dodaj: SplashUtil.createSplash();
3. napravi clasu SplashUtil

public class SplashUtil {
public static void renderSplashFrame(Graphics2D g, int frame) {
final int XPOS=40;
final int YPOS=290;
final int WIDTH=500;
final int HEIGHT=7;
final Color barColor = new Color(120, 240, 220);
final String[] comps = {"foo", "bar", "baz"};
g.setComposite(AlphaComposite.Clear);
g.fillRect(XPOS, YPOS, WIDTH, 40);
g.setPaintMode();
g.setColor(Color.YELLOW);
g.drawString("Loading " + comps[(frame/5)%3] + "...", XPOS, YPOS + 10);
g.setColor(barColor);
g.fill3DRect(XPOS, YPOS + 20, (frame*10)%WIDTH, HEIGHT, true);
}

public static void createSplash() {
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash == null) {
System.out.println("SplashScreen.getSplashScreen() returned null");
return;
}
Graphics2D g = (Graphics2D)splash.createGraphics();
if (g == null) {
System.out.println("g is null");
return;
}
for(int i=0; i<100; i++) {
renderSplashFrame(g, i);
splash.update();
try {
Thread.sleep(10);
} catch(InterruptedException e) {
}
}
splash.close();
}
}
[ ban17 @ 16.05.2007. 10:39 ] @
Hvala za odgovor , ali zaboravio sam da kazem da mi je potreban kod koji ce raditi i u javi 5 (po mogucstvu i 1.4 ali java 5 obavezno).