It is commandable to do this research, but...
Splashes are annoying. So is it worth replacing one annoyance
with another?
It was noticed earlier that there may be an issue with accessing
AWT from main thread.
So maybe this route can be pursued first?
Oleg
On May 6, 2008, at 19:45, "N. Drinkwater" <[EMAIL PROTECTED]> wrote:
Several posts last month reported that starting J 6.02 on OSX resulted in an
error message-"Failed to get Java metrics." Although this error is a minor
annoyance when running the IDE, it would be potentially very confusing for end
users of standalone applications.
Investigating the problem further, I found that the error occurs the first time
J is started after every reboot. I've only encountered the error on OSX 10.4
(PPC) and 10.5 (Intel), both running Java SE 5. I had no problem running on
linux (Ubuntu 7 and Fedora 8, Java SE 6). The error does not occur if any java
program is run prior to starting J (including the prior failed attempt to start
J).
As a simple workaround (until either Java on OSX or j.jar is fixed), a simple
"splash screen" program can be inserted into the jwd script just prior to the
execution of J. With the addition of the splash screen, the Java metrics error
does not occur (even after a reboot) with the cost of a few seconds additional
startup time. The change to the startup isn't worthwhile for users of the IDE
who don't turn their computer off very often, but if you're distributing a
program for use by non-J programmers it may be worth consideration. The revised
start up script and java class for the splash screen are given below.
Norman Drinkwater
The revised jwd script is as follows (the last two lines are a single line of
code):
#!/bin/sh
# problems - see J bin/install.htm
cd "`dirname "$0"`/.."
java -jar bin/Splash.jar
java -Xss8000000 -Xdock:name=J -Xdock:icon=bin/icons/jred.icns -jar bin/j.jar
"$@"
The splash screen is adapted from code in a book on Swing by Loy et al.
(I don't do Java, only J these days, so others may have a better solution.)
/*
SplashScreen.java
Based on Java Swing (2nd ed.), by Loy et al.
*/
// Displays a simple text splash screen and exits after two seconds.
//
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
public class SplashScreen extends JWindow {
private int duration;
public SplashScreen(int d) {
duration = d;
}
public void showSplash() {
JPanel content = (JPanel) getContentPane();
content.setBackground(Color.white);
// Set the window's bounds, centering the window
int width = 80;
int height = 80;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width - width) / 2;
int y = (screen.height - height) / 2;
setBounds(x, y, width, height);
// Build the splash screen
JLabel logo = new JLabel("J",
JLabel.CENTER);
logo.setFont(new Font("Serif", Font.BOLD, 72));
logo.setForeground(Color.red);
content.add(logo, BorderLayout.SOUTH);
// Display it
setVisible(true);
// Wait a little while
try {
Thread.sleep(duration);
} catch (Exception e) {
}
setVisible(false);
}
public void showSplashAndExit() {
showSplash();
System.exit(0);
}
public static void main(String[] args) {
SplashScreen splash = new SplashScreen(2000);
splash.showSplashAndExit();
}
}
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm