Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #5186
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Overriding JComponent or implementing ComponentUI? |
| Date | 2012-07-01 20:11 -0400 |
| Organization | The Wasteland |
| Message-ID | <nospam-30C850.20115301072012@news.aioe.org> (permalink) |
| References | <kN1Ir.59786$GJ4.56436@newsfe16.iad> |
In article <kN1Ir.59786$GJ4.56436@newsfe16.iad>, Daniel Pitts <newsgroup.nospam@virtualinfinity.net> wrote: > I'm going to try to make a few custom components. Specifically > histogram and heat maps. Heat maps meaning histograms over time > plots. <http://www.jfree.org/jfreechart/> should be on your short list. I'd look at XYBarRenderer and XYBlockRenderer; both are pictured in the API and featured in the JWS demo. > I know there are probably existing libraries which do this, and I > will investigate using them too, but for my use-case I may need more > flexibility then they afford. In any case, I also enjoy implementing > these kinds of things as a learning exercise. As a simple example, implementing the Icon interface will allow you to leverage the text positioning feature(s) of JLabel: <https://sites.google.com/site/drjohnbmatthews/kineticmodel/code#Histogram> > So, in the past I've always implement custom views by extends > JComponent and overriding the paintComponent method. That works > fairly well, but then I noticed that there is the ComponentUI classes > and subclasses. > > Does anyone have any experience with implementing ComponentUI > classes? It seems to be part of the PLAF architecture, and since this > isn't really a look-and-feel configurable component, it seems like > that may be overkill. I've followed this outline to get the UI plumbing right, but there's little value unless you can realistically anticipate anyone ever wanting more that one UI delegate. <http://today.java.net/pub/a/today/2007/02/22/how-to-write-custom-swing-component.html> As a particular example, org.jfree.chart.JFreeChart itself extends Object, not JComponent. Typically, a JFreeChart is added to a ChartPanel, which extends JPanel and listens for chart related events. The container then adopts the chosen PLAF, while the chart has a ChartTheme. You can leverage the chosen PLAF by having your implementation of ChartTheme use the PLAF defaults. > Actually, I think I've answered my own question, but I'll post this > anyway to encourage discussions :-) > > Feedback and suggestions on libraries to use instead is welcome. > Thanks. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Overriding JComponent or implementing ComponentUI? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-01 12:45 -0700
Re: Overriding JComponent or implementing ComponentUI? "John B. Matthews" <nospam@nospam.invalid> - 2012-07-01 20:11 -0400
Re: Overriding JComponent or implementing ComponentUI? Roedy Green <see_website@mindprod.com.invalid> - 2012-07-05 07:40 -0700
Re: Overriding JComponent or implementing ComponentUI? "John B. Matthews" <nospam@nospam.invalid> - 2012-07-05 21:11 -0400
Re: Overriding JComponent or implementing ComponentUI? "John B. Matthews" <nospam@nospam.invalid> - 2012-07-05 21:06 -0400
Re: Overriding JComponent or implementing ComponentUI? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-10 01:42 +0200
Re: Overriding JComponent or implementing ComponentUI? Lew <noone@lewscanon.com> - 2012-07-09 23:30 -0700
Re: Overriding JComponent or implementing ComponentUI? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-10 20:18 +0200
Re: Overriding JComponent or implementing ComponentUI? Lew <lewbloch@gmail.com> - 2012-07-10 13:25 -0700
csiph-web