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

JPopup repaint all screen area On JWindow

XMLWordPrintable

    • beta
    • generic
    • generic



      Name: vi73552 Date: 07/06/99


      The following simple program shows that the screen is repainted between the JButton and the JPopup that appear on screen when you press the button.
      To press multiple times the button shows clearly the bug.
      This bug is not present when using a JFrame.

      package test.popup;

      public class PopupOnWindow extends javax.swing.JWindow implements java.awt.event.ActionListener {
      private javax.swing.JButton ivjJButton1 = null;
      private javax.swing.JDesktopPane ivjJDesktopPane1 = null;
      private javax.swing.JInternalFrame ivjJInternalFrame1 = null;
      private javax.swing.JPanel ivjJInternalFrameContentPane = null;
      private javax.swing.JMenuItem ivjJMenuItem1 = null;
      private javax.swing.JMenuItem ivjJMenuItem2 = null;
      private javax.swing.JPopupMenu ivjJPopupMenu1 = null;

      public PopupOnWindow() {
      super();
      initialize();
      }

      public PopupOnWindow(java.awt.Frame owner) {
      super(owner);
      }

      public void actionPerformed(java.awt.event.ActionEvent e) {
      if ((e.getSource() == getJMenuItem2()) ) {
      connEtoC2(e);
      }
      if ((e.getSource() == getJButton1()) ) {
      connEtoM1(e);
      }
      }

      private void connEtoC2(java.awt.event.ActionEvent arg1) {
      try {
      this.jMenuItem2_ActionPerformed(arg1);
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      }

      private void connEtoM1(java.awt.event.ActionEvent arg1) {
      try {
      getJPopupMenu1().show(getJDesktopPane1(), 0, 0);
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      }
      private javax.swing.JButton getJButton1() {
      if (ivjJButton1 == null) {
      try {
      ivjJButton1 = new javax.swing.JButton();
      ivjJButton1.setName("JButton1");
      ivjJButton1.setText("JButton1");
      ivjJButton1.setBounds(23, 112, 85, 25);
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJButton1;
      }
      private javax.swing.JDesktopPane getJDesktopPane1() {
      if (ivjJDesktopPane1 == null) {
      try {
      ivjJDesktopPane1 = new javax.swing.JDesktopPane();
      ivjJDesktopPane1.setName("JDesktopPane1");
      getJDesktopPane1().add(getJInternalFrame1(), getJInternalFrame1().getName());
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJDesktopPane1;
      }
      private javax.swing.JInternalFrame getJInternalFrame1() {
      if (ivjJInternalFrame1 == null) {
      try {
      ivjJInternalFrame1 = new javax.swing.JInternalFrame();
      ivjJInternalFrame1.setName("JInternalFrame1");
      ivjJInternalFrame1.setBounds(759, 522, 198, 195);
      getJInternalFrame1().setContentPane(getJInternalFrameContentPane());
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJInternalFrame1;
      }
      private javax.swing.JPanel getJInternalFrameContentPane() {
      if (ivjJInternalFrameContentPane == null) {
      try {
      ivjJInternalFrameContentPane = new javax.swing.JPanel();
      ivjJInternalFrameContentPane.setName("JInternalFrameContentPane");
      ivjJInternalFrameContentPane.setLayout(null);
      getJInternalFrameContentPane().add(getJButton1(), getJButton1().getName());
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJInternalFrameContentPane;
      }
      private javax.swing.JMenuItem getJMenuItem1() {
      if (ivjJMenuItem1 == null) {
      try {
      ivjJMenuItem1 = new javax.swing.JMenuItem();
      ivjJMenuItem1.setName("JMenuItem1");
      ivjJMenuItem1.setText("JMenuItem1");
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJMenuItem1;
      }
      private javax.swing.JMenuItem getJMenuItem2() {
      if (ivjJMenuItem2 == null) {
      try {
      ivjJMenuItem2 = new javax.swing.JMenuItem();
      ivjJMenuItem2.setName("JMenuItem2");
      ivjJMenuItem2.setText("Exit");
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJMenuItem2;
      }
      /**
      private javax.swing.JPopupMenu getJPopupMenu1() {
      if (ivjJPopupMenu1 == null) {
      try {
      ivjJPopupMenu1 = new javax.swing.JPopupMenu();
      ivjJPopupMenu1.setName("JPopupMenu1");
      ivjJPopupMenu1.add(getJMenuItem1());
      ivjJPopupMenu1.add(getJMenuItem2());
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      };
      return ivjJPopupMenu1;
      }
      private void handleException(Throwable exception) {
      System.out.println("--------- UNCAUGHT EXCEPTION ---------");
      exception.printStackTrace(System.out);
      }
      private void initConnections() {
      getJMenuItem2().addActionListener(this);
      getJButton1().addActionListener(this);
      }
      private void initialize() {
      setName("PopupOnWindow");
      setSize(1200, 800);
      setContentPane(getJDesktopPane1());
      initConnections();
      }
      public void jMenuItem1_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
      return;
      }
      public void jMenuItem2_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
      System.exit(0);
      }
      public static void main(java.lang.String[] args) {
      try {
      PopupOnWindow aPopupOnWindow;
      aPopupOnWindow = new PopupOnWindow();
      aPopupOnWindow.setVisible(true);
      } catch (Throwable exception) {
      System.err.println("Exception occurred in main() of javax.swing.JWindow");
      exception.printStackTrace(System.out);
      }
      }
      }
      (Review ID: 85192)
      ======================================================================

            peterz Peter Zhelezniakov
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: