-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.1.7, 1.2.0
-
generic, x86, sparc
-
generic, solaris_2.6, windows_nt
Name: mf23781 Date: 08/12/98
A JInternalFrame can be sized off of the desktop in which it
resides. This is a problem because the title bar of the
JInternalFrame can disappear off the top of the
desktop, and there is no way to resize the window or bring it
back onto the desktop. In the following sample program,
grab the bottom most part of the title bar and move it up as far
as possible in the JDesktopPane. This should result in there being a
narrow line where the title bar is. If you now grab the bottom right hand
corner of the JInternalFrame and resize it up above thetitle bar of
the desktop pane then the JInternalFrame will be positioned off the
desktop and is impossible to recover.
import com.sun.java.swing.*;
class JIFTest extends JFrame
{
public JIFTest()
{
super();
setBounds(100,100,300,300);
JInternalFrame jif = new
JInternalFrame("Test",true,true,true,true);
JDesktopPane dp = new JDesktopPane();
setContentPane(dp);
dp.add(jif);
try
{
jif.setBounds(50,50,200,200);
jif.setMaximum(false);
}
catch(Exception e)
{}
}
static public void main(String args[])
{
JIFTest jt = new JIFTest();
jt.show();
}
}
======================================================================
daniel.indrigo@Canada 1998-11-26
Problem with SWING 1.03
1. Create Problem
package test.display.frame;
public class ProblemDesk extends com.sun.java.swing.JFrame {
private com.sun.java.swing.JDesktopPane ivjDesktopPane = null;
private com.sun.java.swing.JInternalFrame ivjInternalFrame = null;
private com.sun.java.swing.JPanel ivjInternalFrameContentPanel = null;
private com.sun.java.swing.JLabel ivjLabel = null;
/**
* Constructor
*/
public ProblemDesk() {
super();
initialize();
}
/**
* ProblemDesk constructor comment.
* @param title java.lang.String
*/
public ProblemDesk(String title) {
super(title);
}
/**
* Return the DesktopPane property value.
* @return com.sun.java.swing.JDesktopPane
*/
private com.sun.java.swing.JDesktopPane getDesktopPane() {
if (ivjDesktopPane == null) {
try {
ivjDesktopPane = new com.sun.java.swing.JDesktopPane();
ivjDesktopPane.setName("DesktopPane");
getDesktopPane().add(getInternalFrame(), getInternalFrame().getName());
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjDesktopPane;
}
/**
* Return the InternalFrame property value.
* @return com.sun.java.swing.JInternalFrame
*/
private com.sun.java.swing.JInternalFrame getInternalFrame() {
if (ivjInternalFrame == null) {
try {
ivjInternalFrame = new com.sun.java.swing.JInternalFrame();
ivjInternalFrame.setName("InternalFrame");
ivjInternalFrame.setResizable(true);
ivjInternalFrame.setPreferredSize(new java.awt.Dimension(300, 100));
ivjInternalFrame.setBounds(37, 79, 334, 67);
ivjInternalFrame.setMaximumSize(new java.awt.Dimension(300, 100));
ivjInternalFrame.setTitle("Resize me");
getInternalFrame().setContentPane(getInternalFrameContentPanel());
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjInternalFrame;
}
/**
* Return the InternalFrameContentPanel property value.
* @return com.sun.java.swing.JPanel
*/
private com.sun.java.swing.JPanel getInternalFrameContentPanel() {
if (ivjInternalFrameContentPanel == null) {
try {
ivjInternalFrameContentPanel = new com.sun.java.swing.JPanel();
ivjInternalFrameContentPanel.setName("InternalFrameContentPanel");
ivjInternalFrameContentPanel.setLayout(new java.awt.BorderLayout());
getInternalFrameContentPanel().add(getLabel(), "Center");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjInternalFrameContentPanel;
}
/**
* Return the Label property value.
* @return com.sun.java.swing.JLabel
*/
private com.sun.java.swing.JLabel getLabel() {
if (ivjLabel == null) {
try {
ivjLabel = new com.sun.java.swing.JLabel();
ivjLabel.setName("Label");
ivjLabel.setText("I\'ve got a Problem with my size");
ivjLabel.setHorizontalTextPosition(com.sun.java.swing.SwingConstants.LEFT);
ivjLabel.setHorizontalAlignment(com.sun.java.swing.SwingConstants.CENTER);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjLabel;
}
/**
* Called whenever the part throws an exception.
* @param exception java.lang.Throwable
*/
private void handleException(Throwable exception) {
/* Uncomment the following lines to print uncaught exceptions to stdout */
// System.out.println("--------- UNCAUGHT EXCEPTION ---------");
// exception.printStackTrace(System.out);
}
/**
* Initialize the class.
*/
private void initialize() {
// user code begin {1}
// user code end
setName("ProblemDesk");
setDefaultCloseOperation(com.sun.java.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(426, 240);
setContentPane(getDesktopPane());
// user code begin {2}
// user code end
}
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
ProblemDesk aProblemDesk;
aProblemDesk = new ProblemDesk();
try {
Class aCloserClass = Class.forName("com.ibm.uvm.abt.edit.WindowCloser");
Class parmTypes[] = { java.awt.Window.class };
Object parms[] = { aProblemDesk };
java.lang.reflect.Constructor aCtor = aCloserClass.getConstructor(parmTypes);
aCtor.newInstance(parms);
} catch (java.lang.Throwable exc) {};
aProblemDesk.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of com.sun.java.swing.JFrame");
exception.printStackTrace(System.out);
}
}
}
Run sample.
Increase height or width of the internal frame using the mouse.
Repeat resizing and see the internal frame growing
at large intervals far beyond the given maximum.
2. Java Source Code with the problem
Check out BasicInternalFrameUI.BorderListener!
I first thought this finally gives us a frame
bound to it's max and min sizes. But looking at the
code I'm puzzled by the way the new dimension
of the frame gets calculated.
Excerpt of the mouseDragged() method:
...
case SOUTH:
if(startingBouds.height - deltaY < min.height)
deltaY = (startingBouds.height - min.height);
if(startingBouds.height - deltaY > max.height)
deltaY = -(startingBouds.height - min.height);
newW = startingBounds.width;
newH = startingBounds.height - deltaY;
...
I don't know what the code should do, but it shure
does not prevent the frame from exceeding it's
maximum size. Similar code is found for all the
other resize cases. How come, deltaY gets to be
-(startingBouds.height - min.height)
if the new size would exceede min.height?
-(startingBouds.height - min.height)
- duplicates
-
JDK-4138298 JInternalFrame deletes bottom border line at Motif L&F and Metal L&F
- Closed
- relates to
-
JDK-4305284 JInternalFrames can be sized off of the desktop
- Resolved