moved in from other realms
git-svn-id: https://samskivert.googlecode.com/svn/trunk@791 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// $Id: JInternalDialog.java,v 1.1 2002/07/09 17:48:23 ray Exp $
|
||||
|
||||
package com.samskivert.swing;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
|
||||
/**
|
||||
* Used for displaying dialogs internally. Be sure to use {@link
|
||||
* #showDialog} and {@link #dismissDialog} to show and hide these dialogs
|
||||
* because they need to do some extra fiddling that the regular show and
|
||||
* hide wouldn't do.
|
||||
*/
|
||||
public class JInternalDialog extends JInternalFrame
|
||||
{
|
||||
/**
|
||||
* Creates a dialog that will display itself in the layered pane of
|
||||
* the frame that contains the supplied component.
|
||||
*/
|
||||
public JInternalDialog (JComponent friend)
|
||||
{
|
||||
this(JLayeredPane.getLayeredPaneAbove(friend));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dialog that will display itself in the layered pane of
|
||||
* the supplied frame.
|
||||
*/
|
||||
public JInternalDialog (JFrame frame)
|
||||
{
|
||||
this(frame.getLayeredPane());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dialog that will display itself in the specified layered
|
||||
* pane.
|
||||
*/
|
||||
public JInternalDialog (JLayeredPane parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this dialog to its parent and shows it.
|
||||
*/
|
||||
public void showDialog ()
|
||||
{
|
||||
_parent.add(this, JLayeredPane.PALETTE_LAYER);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides this dialog and removes it from its parent.
|
||||
*/
|
||||
public void dismissDialog ()
|
||||
{
|
||||
setVisible(false);
|
||||
_parent.remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans up the interface hierarchy looking for the {@link
|
||||
* JInternalDialog} that contains the supplied child component and
|
||||
* dismisses it.
|
||||
*/
|
||||
public static void dismissDialog (Component child)
|
||||
{
|
||||
if (child == null) {
|
||||
return;
|
||||
} else if (child instanceof JInternalDialog) {
|
||||
((JInternalDialog)child).dismissDialog();
|
||||
} else {
|
||||
dismissDialog(child.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
/** Our parent. */
|
||||
protected JLayeredPane _parent;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// $Id: SafeScrollPane.java,v 1.1 2002/07/09 17:48:23 ray Exp $
|
||||
|
||||
package com.samskivert.swing;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JViewport;
|
||||
|
||||
/**
|
||||
* A scroll pane that is safe to use in frame managed views.
|
||||
*/
|
||||
public class SafeScrollPane extends JScrollPane
|
||||
{
|
||||
public SafeScrollPane (Component view)
|
||||
{
|
||||
super(view);
|
||||
}
|
||||
|
||||
protected JViewport createViewport ()
|
||||
{
|
||||
JViewport vp = new JViewport();
|
||||
vp.setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
|
||||
return vp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user