How to change Font in questionPanel

Ask questions and discuss programming issues around Tatool Java.
Locked
mouthonm
Posts: 16
Joined: Fri Aug 31, 2012 8:04 am
Institution: University of Fribourg

How to change Font in questionPanel

Post by mouthonm » Mon Nov 05, 2012 4:41 am

How can I change to a Bold or no Bold font in the questionPannel (text displays to participants) ?

alocher
Posts: 259
Joined: Tue Apr 24, 2012 12:56 pm
Institution: Tatool

Re: How to change Font in questionPanel

Post by alocher » Thu Nov 08, 2012 10:13 am

The existing panels don't support this functionality. You can easily copy an existing panel (e.g. ch.tatool.core.display.swing.panel.CenteredTextPanel) and create your own method similar to the method setTextSize() which could look like this.

Code: Select all

textLabel.setFont(textLabel.getFont().deriveFont(Font.BOLD, textLabel.getFont().getSize()));

a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Re: How to change Font in questionPanel

Post by a.rey-mermet » Sun Nov 23, 2014 10:14 am

Hi!

How can I change the actual font into the font "courier new" in the code given above?

Thanks for the response!
Alodie

cvonbastian
Posts: 185
Joined: Tue Apr 24, 2012 8:22 am
Institution: Bournemouth University

Re: How to change Font in questionPanel

Post by cvonbastian » Mon Nov 24, 2014 12:43 pm

Hi Alodie,

The same applies as in the above reply, in this case you just have to use

Code: Select all

textLabel.setFont(new Font("Courier New"));
You can also add any other formatting that you wish to have using this approach. For example, you can choose to display the text in italics and in font size 12:

Code: Select all

textLabel.setFont(new Font("Courier New", Font.ITALIC, 12));
(Note that this overrides any other text formatting)

Locked

Who is online

Users browsing this forum: No registered users and 1 guest