Meaningless Drivel is fun!*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8843

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!

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[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: 15299

You could just use a JSeparator;

GenRocket - Experts at Building Test Data
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: How can this be done (lines with panels)
Similar Threads
Manage Layouts in java
Help in GroupLayout
How to prevent AWT component flicker?
Usership of Linux
New ground, making progress, but need some guidance with drawing lines.