Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Change font color and size

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Change font color and size

    i need help with my code, i need to change the font,the color and the 0.0 on top need to be right aligned
    import java.awt.*;
    import java.awt.Color;
    public class Calculator
    {
        Frame f;
        TextField tf;
     
        Button  b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16;
        Panel west, center;
     
        public void makeCALC()
        {
            f = new Frame("Calculate it");
            tf = new TextField("0.0");
     
            b1 = new Button("7");
            b2 = new Button("8");
            b3 = new Button("9");
            b4 = new Button("/");
            b5 = new Button("4");
            b6 = new Button("5");
            b7 = new Button("6");
            b8 = new Button("*");
            b9 = new Button("1");
            b10 = new Button("2");
            b11 = new Button("3");
            b12 = new Button("-");
            b13 = new Button("0");
            b14 = new Button("=");
            b15 = new Button(".");
            b16 = new Button("+");
     
            west = new Panel();
            center = new Panel();
            center.setLayout(new GridLayout(4,4));
            f.add(tf,BorderLayout.NORTH);
            f.add(west,BorderLayout.WEST);
            f.add(center,BorderLayout.CENTER);
     
            center.add(b1);
            center.add(b2);
            center.add(b3);
            center.add(b4);
            center.add(b5);
            center.add(b6);
            center.add(b7);
            center.add(b8);
            center.add(b9);
            center.add(b10);
            center.add(b11);
            center.add(b12);
            center.add(b13);
            center.add(b14);
            center.add(b15);
            center.add(b16);
            f.setSize(500,500);
            f.setVisible(true);
     
     
            Font font = new Font("Verdana", Font.BOLD,40);
            f.setFont(font);
            Color color = new Color("BLUE");
            f.setColor(color);
     
     
            }//end makeGUI()
            public static void main(String args[])
            {
                Calculator theNew = new Calculator();
                theNew.makeCALC();
        }
    }


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: d

    Please use descriptive thread titles. Writing just 'd' is simply lazy! You need to give members a good idea of what the problem is if you want decent replies.

    I have updated it for you this time. I have also moved your thread to the right forum.

    This thread may help you:

    http://www.javaprogrammingforums.com...ize-color.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Change font color and size

    thanks am new at this thanks for the help,