Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java Problems

Started by nihonlvr Apr 1, 2006 at 10:26 AM 0 replies 600+ views
Original Post
nihonlvr
nihonlvr
I am pretty new to Java and am having a difficult time working with JComponents. What I am trying to do is create a class that creates a JPanel object that is 50 pixels by 50 pixels and sets the background color to black. Can anyone point me in the right direction?
gcs584
gcs584
    import java.awt.*;    import javax.swing.*;    //...    JPanel drawingArea = new JPanel();    drawingArea.setPreferredSize(new Dimension(400, 0));    drawingArea.setBackground(Color.black);


As Sun's Java tutorial page on layout managers states:
"Or you can create a subclass of the component that overrides the appropriate getter methods — getMinimumSize, getPreferredSize, and getMaximumSize."

But remember: "Many layout managers don't pay attention to a component's requested maximum size. However, BoxLayout and SpringLayout do."

Regards,

GCS584

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.