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

Problem with setFont, g.setFont, getFont and g.getFont ...

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: joT67522 Date: 09/16/97


      Problem lies around the setFont method. When invoked it only
      sets the font of the component but not the graphics context of
      the component. I have included the two source files which
      should help you to reproduce the bug.


      /**
       * @author Mohammed Akbar Khan
       */

      import java.awt.Color;
      import java.awt.Component;
      import java.awt.Graphics;
      import java.awt.Font;

      public class G extends Component
      {
          public void update(Graphics g)
          {
              paint(g);
          }

          public void paint(Graphics g)
          {
              g.setColor(Color.black);
              g.drawString("Mohammed Akbar Khan", 10, 10);
          }
      }


      /**
       * @author Mohammed Akbar Khan
       */

      import java.awt.*;
      import java.awt.event.*;

      public class M extends Frame
      {
          public M()
          {
              setBackground(Color.lightGray);
              setTitle("Graphic Button Test");
              setLayout(null);

              String[] strFontList = Toolkit.getDefaultToolkit().getFontList();

              for(int j = 0; j < strFontList.length; j++)
              {
                  System.out.println(strFontList[j] + " = " + j);
              }

              Font gf = new Font(strFontList[1], Font.BOLD, 11);
              System.out.println(gf.toString());

              G gb0 = new G();
              gb0.setSize(200, 200);
              gb0.setLocation(100, 100);
              gb0.setFont(gf);
              add(gb0);

              addWindowListener(new WindowEventClass());
          }

          class WindowEventClass extends WindowAdapter
          {
              public void windowClosing(WindowEvent e)
              {
                  setVisible(false);
                  dispose();
               System.exit(0);
              }
          }

          public static void main(String[] arg)
          {
              Frame f = new M();
              f.setSize(600, 300);
              f.setVisible(true);
          }
      }


      company - Sabre Technology Solutions. , email - Work: ###@###.### Home: ###@###.###
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ehawkessunw Eric Hawkes (Inactive)
                Reporter:
                johsunw Joon Oh (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: