I've been trying to find an alternate means of achieving essentially what JSplitPanes can do, except that the hideous-looking splitter bar would be invisible, and you can resize in both x and y dimensions at the same time.

My current thought is to subclass a JPanel with listeners that implement the behaviors for when the resizing border(s) is (are) mouseovered and dragged. Is this strategy pretty much the way it's usually done in Swing, or is there some sort of a ready-made JResizablePanel that I've somehow missed?


11 Years
Discussion Span
Last Post by nordmann

hi Erik,

I think what you are doing is right by creating a subclass.

Did you try with jSplitPaneInstance.setDividerSize(0) ?



Thank you, Cheenu, for your interesting suggestion. Setting the divider bar does allow the visual effect I want, but unfortunately, it leaves nothing for the mouse to grab, which renders it unresizable through a mouse-drag. I also can find no JScrollPane.setDividerMouseActionWidth(int width) to make the mouse-active area of the divider larger than the divider's visual representation. Maybe I should start looking at subclassing JScrollPane, rather than JPanel. If I can find a way of suppressing the rendering of the divider bar, that would do the trick.

The more I work with Swing, the more it strikes me as detached from the real-world, common-sense issues that applications developers confront in their projects. Sure, you can create a UI that looks and behaves like nothing of this Earth, and drastically alter the entire Look and Feel by changing one line in a configuration file, or even in response to user input at run time. But how often and how much do people care about such exotic capabilities?

On the other hand, if you just want the usual things that everyone expects from a GUI, working the way they expect them to, you have to invent your own widgets. I don't see why it should require extensions to the windowing API to add such mundane features as a resizable navigation panel sitting on the left-hand side of the screen with no ugly divider bars chopping up your UI.

And no, I don't want an MDI app, either. That's way more complexity and extra functionality than my app needs.

I would move over to SWT, but then I couldn't deploy my app as a JApplet.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.