Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "usenet" Subject: Re: comp.lang.java.gui FA Message-ID: <0T3kvcp5Isfc@uni.chka.de> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 131 Date: Wed, 27 Apr 2011 15:25:52 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303917952 96.60.20.240 (Wed, 27 Apr 2011 10:25:52 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:25:52 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:147 To: comp.lang.java.gui In comp.lang.java.gui Thomas Weidenfeller wrote: > Q3.2 How do I update the GUI from another thread? > If you have to update the GUI from another thread (e.g. once you > offloaded a time consuming task from the EDT to another thread) you > should use the javax.swing.SwingUtilities.invokeLater() or > javax.swing.SwingUtilities.invokeAndWait(). Often you want > invokeLater(). invokeAndWait is broken and should not be used (It uses wait() without testing for success). > Q4.3 What is the right way to start a Swing GUI? > Sun almost silently changed the recommended GUI startup procedure. At > the beginning of 2004 the examples in Sun's GUI tutorial were changed, > and some rather short "explanation" was given. The explanation can be > summarized as: "There is a threading bug somewhere in Swing. To work > around, already build and start the GUI from the EDT". No more useful > information is provided, e.g. if Sun knows the root cause of the bug whether (clear?) > and intends to fix it. I doubt this is a single bug. > So now the official way to build and start (calling setVisible(true)) > the GUI is to use invokeLater(). The shortest version of a GUI > application's main() method becomes: > public static void main(String[] args) { > invokeLater(new Runnable() { Misses "SwingUtilities." or "EventQueue." > public void run() { > // > // Build and start the GUI here. > // > } > }); > } > Q5.8 How Do I center a window on the screen? How do I get the > screen size? [...] > 2) Since 1.4: > Window.setLocationRelativeTo(null); I doubt this works in a multi-screen environment without a virtual device. > Q5.10 How to ensure a particular aspect ration of a window? Isn't it called "aspect ratio"? > Q5.13 My window layout is displayed incorrectly. I have to move > the window, before the layout is right. What's wrong? > It is likely that you have changed the layout after you showed the > window. The layout is not redone in such cases, unless you tell the > container to do so. It is best to first finish the construction of > the window before showing it. If you really can't do this, then What is meant by "changed the layout"? > Alternatively one can call pack() after invalidating the window. But this will change the window's size. > Q6.1.3 How to create a non-rectangular widget? > The boundaries of a Component (widget) in Java are always rectangular. > Non-rectangular Components can be faked by implementing Components with > a transparent background. > Java will still treat these components as rectangular objects. E.g. The > standard layout managers always use the rectangular boundaries to > layout Components. If another behavior is required for transparent > Components (e.g. partly overlapping boundaries) custom layout mangers > need to be implemented. But with respect to mouse interactions (i.e. "which component is top at a specific point on a screen), Component.contains can be used to make a component not contains all the pixels within its boundary. > Q6.1.5 How do I find a component's top-level container (e.g. > the window)? > Use > SwingUtilities.getRoot() No, SwingUtilities.getWindowAncestor() > Q6.3.2 I have problems using the Swing HTML parser to parse all > kinds of HTML. Is this normal? > Unfortunately it is. The Swing HTML parser is the old HotJava parser > (Sun's pure Java web browser, once a separate product). It is limited > and hasn't been updated for a long time. In principle it can deal with Not true. For example, all HTML 4.01 character entities have been added. Christian --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24