• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help in understanding basic graphic components.

 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is there anybody around who is willing to help me with Swing basics? I mean I have very basic questions. This is because I have never ever worked or studied graphics/Swing/awt components. If I start asking those questions here, I feel I might flood this forum with questions.

As of now, I only know what a JFrame and a JButton is. I need help in understanding the following.
JComponent, Canvas, Dimension, repaint() method, and Toolkit for now.

Do you have any suggestions on from where to start?

Is there somebody who's around and is not too caught up with his/her work and is willing to help?

Thanks,
Chan.



 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you're a beginner at Swing and want to learn more? Here's where I learned all about Swing: Creating a GUI With JFC/Swing.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, a very, very, very beginner.

And the worst thing is I really don't need to know swing for my next assignment. But I need to know threads and I will have to scale up in advanced thread concepts quickly. And to understand these thread examples in text books, reference books etc, I need to know the basic swing.. ( don't even know if what I need is just basic/advanced stuff).

But ok. I will try to find out more from the link you've posted. Thanks for that.

Actually I don't need to know many things in swing which is why I was trying to see if I could save some time by just getting the specific information on what I needed. But since I don't know the answer to my question, it is possible that my question spans many topics and it might make sense to go through it all from the beginning. That is too much work. . And it seems like there is no other way.


Thanks,
Chan.

 
Bartender
Posts: 5465
212
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chang,

well, if you don't have any time to loose, my suggestion is: draw a GUI on paper, just with the bare minimum
of what you need for these threads to get them working.

Maybe you need a JFrame and a JPanel, and a JButton somewhere and perhaps even a JTextField.
Look up the API's for these things, use a JPanel with FlowLayout and just add the panel to your frame. That's all.

It won't look pretty perhaps, but that's for later.

Greetings,
Piet
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chan Ag wrote:I need help in understanding the following.
JComponent, Canvas, Dimension, repaint() method, and Toolkit for now.


JComponent is the abstract superclass of all Swing components (not top level windows). It doesn't actually contain any abstract methods, so you can create a Jcomponent with new JComponent() {};

Canvas is a legacy AWT class. Use JPanel instead.

Dimension simply encapsulates two int values height and width. (Point also encapsulates two int values x and y and I guess the only justification for the two separate classes is to enhance code readability. Point represents a location, Dimension represents a size.

repaint() method is to be called whenever a state change requires a visual update. There are too many possibilities to list them all, but two examples could be when the text of a JLabel is set or when a value in a JTable cell is changed or a row is added or removed.

Toolkit is well described in the API. If there's anything there that you don't understand, ask about it specifically.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, Darryl, Piet, Paul. I have finally figured this one program that was not letting me proceed further.

I have ignored Toolkit part of the code for now because the programmer has used it to just get a FontMetrics ( a font style I guess) for the custom canvas. The rest of it has become easy after reading up your responses and a bit about repaint() and paintComponent(Graphic obj) methods.

Thank you,
Chan.
 
reply
    Bookmark Topic Watch Topic
  • New Topic