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

TitledBorders do not render correctly with TitledBorder.DEFAULT_POSITION

XMLWordPrintable



      Name: dbT83986 Date: 03/31/99


      When using a TitledBorder, if the position is given as TitledBorder.DEFAULT_POSITION, or as 0, the border is drawn through the text,
      providing a "strike through" appearance. With other positions, such as TitledBorder.CENTER, the line is not visible in the location
      where the text is drawn.

      To see this problem, you can modify the SwingSet (I used ButtonPanel.java); change one of the TitledBorders to use a position of
      TitledBorder.DEFAULT. For the first button, use:

      Border buttonBorder = new TitledBorder(null, "Text Buttons",
      TitledBorder.LEFT,
                              TitledBorder.DEFAULT_POSITION,
      swing.boldFont);

      Examine the display when running. When running with jdk 1.2.1-K, the text has the border drawn through the text. When running
      with jdk 1.2FCS, the border is not drawn where text is present.

      One additional thing to note --- the border is drawn closer to the text with jdk 1.2.1-K than with jdk 1.2FCS. Was this intentional?
      (Review ID: 56332)
      ======================================================================

      Name: krT82822 Date: 08/13/99


      I use the instance of JPanel with such border:
      TitledBorder titledBorder = new TitledBorder( newEtchedBorder( EtchedBorder.LOWERED ), "My Title", 0, 0, new Font("TimesRoman", 1, 11), Color.blue );

      In all jdks I used ( 1.1.6 - 1.1.8 with jfc1.1beta1; 1.2.1 )everything looks good but in jdk1.2.2 etched line is visible under the title.

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

      public class borderTest extends JApplet
      {
      boolean isStandalone = false;
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
           TitledBorder newBorder = new TitledBorder( new EtchedBorder(
           EtchedBorder.LOWERED ), "Add any component here", 0, 0, new Font("TimesRoman", 1, 11), Color.blue );

      //Construct the applet
         public borderTest()
      {
      }

      //Initialize the applet
         public void init()
      {
      try
      {
      jbInit();
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      }

      //Component initialization
         private void jbInit() throws Exception
      {
      this.setSize(new Dimension(392, 325));
      this.getContentPane().add(jPanel1, BorderLayout.CENTER);
      jPanel1.add(jPanel2, null);
      jPanel1.setLayout(null);
      jPanel2.setBorder(newBorder);
      jPanel2.setBounds(new Rectangle(29, 32, 331, 118));
      }

      //Get Applet information
         public String getAppletInfo()
      {
      return "Applet Information";
      }

      //Get parameter info
         public String[][] getParameterInfo()
      {
      return null;
      }

      //Main method
         public static void main(String[] args)
      {
      borderTest applet = new borderTest();
      applet.isStandalone = true;
      JFrame frame = new JFrame();
      frame.setTitle("Applet Frame");
      frame.getContentPane().add(applet, BorderLayout.CENTER);
      applet.init();
      applet.start();
      frame.setSize(400,320);
               frame.addWindowListener(new java.awt.event.WindowAdapter()
               {
               public void windowClosing(WindowEvent e)
                   {
               System.exit( 0 );
                   }
               });
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
      frame.setVisible(true);
      }
      // static initializer for setting look & feel
      static
      {
      try
      {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      }
      catch (Exception e) {}
      }
      }
      (Review ID: 93902)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: