JInternalFrame inmovable

Hallo!

Sowas?
Code:
/**
 * 
 */
package de.tutorials;

import java.awt.Dimension;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;

/**
 * @author Tom
 */
public class JDesktopPaneExample extends JFrame {

	JDesktopPane desktopPane;

	public JDesktopPaneExample() {
		super("JDesktopPaneExample");
		setDefaultCloseOperation(EXIT_ON_CLOSE);

		desktopPane = new JDesktopPane();
		desktopPane.setPreferredSize(new Dimension(320, 240));

		final JInternalFrame frm = new JInternalFrame("NotMovable");

		final int x = 50, y = x;

		frm.setBounds(x, y, 160, 120);

		frm.setVisible(true);

		frm.addComponentListener(new ComponentAdapter() {
			public void componentMoved(ComponentEvent e) {
				frm.setLocation(x, y);
			}
		});

		desktopPane.add(frm);

		add(new JScrollPane(desktopPane));

		pack();

		setVisible(true);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new JDesktopPaneExample();
	}

}

Gruß Tom
 
Zurück