This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How can this be done (lines with panels) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How can this be done (lines with panels)" Watch "How can this be done (lines with panels)" New topic

How can this be done (lines with panels)

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
I need to create a panel that looks something like this:

[] [] [] [] [] | [] [] [] []
[] [] [] [] [] | [] [] [] []

Where the [] will really be boxes and the | and -- marks will be solid lines.

So, I have 4 quadrants with boxes in each seperated by lines. I planned to make each quadrant its own JPanel holding JTextFields (the boxes need to accept text input), but the dividing lines part concerns me.

I know that I can use 2D to draw the lines by overriding paintComponent(), but how can I then position the panels to on top of the drawing?

Is this even possible to do?

Some guidance would be greatly appreciated!

Joe Ess

Joined: Oct 29, 2001
Posts: 9137

Put each quadrant into a JPanel and set each JPanel's border to javax.swing.border.LineBorder. If the lines are two thick, try only setting two quadrants' borders (upper right, lower left). Warning: I am not a graphic designer!

[How To Ask Questions On JavaRanch]
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Thanks Joe...I'll give it a try.

I was thinking it was going to end up being (:eek a 2D solution.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

You could just use a JSeparator;

GenRocket - Experts at Building Test Data
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Have you checked out Aspose?
subject: How can this be done (lines with panels)
It's not a secret anymore!