From: Jonathan F. <jon...@ya...> - 2008-11-17 06:18:05
|
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()); + } + }); } } |