Re: swing comments from an ex-C++ motif programmer



On Aug 31, 10:40 am, ap...@xxxxxxxxxxxxxxxxxx wrote:
However with Motif at least it was possible to get the result you
wanted

What? Later you complain about JTable. Motif doesn't even have a
table.

and the result always looked nice.

What? Motif looks even uglier than Windows 95. Look at this junk
http://www.opengroup.org/graphics/desktop/m-mwm.gif

I remember what happened with C++/Motif. A number
of competing toolkits were developed, some proprietary, some open
source. A number of them, mainly the open source ones, survived to the
present day.

The root of the X11 toolkit proliferation is not Motif. The root is
X11's architecture which was right from the beginning designed to be
independent of toolkits, and LAFs. And early X11 already shipped with
several toolkits, like Xt and Andrew.

What I am after is a toolkit that is built on swing that makes things
easier to code,

Swing is a toolkit.

Bling fan use SwingX for fancy effects https://swingx.dev.java.net/

possibly with a GUI builder (e.g like GTK has glade).

Hand-coding GUIs works better. If you really want a GUI builder look
at the one in NetBeans.

Whilst some toolkits do seem to be evolving in java they seem to be
concentrating on the LAF rather than making coding easier. Maybe this
is because swing components do not look nice by default.

It is completely up to the PLAF how a Swing component looks. Don't
like the look? Switch the PLAF.

As a relative latercomer to java I am shocked at the state of play
when it comes to GUI programming. I wonder why that is. Perhaps it is
because GUIs are moving over to being web based?

No, there are two main reasons:

Sun does not care about Java on the desktop. They spend most of the
development effort on enterprise stuff and ME, because that's where
the big bucks can be made.

The other issue is that it is really difficult to develop a non-
trivial cross-platform toolkit.

In particular I find it very awkward to implement a non-trivial JTable
component.

Well, here programming hasn't degenerated to copy-pasting stuff from
MSDN or clicking around in some fancy GUI. Sometimes a programmer has
to write code.

I want my table to be non-editable by the end-user

Use a TableModel with an isCellEditable() method that always returns
false. A trivial line of code.

programmatically updated (rows added/deleted/changed) upon the
asynchronous arrival of events from a third-party API.

Let the TableModel fire the necessary events to the JTable. This is
the general Swing architecture. The model informs the component about
updates. Nothing special when it comes to JTables.

See the implementation of the fire methods in AbstractTableModel for
examples on how the events should be fired, or even subclass
AbstractTableModel for your model and just use the methods. Make sure
you call the fire methods from the EDT, so use invokeLAter().

I want to be
able to set the color of cells depending on data that arrives via this
API. I have found a crude way to do it by extending
DefaultTableCellRenderer but I want something better.

Extend a JLabel and implement TableCellRenderer. Implement a
TableModel which keeps data type information, too. Let the
CellRenderer query the model for the type of a particular cell. Let
the renderer translate the type into a set of colors (e.g. from some
color schema). Let the renderer set the superclass (JLabel) colors.

.



Relevant Pages

  • Motifs Longevity
    ... However, as I begin to deal with larger end-user products that are not intended for the server room, I'm going to require a full-scale production class GUI framework that I can put my chops behind. ... I've always liked Motif for various reasons, but I guess since I'm not very fluent in GUI programming, I want to see what people who are experienced in Motif have to say about it. ... Reading through all the features and not features of each tookit can become a mountain of a task very quickly. ... All the write-ups regarding all the toolkits in this world has confused me to no end. ...
    (comp.windows.x.motif)
  • Re: kde vs gnome
    ... the solution is to have a style guide that every developer who ... The trick is to have GUI ... >> be done very easily on any GUI toolkit, including the X toolkits I ... I am certainly unhappy with the present concurrence of KDE ...
    (comp.unix.bsd.freebsd.misc)
  • Re: A common GUI API for Linux, is it possible?
    ... > A common GUI API for Linux, ... > irks me to think of all the RAM used by all those toolkits just so that I ... > GTK libraries. ...
    (comp.os.linux.development.apps)
  • Re: python QT or python-GTK
    ... drag&drop GUI BUILDER. ... Toolkits are libraries defining an API (in the ... multi-thousand lines of config file in xt; the config file was nearly as ... You can design your GUI's in the designer, ...
    (comp.lang.python)
  • Re: Wheel Mouse on FreeBSD
    ... >> It also doesn't work with Motif etc. ... I've done this once for the Motif List widget and it worked ... reasonably well although not quite like in toolkits which have ... Matthias Buelow ...
    (freebsd-stable)