Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6701166

setVisible(true) does not show a Button present in an embedded frame

    XMLWordPrintable

Details

    • x86
    • linux

    Description

      This is reproducible with jdk7 b27 PIT build on SuSE 10. Not reproducible with 6u10 b23.

      I've an AWT Button and an AWT Label present in a frame embedded in SWT shell. Both the components are invisible initially. On clicking an swt component, I'm showing the Button and Label. The label shows up, but the button doesn't.

      SWT 3.3.2 gtk-linux version was used for reproducing this issue.

      To reproduce, run the below test. Click on the swt List. It could be seen that a label shows up at the bottom panel. But, a button which is supposed to be shown, doesn't show up.

      import org.eclipse.swt.awt.SWT_AWT;
      import org.eclipse.swt.widgets.Display;
      import org.eclipse.swt.widgets.Shell;
      import org.eclipse.swt.widgets.Composite;
      import org.eclipse.swt.SWT;
      import org.eclipse.swt.layout.GridData;
      import org.eclipse.swt.widgets.Listener;
      import org.eclipse.swt.widgets.Event;

      import java.awt.Frame;
      import java.awt.Button;
      import java.awt.Label;
      import java.awt.Panel;

      public class TestXEmbed implements org.eclipse.swt.events.FocusListener {

          private Display display;
          private Shell shell;
          private Composite composite;
          private org.eclipse.swt.widgets.Button swtButton;
          private org.eclipse.swt.widgets.List swtList;
          private org.eclipse.swt.graphics.Rectangle sbBounds;
          private org.eclipse.swt.graphics.Rectangle shellClient;
          private org.eclipse.swt.graphics.Rectangle shellBounds;
          private Frame frame;
          private Button b;
          private Label label;
          private Panel panel;

          public static void main(String[] args) {
              TestXEmbed test = new TestXEmbed();
              test.waitToClose();
          }

          public void focusGained(org.eclipse.swt.events.FocusEvent event) {
              b.setVisible(true);
              label.setVisible(true);
              frame.invalidate();
              frame.validate();
          }

          public void focusLost(org.eclipse.swt.events.FocusEvent event) {
          }

          public Test() {
              initializeGUI();
          }

          private void initializeGUI() {
              display = new Display();
              shell = new Shell(display);
              shell.setText("AWT Test");
              org.eclipse.swt.layout.GridLayout gridlayout =
                  new org.eclipse.swt.layout.GridLayout();
              shell.setLayout(gridlayout);
              swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
              swtButton.setText("SWTButton");
              swtButton.setFocus();
              swtList = new org.eclipse.swt.widgets.List(shell, SWT.COLOR_LIST_BACKGROUND);
              swtList.add(" Einstein");
              swtList.add(" Tolstoy");
              swtList.add(" FeynMan");
              swtList.add(" Newton");
              swtList.addFocusListener(this);
           composite = new Composite(shell, SWT.EMBEDDED);
              composite.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL));
              composite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
           frame = SWT_AWT.new_Frame(composite);

              frame.setLayout(new java.awt.BorderLayout());
              panel = new Panel();
              panel.setLayout(new java.awt.FlowLayout());
              b = new Button("AWT Button");
              b.setVisible(false);
              label = new Label("AWT Label");
              label.setVisible(false);
              panel.add(label);
              panel.add(b);
              frame.add(panel);

              Listener exitListener = new Listener() {
                  public void handleEvent(Event e) {
                      System.err.println("User closed the window");
                      shell.dispose();
                      System.exit(1);
                  }
              };
              shell.addListener(SWT.Close, exitListener);
              shell.setLocation(300, 100);
              shell.setSize(400, 400);
           shell.open();
          }

          private void waitToClose() {
              while(!shell.isDisposed()) {
                  if (!display.readAndDispatch()) display.sleep();
              }
              display.dispose();
          }
      }

      Attachments

        Issue Links

          Activity

            People

              anthony Anthony Petrov (Inactive)
              gramachasunw Girish Ramachandran (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: