-
Bug
-
Resolution: Duplicate
-
P1
-
None
-
1.1
-
None
-
generic
-
solaris_2.5.1
I have an application with a menu bar, a button, and a text area.
Now, when the button is hit, I want to hide the text area, and resize the
window to a new size. Then when the button is hit again, I want to show
the hidden part again and resize the window to its original size.
I wrote some code to do this. The odd thing is that this works
fine on NT, but on Solaris (CDE, and Openwin) the window Jumps around.
i.e, while the width and height do get set properly, the 'x' and 'y'
coordinates are also getting messed up.
Note that this happens ONLY when the menu bar is present in the
app. I have included the Java source for a test case.
The behaviour is slightly different on CDE and Openwin. On CDE,
the jump happens the first time you show/hide after moving the window.
On Openwin, it jumps all the time.
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class showhidetest extends Frame implements WindowListener, ActionListener
{
Button bdat= new Button("Hide");
TextArea tarea = new TextArea( 20, 20 );
MenuBar mbar = new MenuBar();
public showhidetest()
{
bdat.addActionListener(this);
Panel p = new Panel();
p.setLayout( new BorderLayout() );
add( p );
p.add( "North", bdat );
p.add( "Center", tarea );
Menu fmenu = new Menu("File", true);
mbar.add(fmenu);
fmenu.add( new MenuItem("Exit") );
setMenuBar( mbar );
addWindowListener(this);
}
public void windowClosed(WindowEvent event) {
}
public void windowOpened(WindowEvent event) {
}
public void windowIconified(WindowEvent event) {
}
public void windowDeiconified(WindowEvent event) {
}
public void windowActivated(WindowEvent event) {
}
public void windowDeactivated(WindowEvent event) {
}
public void windowClosing(WindowEvent event) {
System.exit(0);
}
public void actionPerformed( ActionEvent event)
{
Object source = event.getSource();
if( source == bdat) {
if (bdat.getLabel().equals("Show"))
{
setComponentState( tarea, true );
bdat.setLabel( "Hide" );
}
else if (bdat.getLabel().equals("Hide"))
{
setComponentState( tarea, false );
bdat.setLabel( "Show" );
}
}
}
/**
* This is responsible for showing/hiding components
* and readjusting the UI
* @param comp the component to hide/shiw
* @param showc if set, then the component is being shown
*/
private void setComponentState( Component comp, boolean showc )
{
// If the state is the same as the component's state, skip it
if (showc == comp.isVisible()) return;
Dimension csize = comp.getSize();
Dimension size = getSize();
if (!showc)
{
comp.setVisible( false );
setSize( size.width, size.height - csize.height );
}
else
{
comp.setVisible( true );
setSize( size.width, size.height + csize.height );
}
}
public static void main( String args[] )
{
Frame f = new showhidetest();
f.setSize( 200, 200 );
f.show();
}
}
Is this going to be fixed in the next release of jdk(1.1.1)?
Several groups at Cadence cannot release their products without this fix.
__Nasser
nasser.nouri@Corp 1997-03-20
Now, when the button is hit, I want to hide the text area, and resize the
window to a new size. Then when the button is hit again, I want to show
the hidden part again and resize the window to its original size.
I wrote some code to do this. The odd thing is that this works
fine on NT, but on Solaris (CDE, and Openwin) the window Jumps around.
i.e, while the width and height do get set properly, the 'x' and 'y'
coordinates are also getting messed up.
Note that this happens ONLY when the menu bar is present in the
app. I have included the Java source for a test case.
The behaviour is slightly different on CDE and Openwin. On CDE,
the jump happens the first time you show/hide after moving the window.
On Openwin, it jumps all the time.
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class showhidetest extends Frame implements WindowListener, ActionListener
{
Button bdat= new Button("Hide");
TextArea tarea = new TextArea( 20, 20 );
MenuBar mbar = new MenuBar();
public showhidetest()
{
bdat.addActionListener(this);
Panel p = new Panel();
p.setLayout( new BorderLayout() );
add( p );
p.add( "North", bdat );
p.add( "Center", tarea );
Menu fmenu = new Menu("File", true);
mbar.add(fmenu);
fmenu.add( new MenuItem("Exit") );
setMenuBar( mbar );
addWindowListener(this);
}
public void windowClosed(WindowEvent event) {
}
public void windowOpened(WindowEvent event) {
}
public void windowIconified(WindowEvent event) {
}
public void windowDeiconified(WindowEvent event) {
}
public void windowActivated(WindowEvent event) {
}
public void windowDeactivated(WindowEvent event) {
}
public void windowClosing(WindowEvent event) {
System.exit(0);
}
public void actionPerformed( ActionEvent event)
{
Object source = event.getSource();
if( source == bdat) {
if (bdat.getLabel().equals("Show"))
{
setComponentState( tarea, true );
bdat.setLabel( "Hide" );
}
else if (bdat.getLabel().equals("Hide"))
{
setComponentState( tarea, false );
bdat.setLabel( "Show" );
}
}
}
/**
* This is responsible for showing/hiding components
* and readjusting the UI
* @param comp the component to hide/shiw
* @param showc if set, then the component is being shown
*/
private void setComponentState( Component comp, boolean showc )
{
// If the state is the same as the component's state, skip it
if (showc == comp.isVisible()) return;
Dimension csize = comp.getSize();
Dimension size = getSize();
if (!showc)
{
comp.setVisible( false );
setSize( size.width, size.height - csize.height );
}
else
{
comp.setVisible( true );
setSize( size.width, size.height + csize.height );
}
}
public static void main( String args[] )
{
Frame f = new showhidetest();
f.setSize( 200, 200 );
f.show();
}
}
Is this going to be fixed in the next release of jdk(1.1.1)?
Several groups at Cadence cannot release their products without this fix.
__Nasser
nasser.nouri@Corp 1997-03-20
- duplicates
-
JDK-4028130 replacing menubar causes frame to migrate upwards
-
- Closed
-