PureSwing

New version available on PureSwing homepage.

Changes in release 20091121:

  • Fixed compilation under Java 5
  • Added MigLayout (contributed by Mikael Grev, MiG InfoCom AB)
  • Changed to use Graphics2D instead of Graphics
  • Added EventQueue.runLoop()
  • Moved JComponent’s constants UNDEFINED_CONDITION, WHEN_FOCUSED,
    WHEN_ANCESTOR_OF_FOCUSED_COMPONENT and WHEN_IN_FOCUSED_WINDOW to
    InputCondition enum
  • Changed WindowConstants interface to CloseOperation enum
  • Removed DebugGraphics
  • Removed old version of JDesktopPane and removed JInternalFrame
  • Changed Cursor API
  • Moved JSplitPane’s constants HORIZONTAL_SPLIT and VERTICAL_SPLIT to
    SplitOrientation enum, also made continuous layout by default
  • Improved dialog modality API
  • Added initial Slick support
  • Removed usage of continuations
  • Removed UnsupportedLookAndFeelException

Also latest development version is now available from Monotone repository.

Maybe i’m doing something wrong, but i’m perplexed that a JLabel doesn’t have a model. How are we supposed to share them in more complex cellrenderers (2 labels x 3 different panels).

this is a great and very promising project, the one i’m looking for quite a while :slight_smile:

i have a 3d virtual world application with a complicated Swing GUI rendered with jPCT’s software renderer. i had been looking for ways to port it to OpenGL. now it seems i’ve found the solution :smiley:

however i’m having difficulty running Modern3D demo. below is the exception. any ideas why this happens ? this is a ubuntu 8.04 on a toshiba sattelite laptop with an onboard intel chipset. i got the same exception at Win XP on a similar toshiba laptop.

SlickDemo runs ok although layout is a bit garbaged (texts does not fit into components)

i’ve also posted the problem to LWJGL forum

Exception in thread "main" java.lang.IllegalStateException: Function is not supported
	at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:64)
	at org.lwjgl.opengl.EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.java:170)
	at cz.advel.modern3d.opengl.LWJGLContext.flush(LWJGLContext.java:175)
	at cz.advel.modern3d.opengl.LWJGLContext.<init>(LWJGLContext.java:93)
	at cz.advel.pureswing.test.Modern3DDemo.main(Modern3DDemo.java:82)

As a guess, I think the problem is that modern3d uses shaders which your intel video card doesn’t support. If you look into the requirements of modern3d you’d be able to find out

Modern3D requires some minimum functionality, not good option for general/web usage. Best would be to port Graphics2D implementation from Modern3D to pure LWJGL and fixed function pipeline instead of shaders, this is not problem as it uses just Pixel Shaders 2.0 in more or less the same way like fixed function pipeline. I’ll look into it for next release.

Slick support needs little more work.

i see. thanks.

any plans when to do it ?

I’ll look into it somewhere between tommorow and end of next week probably.

great. i can’t wait it :slight_smile:

I’ve tried porting Karga to PureSwing (with default Desktop). Most went quite smootly :slight_smile:

below are some issues i’ve faced (some important some not)

  • ImageIcon(url) waits indefinetely if given url is an animated gif
  • JDesktopPane does not correctly stack (render and dispatch mouse events) components
  • JLabel doesn’t support multilines (separated with \n)
  • JFrame.pack() does not take window decorations (title bar, borders) into account
  • JFrame.setDefaultCloseOperation(CloseOperation.EXIT_ON_CLOSE) does not work
  • switching to another window and coming back results in losing keyboard focus. we even can not regain it by clicking
  • pressing Tab does not iterate over focusable components

and some opinions:

  • re-adding JOptionPane.showInternalXXDialog makes sense to show the dialogs embedded in same window
  • re-adding basic HTML support can make sense (JEditorPane, JTextPane, html in JLabel) they are very handy to create multi color/line/format texts.

and below is a test case:

[quote]import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;

import cz.advel.pureswing.CloseOperation;
import cz.advel.pureswing.EventQueue;
import cz.advel.pureswing.JDesktopPane;
import cz.advel.pureswing.JFrame;
import cz.advel.pureswing.JPanel;
import cz.advel.pureswing.JTextField;
import cz.advel.pureswing.event.MouseAdapter;
import cz.advel.pureswing.event.MouseEvent;

public class MultiLayer {
public static final Integer BACKGROUND_LAYER = new Integer(10);
public static final Integer HELPERS_LAYER = new Integer(30);

public static void main(String[] args) {
	JDesktopPane desktop = new JDesktopPane();
	desktop.setPreferredSize(new Dimension(800, 600));
	
	JPanel backgroundPanel = new JPanel();
	backgroundPanel.setBackground(Color.LIGHT_GRAY);
	desktop.add(backgroundPanel, BACKGROUND_LAYER);
	// this should be centered in frame but is not
	backgroundPanel.setBounds(new Rectangle(50, 50, 700, 500));
	backgroundPanel.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent event) {
			System.out.println("mouse clicked on background");
		}
	});
	
	// this text field should be rendered on top of background but is not
	JTextField textField = new JTextField();
	desktop.add(textField, HELPERS_LAYER);
	textField.setBounds(0, 50, 200, 20);
	textField.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent event) {
			System.out.println("mouse clicked on textField");
		}
	});
	
	JFrame frame = new JFrame("PureSwing - test");
	frame.setDefaultCloseOperation(CloseOperation.EXIT_ON_CLOSE);
	frame.add(desktop);
	frame.pack();
	frame.setVisible(true);
	
	EventQueue.runLoop();
}

}
[/quote]
hope this helps,
r a f t

