[ Back | Previous | Next ]

Changing Font of Component

Package:
java.awt.*
Product:
JDK
Release:
1.0.2
Related Links:
Color
Cursor
FileDialog
Font
FontMetrics
Frame
general
Image
LayoutManager
Menu
ScrollPane
Comment:
Changing the font of a component is done by Component.setFont() The following example changes the font of a
button. 

  ...
  ...
  Button cancel = new Button("Cancel");
  cancel.setColor( Color.white );
        
  // Get font
  Font font = new Font("Helvetica", Font.PLAIN, 12);
  cancel.setFont( font );
1