Ticket #6026 (new defect)

Opened 7 years ago

Last modified 6 years ago

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
Action Needed: Verified: no
Deployments affected: Blocked By:
Blocking:

Description

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() {
	super();
	setTitle("Swing Test");

	updateMenuBar();
	setJMenuBar(menuBar);

	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");
	  menuBar.add(fileMenu);
        } 
        else {
            fileMenu = menuBar.getMenu(0);
	  fileMenu.removeAll();
        }
        fileMenu.add(new ExitAction());
        return menuBar;
    }

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

	public ExitAction() {
	    super("Exit");
	}

	public void actionPerformed(ActionEvent e) {
	    System.exit(0);
	}
    }
}

Change History

Changed 7 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?

Changed 7 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.

Changed 7 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.

Changed 7 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.

Changed 7 years ago by stepheneb

  • cc stepheneb added

Changed 6 years ago by marco

  • milestone changed from Update.2 to Future Release

Changed 6 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.