Opened 9 years ago

Last modified 9 years ago

#6026 new defect

Matchbox won't show a Java/Swing window

Reported by: skim Owned by: marco
Priority: high Milestone: 9.1.0-cancelled
Component: sugar Version:
Keywords: 9.1.0:? Cc: mallum, stepheneb
Blocked By: Blocking:
Deployments affected: Action Needed:
Verified: no


I thought I'd create a new ticket although this is perhaps remotely related to #907 and #5132.

I tried a minimal Java/Swing application with the following code on jhbuild, and found that either setLocation() or setSize() must be called AFTER setVisible(True) for the window to show itself correctly.

Otherwise, if either none of the setLocation() and setSize() were called or if they were called BEFORE setVisible(), the Sugar would hang with a blank screen.

Normally the order of the method calls shouldn't matter. I ran the matchbox window manager on Ubuntu Linux and it didn't have the problem there.

I saw this problem with both java 5 and java 6, on build 623 and jhbuild.

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;

public class SwingTest extends JFrame {
    JMenuBar menuBar;

    public static void main(String[] args) {
        SwingTest viewer = new SwingTest();

    public SwingTest() {
	setTitle("Swing Test");


	setVisible(true); // works!
	setLocation(10, 10);
	//setVisible(true); // breaks!

    public JMenuBar updateMenuBar() {
        JMenu fileMenu = null;
        if (menuBar == null) {
            menuBar = new JMenuBar();
	  fileMenu = new JMenu("File");
        else {
            fileMenu = menuBar.getMenu(0);
        fileMenu.add(new ExitAction());
        return menuBar;

    class ExitAction extends AbstractAction {
	private static final long serialVersionUID = 1L;

	public ExitAction() {

	public void actionPerformed(ActionEvent e) {

Change History (7)

comment:1 Changed 9 years ago by jg

  • Cc mallum added
  • Milestone changed from Never Assigned to Update.1

Matthew, do you have a clue what is going on?

comment:2 Changed 9 years ago by mallum

I've seen a similar problem a long time ago (but with awt rather than swing, iirc) when java applications would not initially mapp correctly if they did not get given there requested window size by the window manager (which an app should handle). Sounds like a similar thing here with comments regarding set size etc working around issue.

Not sure whats best to suggest here beyond treating all java applications as dialogs or some such.

comment:3 Changed 9 years ago by marco

  • Milestone changed from Update.1 to Retriage, Please!

Jim, is this actually something we should spend time on for Update.1? There is a work around and we are not going to ship Java activities with Update.1.

comment:4 Changed 9 years ago by jg

  • Milestone changed from Retriage, Please! to Update.2

no, we won't spend time on it now given Matthew's response; I just wanted to get this on people's radar screen. It's clearly not something we can resolve any time soon.

comment:5 Changed 9 years ago by stepheneb

  • Cc stepheneb added

comment:6 Changed 9 years ago by marco

  • Milestone changed from Update.2 to Future Release

comment:7 Changed 9 years ago by marco

  • Keywords 9.1.0:? added
  • Milestone changed from Future Release to 9.1.0

We might switch to metacity for 9.1.0.

Note: See TracTickets for help on using tickets.