AWT

Norman Hendrich hendrich@informatik.uni-hamburg.de
Mon Aug 16 15:39:00 GMT 2004


Hello, 
this is the third attempt to get my mail through your spamfilter...
---
I just managed to get jfig running under GCJ 3.5! (The AWT version,
that is; I guess I will try Swing again after the next GUI-branch merge):
http://tams-www.informatik.uni-hamburg.de/applets/jfig/
 archive/screen-jfig-gcj-20040816.gif
BTW, this is the "gcj (GCC) 3.5.0 20040704 (experimental)" snapshot with
the recent drawImage patch.
Status: Most things work, but there are a few issues:
* help menu missing
* annoying flicker for Canvas/Panel subclasses (see attached testcase);
 this also means the app is eating 100% cpu time... why does the event
 loop keeps calling paint() over and over again?
 
* CheckboxMenuItems don't work
* focus problems with nested dialogs (admittedly, the AWT had them, too).
* the buttons really should be transparent. This is either a problem with
 image loading or with Button not getting the dark gray background.
 
- Norman
import java.awt.*;
/** 
 * demonstrate Gcj/Gtk annoying flicker for Canvas/Panel 
 */
public class GcjFlicker
 //extends Component
 //extends Panel
 extends Canvas
{
 String msg;
 Font font = new Font( "Helvetica", Font.PLAIN, 12 );
 FontMetrics fm = null;
 int w, h, y;
 public GcjFlicker() {
 super();
 // getFontMetrics is deprecated, but we keep it for 1.1 compatibility
 fm = Toolkit.getDefaultToolkit().getFontMetrics( font );
 h = fm.getHeight();
 w = 600; // full width
 msg = "status messages will appear here";
 }
 /**
 * directly set the new message, without touching the message stack
 */
 public synchronized void setText( String msg ) {
 this.msg = msg;
 repaint();
 }
 public void paint( Graphics g ) {
 //Thread.dumpStack(); // who keeps calling? the event loop :-(
 setBackground( Color.lightGray );
 g.clearRect( 0, 0, getBounds().width, getBounds().height );
 g.setColor( Color.black );
 int y = h + (getBounds().height - h)/2;
 g.setFont( font );
 g.drawString( msg, 10, y );
 }
 public Dimension getPreferredSize() {
 int xsize = w;
 int ysize = 2*h;
 return new Dimension( xsize, ysize );
 }
 public Dimension getMinimumSize() {
 return new Dimension( 100, 2*h ); 
 }
 public static void main( String argv[] ) {
 Frame frame = new Frame( "GCJ flickering demo" );
 GcjFlicker gf = new GcjFlicker();
 gf.setText( "flickering message" );
 frame.add( "North", gf );
 frame.add( "South", new Label( "Just a Label" ));
 frame.pack();
 frame.show();
 }
} 


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /