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

JLayeredPane setEnabled(false) ineffective on its children

XMLWordPrintable



      Name: vi73552 Date: 06/22/99


      This may be the a duplicate of 1257395, and akin to 4121207
      but I thought I'd bring it to your attention.
      JLayeredPane.setEnabled(false) is ineffective for recursively
      disabling its children.

      import java.awt.*;
      import java.util.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.table.*;


      public class disablePanelBug extends JFrame {
        public disablePanelBug(){
          getContentPane().setLayout(null);

          layeredPaneWithListener mainPanel = new layeredPaneWithListener();
      GridBagLayout gb = new GridBagLayout();
      mainPanel.setLayout(gb);

      GridBagConstraints leftPanelConst = new GridBagConstraints();
          leftPanelConst.weightx = 0.0;
      leftPanelConst.weighty = 0.0;
      leftPanelConst.gridx = 0;
      leftPanelConst.gridy = 0;
          leftPanelConst.fill = GridBagConstraints.VERTICAL;
          
      panelWithListener leftPanel = new panelWithListener();

      leftPanel.setBackground(Color.red);
      JLabel leftLabel = new JLabel("A Panel");
      leftPanel.add(leftLabel);
          gb.setConstraints(leftPanel,leftPanelConst);
          mainPanel.add(leftPanel);

          GridBagConstraints tableConst = new GridBagConstraints();
          tableConst.weightx = 1.0;
      tableConst.weighty = 1.0;
      tableConst.gridx = 1;
      tableConst.gridy = 0;
          tableConst.fill = GridBagConstraints.BOTH;
      Vector rows = new Vector();
      Vector row1 = new Vector();
      row1.addElement("row1 col1");
      row1.addElement("row1 col2");
      row1.addElement("row1 col3");
          Vector row2 = new Vector();
      row2.addElement("row2 col1");
      row2.addElement("row2 col2");
      row2.addElement("row2 col3");
      Vector row3 = new Vector();
      row3.addElement("row3 col1");
      row3.addElement("row3 col2");
      row3.addElement("row3 col3");

      rows.addElement(row1);
      rows.addElement(row2);
      rows.addElement(row3);

          Vector cols = new Vector();
      cols.addElement("Column1");
      cols.addElement("Column2");
      cols.addElement("Column3");

      DefaultTableModel tm = new DefaultTableModel(rows,cols);
      JTable table = new JTable(tm);
      JScrollPane s = new JScrollPane(table);
      s.setColumnHeaderView(table.getTableHeader());
          
          s.setBackground(Color.green);
          gb.setConstraints(s,tableConst);
          mainPanel.add(s);

          mainPanel.setSize(545,183);
      mainPanel.setLocation(0,0);
          getContentPane().add(mainPanel);

      mainPanel.setEnabled(false);

          setSize(547,185);
      show();
        }
        public static void main(String args[]){
          new disablePanelBug();
        }
      }

      class panelWithListener extends JPanel implements MouseMotionListener {
      public panelWithListener () {
      addMouseMotionListener(this);
      }
      public void mouseDragged(MouseEvent event) {
      System.out.println("Mouse dragged JPanel");
      }
      public void mouseMoved(MouseEvent event) {
      System.out.println("Mouse moved JPanel");
      }
      }

      class layeredPaneWithListener extends JLayeredPane implements MouseMotionListener {
      public layeredPaneWithListener () {
      addMouseMotionListener(this);
      }
      public void mouseDragged(MouseEvent event) {
      System.out.println("Mouse dragged JLayeredPane");
      }
      public void mouseMoved(MouseEvent event) {
      System.out.println("Mouse moved JLayeredPane");
      }
      }
      (Review ID: 84690)
      ======================================================================

            hgajewsksunw Hania Gajewska (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: