Ryan O'Mara wrote:
Andrea, andbin.dev — SCJP 5 (91%) – SCWCD 5 (94%)
java.util.function Interfaces Cheat Sheet — Java Versions Cheat Sheet
Paul Clapham wrote:And once you have made a Font object from the input data, you'll need to call setFont() on the Graphics object. It's best to do that in the paintComponent() method -- in fact, it's best to call the drawText() method from paintComponent() as well.
Oh... I see you haven't overridden paintComponent(). You should be overriding the JPanel's paintComponent() method with the code you have in your paintScreen() method. You shouldn't be drawing on the JPanel from your code, you should be drawing from Swing's code. That would be Swing's paintComponent() method. Hopefully the code you posted wasn't based on what you were taught in the course!
By the way, you mentioned that the user would be typing a "font style". That means one of BOLD, ITALIC, or PLAIN... so having the user type one of those things would be sort of clumsy. Choosing from a JList would be more convenient for the user. Or did you mean for the user to type a font name, like Helvetia or Comic Sans?
Yes that is the way we have been taught
Paul Clapham wrote:Extending JFrame and then ignoring that and creating a new JFrame to use for the GUI is another faux pas in that code. Not to mention having the main class implement ActionListener, instead of creating an ActionListener object where it's actually needed; people realized that composition was preferable to inheritance in this case well over a decade ago.
Is there anywhere on the internet to learn the other way?
Ryan O'Mara wrote:we have been using the book Java for students
The authors wrote:We wanted to make sure that the fun element of programming was paramount, so we use graphics right from the start. We think graphics is fun, interesting and clearly demonstrates all the important principles of programming.
. . . a link for ppt files for instructors. These have the same abomination for chapter 3.Brian Cole wrote:. . . I found a table of contents for the 5th edition . . . There are also downloadable code examples and. . .
Campbell Ritchie wrote:Do they also teach people to use addActionListener(this)? Another
If you have all your components as local variables, at least that can't happen without your knowing it. Another argument for not writingStephan van Hulst wrote:. . . you can add your form as an action listener on a button on a completely unrelated form . . .
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Well, I've used the'direct drawing method' myself a couple of times, with excellent result,
Piet Souris wrote:Well, I've used the'direct drawing method' myself a couple of times, with excellent result, I used 'implements ActionListener' myself in the past, and it was only about 4 years ago that I learned about the EDT. I wonder how I survived all this.
You obviously prefer people to get paid for teaching wrong programming practicePiet Souris wrote:. . . tearing a book apart without knowing much about the context, need I go on? . . .
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |