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

Line drawn through TitledBorder

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.2.1, 1.2.2
    • Fix Version/s: 1.3.0
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic, x86
    • OS:
      generic, windows_98, windows_nt

      Description



      Name: vi73552 Date: 06/02/99


      Creating a TitledBorder with another Border and Font, the background
      of the title text is transparent.

      I tried to unassign the font, that is, only set Border and this works ok.

      With jdk1.2.1 works fine.

      Source for a simple test:

      /*
      TestTitledBorder.java
      */

      import java.awt.Dimension;
      import java.awt.Font;
      import java.awt.Toolkit;

      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;

      import javax.swing.BorderFactory;
      import javax.swing.JFrame;
      import javax.swing.JPanel;

      import javax.swing.border.TitledBorder;

      public class TestTitledBorder extends JFrame
      {
      static final int WIDTH = 300;
      static final int HEIGHT = 200;

      TestTitledBorder()
      {
      super("TitledBorder Test");

      addWindowListener(new TestCloser());

      Font fontPanel = new Font("Dialog", Font.PLAIN, 12);

      JPanel northPanel = new JPanel(true);
      northPanel.setBorder(
      BorderFactory.createTitledBorder(
      BorderFactory.createEtchedBorder(),
      "North Panel Title",
      TitledBorder.DEFAULT_JUSTIFICATION,
      TitledBorder.DEFAULT_POSITION,
      fontPanel
      )
      );

      JPanel centerPanel = new JPanel(true);
      centerPanel.setBorder(
      BorderFactory.createTitledBorder(
      BorderFactory.createEtchedBorder(),
      "Center Panel Title"
      )
      );

      getContentPane().add("North",northPanel);
      getContentPane().add("Center",centerPanel);
      pack();

      Dimension screenSize =
      Toolkit.getDefaultToolkit().getScreenSize();
      setSize(WIDTH, HEIGHT);
      setLocation(screenSize.width/2 - WIDTH/2,
      screenSize.height/2 - HEIGHT/2);
      show();
      }

      public static void main(String args[])
      {
      new TestTitledBorder();
      }

      class TestCloser extends WindowAdapter
      {
      public void windowClosing(WindowEvent e)
      {
      System.exit(0);
      }
      }
      }
      (Review ID: 83810)
      ======================================================================

      Name: vi73552 Date: 06/02/99


      This paints the etching right through the border title
      using jdk1.2.2. Works fine using jdk1.2.1.
      I am using windows 98 (unfortunately). happens with
      metal L&F and Windows L&F.

      import javax.swing.*;
      import java.awt.Container;
      import javax.swing.border.TitledBorder;
      import java.awt.Font;
      import java.awt.Color;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      class jdk1_2_2Bug
      {
          public static void main(String[] args)
          {
              JFrame jframe=new JFrame();
              Container container=jframe.getContentPane();
              JPanel jpanel=new JPanel();
              jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.X_AXIS));
              JLabel jlabel=new JLabel("Buggy titled border");
              jpanel.add(jlabel);
              container.add(jpanel);
              jpanel.setBorder(BorderFactory.createTitledBorder(null,
                jlabel.getText(),
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                new Font("Default", Font.PLAIN, 11), Color.black));
              jframe.pack();
              jframe.show();
              jframe.addWindowListener(new WindowAdapter()
              {
                  public void windowClosing(WindowEvent we)
                  {
                      System.exit(0);
                  }
              });
          }
      }
      (Review ID: 83773)
      ======================================================================

      Name: vi73552 Date: 06/23/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: 84624)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              svioletsunw Scott Violet (Inactive)
              Reporter:
              vasya Vassili Igouchkine (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: