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

JTextPane in JCheckBoxMenuItem first action not displayed

XMLWordPrintable

    • kestrel
    • x86
    • generic
    • Verified



      Name: vr73486 Date: 11/04/99

      To reproduce bug:
      Compile and run jCheckBoxMenuItem.java on any windows platform
      Choose a CheckBoxMenuItem from Menu and click it
      Note that No text is displayed in TextPane
      Choose another (or same) CheckBoxMenuItem again and click it
      Note that the first and second actions are now displayed in TextPane

      Close jCheckBoxMenuItem application then run it again
      Choose a CheckBoxMenuItem from Menu and click it
      Note that No text is displayed
      Maximize (resize) appplication frame window
      Note that text is displayed in TextPane

      ---------------
      /* Copyright (c) Sun Microsystems 1998

      $Header: /home/sun/src/JDK1.2/jCheckBoxMenuItem.java,v 1.8 1999/09/26 10:17:57 isam Exp $

      */

      import java.awt.*
      import java.awt.event.*
      import javax.swing.*
      import javax.swing.border.*

      public class jCheckBoxMenuItem extends JApplet
      {
        public void init()
        {
                      
              jCheckBoxMenuItem1 example = new jCheckBoxMenuItem1 ()
              example.pane = new JTextPane()
              example.pane.setPreferredSize(new Dimension(250, 250))
              example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED))
              getContentPane().add(example.menuBar, BorderLayout.NORTH)
              getContentPane().add(example.pane, BorderLayout.CENTER)

        }

              public static void main(String[] argv)
              {
                      jCheckBoxMenuItem1 example = new jCheckBoxMenuItem1 ()
                      example.pane = new JTextPane()
                      example.pane.setPreferredSize(new Dimension(250, 250))
                      example.pane.setBorder(new BevelBorder(BevelBorder.RAISED))
                      JFrame frame = new JFrame("\u0645\u062b\u0627\u0644")
                      frame.getContentPane().add(example.menuBar, BorderLayout.NORTH)
                      frame.getContentPane().add(example.pane, BorderLayout.CENTER)
                      frame.pack()
                      frame.setSize(200,300)
                      frame.setVisible(true)
              }
      }

      class jCheckBoxMenuItem1 extends JPanel implements ActionListener
      {
              public JTextPane pane
              public JMenuBar menuBar
              public JToolBar toolBar

              public jCheckBoxMenuItem1()
              {
                      super(true)
                      menuBar = new JMenuBar()
                      JMenu justifyMenu = new JMenu("\u0645\u062b\u0627\u0644\u0020\u05d3\u05d2\u05de\u05d4")
                      justifyMenu.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16))
                      justifyMenu.setMnemonic('J')

                      JCheckBoxMenuItem leftJustify = new JCheckBoxMenuItem("\u0647\u0630\u0647\u0020\u0633\u0646\u0629\u0020\u0661\u0669\u0665\u0668\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0020\u0031\u0039\u0035\u0038")
                      leftJustify.setHorizontalTextPosition(JMenuItem.LEFT)
                      leftJustify.setMnemonic('L')
                      leftJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16))
                      leftJustify.addActionListener(this)

                      
                      JCheckBoxMenuItem rightJustify = new JCheckBoxMenuItem("\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038")
                      rightJustify.setHorizontalTextPosition(JMenuItem.LEFT)
                      rightJustify.setMnemonic('R')
                      rightJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16))
                      rightJustify.addActionListener(this)

                      JCheckBoxMenuItem centerJustify = new JCheckBoxMenuItem("\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd")
                      centerJustify.setHorizontalTextPosition(JMenuItem.LEFT)
                      centerJustify.setMnemonic('C')
                      centerJustify.addActionListener(this)
                      centerJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16))

                      justifyMenu.add(leftJustify)
                      justifyMenu.add(rightJustify)
                      justifyMenu.add(centerJustify)

                      menuBar.add(justifyMenu)
                      TitledBorder titled = new TitledBorder("\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd")
                      menuBar.setBorder(titled)
                      leftJustify.setBorder(titled)
                      rightJustify.setBorder(titled)
                      centerJustify.setBorder(titled)
              }

              public void actionPerformed(ActionEvent e)
              {
                      try { pane.getStyledDocument().insertString(0 ,
                              "Action ["+e.getActionCommand()+"] performed!\n", null)
                      }
                      catch (Exception ex) { }
              }

      }


      WorkAround:
      ======================================================================

            bcbeck Brian Beck (Inactive)
            vrosenmasunw Victor Rosenman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: