• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bold?  RSS feed

 
Graham Robinson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, does anyone know how to print bold text on a drawing window?

This is how i'm printing the text

Text hello = new Text ("Hello", 140, 275);
hello.drawOn(d);

cheers
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "drawing window"? Or more specifically, what is this Text class you are using? This is not from the standard library, so we won't be much help without knowing what methods are available with this class. Also what is d? Can you please post the declaration for this variable?

Layne
[ December 13, 2005: Message edited by: Layne Lund ]
 
Graham Robinson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you would import DrawingWindow. Pretty standard as far as i know.

// construct a drawing window object
DrawingWindow d = new DrawingWindow(290, 400);
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are a student at the Robert Gordon University at Aberdeen, yes? And perhaps you're using the book "Java Elements: Elements of Java for the Principled Programmer" as a text? This "DrawingWindow" of which you speak is part of the "elements" package distributed with that book; it's intended to allow you to do some drawing without actually learning the standard Java APIs (an educational philosphy with which I can't personally say I agree.) From the book:


Java is, at best, a difficult language to learn if one must dive head first. The package used with this text, the element package is responsible for insulating students from the difficulites of using the AWT (Abstract Windowing Toolkit) from day one. Still, the design of the package is such that students who learn Java by using the package will not be left high-and-dry once they must turn to direct use of the AWT.

The element package provides several items:

1. A class that supports a window for generic drawing.
2. A class that supports, in a consistent manner, a window for performing input and output.
3. A heirarchy of classes that support graphics in a drawing window.

The latter feature is supported with a small set of graphics primitives, including Point, Line, Circle, Rect, and others. Each implements an interface, Drawable, which may be implemented by the programmer to extend the features and capabilities of the element package itself. For example, the text spends some time discussing the implementation of a class to draw Triangles and Squares.


In any case, here is some documentation for the elements package. If it's not in there, then you can't do it. Of course it's possible in the standard Java API, but as you're not using that, this knowledge is of no use to you.
 
Graham Robinson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just using this,

http://www-users.cs.york.ac.uk/~bernat/ptc/element/doc/element/DrawingWindow.html

ah, so they use the same book, no i don't have that book.
[ December 13, 2005: Message edited by: Graham Robinson ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!