Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


[java] JApplet - Painting and Swing

This topic is 5485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am currently developing a chess-applet. The idea is that I have a browser window which contains the chess-board, a move list and an analysis part. Something like this: ***.. ***.. ***.. ||||| ||||| (where * is the board, . the move list, and | the analysis). Now, I can manually draw the board and its pieces using the "paint(Graphics g)" method of the JApplet class. The move-list and analysis window could easily be done by using swing components. But how can I combine the manual drawing painting with the components? I have added a JTextArea (just to test it) and it is always painted on top of the board (I mean: I''ve used a BorderLayout and told the component to be placed EAST -- how can it be, that it is still drawn on top of the board?) Any clues? Am I missing something very basic or is there a larger problem? Do I have to assign a JPanel to each of the three "windows" (including my manual painted chess board)? Greetings, Beren

Share this post

Link to post
Share on other sites
If the JTextArea is the only component you added, it may appear that is at the top. For what you are doing, you need to extends JPanel in a custom class and then override paint(). Then you add your custom JPanel to the CENTER, and your other components to the SOUTH and EAST. You will also have to have size detection code in your custom JPanel so you can draw the full chess board. Or override getPreferredSize(),getMinimumSize(),getMaximumSize() to return the size you want to make it.

First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!