Different fonts in a Form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Different fonts in a Form

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Location
    Finland
    Posts
    52

    Different fonts in a Form

    I'm working with a form and I want to use different fonts. This is my code:


    Code:
    private Font font1, font2;
    
    font1 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
    font2 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
    
    try{
                
                append("Title"+'\n'+"something", Image.createImage ("/pic.PNG"));
                setFont(0, font1);
    
               }catch(IOException e){
                }
    I want "Title" to be font1 and "something" to be font2. Can it be done?

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Have you considered using Canvas instead for different fonts?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Mar 2007
    Location
    Bangalore, India
    Posts
    247
    Hi, by form, do you mean a Frame, like a JFrame or something? If its a Frame or a Panel or some AWT or Swing class, then you could make two different Label objects, and align them one on top of the other. Then you could setFont() them to different forms. Also, most of the swing components accept HTML also. So, instead of JLabel.setText("Heading\ntext");, you could give in JLabel.setText("<html><h2>Heading</h2><p>text</p></html>"); Only thing is it has to start with <html>

Similar Threads

  1. Pseudocode Problem
    By zobi316 in forum VB Classic
    Replies: 3
    Last Post: 03-10-2008, 08:05 AM
  2. Replies: 0
    Last Post: 01-17-2007, 11:38 PM
  3. Replies: 3
    Last Post: 08-09-2005, 01:59 PM
  4. Replies: 0
    Last Post: 04-11-2002, 07:48 PM
  5. Losing control on SetParented form.
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 0
    Last Post: 03-16-2000, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center