Subject: FVWM: Java GUIs and Fvwm2 revisited

From: Michael Lampe <[email-masked]>
Date: Wed, 07 Mar 2001 14:41:06 +0100

For users of the IBM JDK-1.3.0 for Linux I recommend putting a line like

    Style "*"           UsePPosition

in ~/.fvwm2rc. This seems to solve the problems with incorrectly sized
windows that were recently reported on this list. For reference, I have
attached one of the previously posted samples that show the error/fix.
It can also be seen with the Java2D demo from the JDK.

Aside:
  It really only helps with the IBM JDK. For the Blackdown and the Sun
Hotspot JDK it makes things even worse.

Some issues are still remaining:

1) The Notepad demo that comes with the JDK:

Obviously, the window wants to get positioned at +0+0. Fvwm2 positiones
it so that the upper left of the inside is at +0+0, so you don't see its
titile bar and left border. This is independent of
UsePPosition/NoPPosition.

I have seen similar perhaps related things with other apps:

a) xv:

Just start xv and open the visual schnauzer. It wants to be positioned
at -10-10, but is placed so that some of the right border and half of
the buttons at the bottom are outside the viewport.

b) gimp 1.2:

Open gfig: It wants to be placed centered in x at y=-0. Again the
buttons at the bottom are partially outside the viewport.

2) Forte (IDE for Java written in Java):

This is really funny. Forte opens a lot of windows. First, it opens a
window at the top of the screen with numerous menues, buttons, tabs,
etc, that spans from left to right. After a second, this window gets a
kick in the upper left direction so you can only see half of it
afterwards. Then more windows are opened. At first everything looks
right. But again after a second they all start crawling towards the
upper left (you can really watch them moving!) until they are all
outside the viewport.

Just to mention it: Mwm works fine for all these apps.

Perhaps someone with more insight in the subject can make something out
of all these peculiarities.

-Michael

// This file from the kde mailing list.  kde2 has a problem
// with the dialog window.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

public class Test extends JFrame
        implements ActionListener
{
        public static void main (String argv[]) throws Exception
        {
                Test t = new Test ();
                t.show ();
        }

        public Test ()
        {
                super ("Test");

                // add close listener
                addWindowListener (new WindowAdapter () {
                        public void windowClosing (WindowEvent e) {
                                dispose ();
                                System.exit (0);
                        }
                });

                // set the size and location
                Dimension frameSize = getPreferredSize ();
                Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
                setSize (frameSize);
                setLocation (screenSize.width / 2 - frameSize.width / 2,
                          screenSize.height / 2 - frameSize.height / 2);

                JButton button = new JButton ("Click Me");
                getContentPane().add (button);
                button.addActionListener (this);

                pack ();
        }

        public void actionPerformed (ActionEvent event)
        {
                TestDialog dialog = new TestDialog (this);
                dialog.show ();
        }

        public Dimension getPreferredSize ()
        {
                return new Dimension (640, 480);
        }

        public class TestDialog extends JDialog
        {
                public TestDialog (Frame owner)
                {
                        super (owner, "Dialog", true);

                        Container content = getContentPane ();

                        JPanel panel;
                        JPanel inputPanel = new JPanel (new GridLayout (2,1));
                        content.add (inputPanel);
                
                        panel = new JPanel (new FlowLayout (FlowLayout.RIGHT));
                        inputPanel.add (panel);

                        JLabel label;
                        label = new JLabel ("Username", JLabel.RIGHT);
                        panel.add (label);              
                        panel.add (new JTextField (16));
                        
                        panel = new JPanel (new FlowLayout (FlowLayout.RIGHT));
                        panel.setBorder (new EtchedBorder ());
                        content.add (panel, "South");                   
                                
                        JButton button = new JButton ("Cancel");
                        button.addActionListener (new ActionListener() {
                                public void actionPerformed (ActionEvent event)
                                {
                                        dispose ();
                                }
                        });
                        panel.add (button);
                
                        Dimension rootSize = getRootPane().getMinimumSize();
                        int paddedHeight = rootSize.height + 100;
                        int paddedWidth = rootSize.width + 100;
                        Dimension paddedSize = new Dimension(paddedWidth, paddedHeight);
                                             
                        setSize(paddedSize);

			// With the next line uncommented, a problem is
			// shown.  with it commented, no problem is visible.
			pack ();

                        setLocationRelativeTo (owner);
                }
        }
}