Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
PopupMenu In JTabbedPane
Isaac Hewitt
Ranch Hand
Posts: 191
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello everyone,
I have a JTabbedPane and I would like to know if it is possbile to insert a PopupMenu in that small background area just above and to the right of the tabs (there are only 2 tabs). Do I have to go through the JTabbedPane UI ? Thanks.
Rob Camick
Rancher
Posts: 3324
32
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Customizing the UI would be the proper way.
For a hack you can try:
import java.awt.*; import javax.swing.*; import javax.swing.plaf.*; public class TabbedPaneWithComponent extends JFrame { public TabbedPaneWithComponent() { JPanel panel = new JPanel(); panel.setLayout( new OverlayLayout(panel) ); add(panel); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("1", new JTextField("one")); tabbedPane.add("2", new JTextField("two")); tabbedPane.setAlignmentX(1.0f); tabbedPane.setAlignmentY(0.0f); JCheckBox checkBox = new JCheckBox("Check Me"); checkBox.setOpaque( false ); checkBox.setAlignmentX(1.0f); checkBox.setAlignmentY(0.0f); System.out.println(checkBox.getInsets()); panel.add( checkBox ); panel.add(tabbedPane); add(new JTextField(10), BorderLayout.NORTH); } public static void main(String args[]) { TabbedPaneWithComponent frame = new TabbedPaneWithComponent(); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setLocationRelativeTo( null ); frame.setVisible(true); } }
Isaac Hewitt
Ranch Hand
Posts: 191
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Great. Thanks for this example. I compiled it in NetBeans and I think I could possibly have a Popup menu in place of the checkbox.
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Patterns for GUI-building ?
Unable to display JScrollPane when added to a JTabbedPane(Plz SEE THIS)
Rearrange Tabs via Drag and Drop
JTabbedPane & Popup Menu
keyboard shortcuts to move between tabs inJTabbedPane
More...