From: Erik V. <eri...@hc...> - 2008-11-18 22:23:46
|
Jonathan, Thanks for this fix, which repairs a long-standing annoyance (at least to me). I have committed it into CVS. If you know a better way than a JLabel to achieve the same effect, I'd like to know it. This was the only way I could manage it. I think a separate and well-readable window report is needed for various reasons, not the least one being that, certainly in internet play, players would like to see a written account of the game actions, not cluttered by other log info. The format is like game reports I have seen published on the Internet, and indeed intended to be suitable for saving, emailing (PBEM), publishing etc. Erik. > -----Original Message----- > From: Jonathan Ferro [mailto:jon...@ya...] > Sent: Monday 17 November 2008 07:18 > To: rai...@li... > Subject: [Rails-devel] delurking with a quick ReportWindow fix > > Hello all, > > I haven't looked at the code in over a year (and really only > lurked before that), so I thought I'd find something to fix > to justify my continued presence. Here's a quick fix to > ReportWindow that (a) installs a clearer border around the > text, and (b) causes the scrollbar to wait until the text has > been repainted before recomputing where the "bottom" of the > window is. The (ab)use of a JLabel for the purpose of > displaying the game log, which makes it impossible to > select/copy the text, can be a lower-priority problem since > all the info in this window is also available in the debug log file. > > -- Jonathan > > swing $ diff -u ReportWindow.java.orig ReportWindow.java > --- ReportWindow.java.orig 2008-11-16 22:03:40.984375000 -0800 > +++ ReportWindow.java 2008-11-16 16:30:58.203125000 -0800 > @@ -32,6 +32,8 @@ > message.setBackground(Color.WHITE); > message.setOpaque(true); > message.setVerticalAlignment(SwingConstants.TOP); > + message.setBorder(BorderFactory.createEmptyBorder(5, > 5, 5, 5)); > + > messagePanel = new JPanel(new GridBagLayout()); > messageScroller = > new JScrollPane(message, > @@ -47,9 +49,6 @@ > > setSize(400, 400); > setLocation(600, 400); > - > - messagePanel.setBorder(BorderFactory.createEtchedBorder()); > - > setTitle("Rails: Game log"); > addWindowListener(this); > addKeyListener(this); > @@ -62,7 +61,11 @@ > buffer.insert(buffer.length() - 7, > newText.replaceAll("\n", "<br>")); > > messageWindow.message.setText(buffer.toString()); > - > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > + SwingUtilities.invokeLater(new Runnable() { > + public void run() { > + > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > + } > + }); > } > } > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |