Solved

Setting color and fonts

Posted on 1998-09-04
1
208 Views
Last Modified: 2013-12-03

 I have created a window that opens up when a button is
 clicked in my applet.It has a textarea, a label and
 2 buttons.How do i set different fonts and color to each
 of these buttons and textarea?
 
0
Comment
Question by:kans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
sailwind earned 10 total points
ID: 1223593

Let's say you have:

TextArea ta = new TextArea();
Label label = new Label();
Button button1 = new Button();
Button button2 = new Button();

You can set the font by doing:

Font f1 = new Font(name1, style, size);
Font f2 = new Font(name2, style, size);
Font f3 = new Font(name3, style, size);

ta.setFont(f1);
label.setFont(f2);
button1.setFont(f3);

You can set the color by:

ta.setForeground(Color.red);
label.setForeground(Color.blue);
button1.setForeground(Color.yellow);
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SequenceInputStream example 3 32
Crystal Reports Licensing Questions 4 80
spring maven example issues 3 88
junit initializtion error 2 16
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question