Nice, though expect for API changes in each new release. This project is currently still in early state.

I’ll remove this property. The default action will be dispose() and once all windows are closed the runLoop() method will exit (immediatelly not with delay like in AWT/Swing). This should work better and be simpler.

Yeah, AWT backend is not fully finished.

You can embed normal JFrame/JDialog/JWindow in JDesktopPane. Just use the desktop instance provided by JDesktopPane. Though you can currently do it for JOptionPane only by using PureSwing.setDesktop(). I’ll look into how to improve it, maybe by just adding parameter for desktop or something.

This will take some time. I have richtext editor component in development with focus on simplicity/extendability and 100% deterministic and expected behaviour when editing by user. I started development in 2006 when I’ve found no such Swing component exist (commercial or not), but found later I didn’t needed it so development became freezed, also it needs some changes to structure as the old structure wasn’t best (though almost good). I plan to add it to PureSwing replacing JEditorPane and other text stuff and also use the rendering part for “HTML” (it will be simplified HTML) support for labels and other components.

Sorry already there. Deleted to hide my stupidity.

Actually, no it doesn’t appear to be.
In short, a composable JPopupMenu if setInheritsPopupMenu == true, with the composed JPopupMenu got from the parent.

Must be lazy and non-persistent though, in getting the composed one. Why? Because the main component is built before adding to the parent, the popupmenu can change etc.

When i first used Actions, i expected the enabled state (indeed all visualization properties) to be checked whenever the action using component needed. So i overrided isEnabled() to return state appropriate to that delta Time. Little did i know that swing uses a push event model, so altering the visualization requires a setEnabled(false) from someone so notification happens.

Got tripped in this again right now. Pathetic really.

Edit: Because i rambled without making a point.
Make abstract action getters and setters final!!! Counsel in the javadoc adding a listener to the observed object by the action!!!

Speaking of action. I think the setActionCommand and setActionListener and friends should be deprecated in favor of the new Action interface always.

JPopupMenu has a hilarious bug.
It’s position is always (0,0).

It is also not added to the normal component hierarchy (under it) so getMousePostion also return 0,0.
You would think that adding a mouselistener to the component the popupmenu is going to be over and listening for the click you want would work, and it does … the first time. If you do right click, it does send the first even and show the popup, then move the mouse outside the popup and right click again, it doesn’t send the event to the component (i assume the popup installs something funky or catches the event.

Since 1.4
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4527633

This is a discussion:
http://markmail.org/message/effistg6dcs2d5aq#query:JPopupMenu%20parent+page:1+mid:vwodpxiuahvjkdlg+state:results

Can be worked around with a PopupMenuListener, getting the invoker directly (instead of getParent) and using that on the swing utility methods. Strangely getMousePosition on the invoker still returns null, but the other appears to work.
Component c = ((JPopupMenu)e.getSource()).getInvoker();
if(c == yourPreferredComponent){
lastVisiblePoint = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(lastVisiblePoint, c);

}else{

}

any plans for date of next release ? ::slight_smile: i’m not in a hurry, just for wonder…

Hello,
I have downloaded the PureSwing ZIP distro.
Trying to run demo classes in gnu.classpath.examples.swing package with no success.
The main method starts, does nothing and exits immediately.

I have run it in debug mode and learned that the runnable passed to SwingUtilities.invokeLater in demo main method is never started.

Any hints? Thx.

Ubuntu 9.04 , SUN Java 1.6

Nice catch, I forgot to update main() method for individual demos. Please use main Demo or move the code from invokeLater directly to main() and add EventQueue.runLoop() at the end.

SwingUtilities.invokeLater is not needed to start the GUI as it uses main thread directly, event queue loop is also explicit, see the EventQueue.runLoop() method and it’s javadoc.

JTooltip mouseevents bitching, by myself.

http://forums.java.net/jive/thread.jspa?messageID=386908&#386908

What is your use case? Normally the tooltip should hide or reposition when the mouse hits it. I don’t know if it works that way in Swing generally now, but it’s the way it should work :slight_smile:

EDIT: Oh I now see the description of the bug… interesting behaviour indeed…

What really hurts is the usability. I mean it’s probably bad idea to allow a general even passthorugh, because when i tried, it messed with the repaint buffer, since one of my mouselisteners called repaint on the list underneath the tooltip, but at least for some of them, like the ultra useful mousewheelevent on a JScrollpane underneath the tooltip, it should pass.

In my app i made it pass even if the tooltip is outside the bounds (my tooltips are at a specified place, for a JList alone inside the JScrollpane and it was easier YMMV).

The real solution is to make the tooltips invisible to everything, including events and damaging repaint requests.