Butaca
Butaca

Reputation: 426

Bypass layout for a component in Swing without null layout

Is there a way to bypass the layout manager for a given component in Swing? Something similar to position="absolute" in CSS. Null layout is not an option.

I have an existing GUI which I can't modify and uses different kinds of layouts and I need to add a button a the top right corner of the screen.

Upvotes: 1

Views: 94

Answers (1)

Matt McHenry
Matt McHenry

Reputation: 20929

If you can't modify the existing GUI, including the top-level containing JFrame, you might be out of luck.

If you can modify the root container, you can achieve what you want with a layered pane. You can put your existing JTabbedPane in a lower layer, and add your button on a higher layer (and there you can use a null layout + setLocation()).

Upvotes: 2

Related Questions