Results 1 to 13 of 13
- 10-07-2008, 12:52 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 20
- Rep Power
- 0
- 10-07-2008, 02:00 PM #2
Do you have any code for this project?
- 10-07-2008, 03:13 PM #3
Member
- Join Date
- Jun 2008
- Posts
- 20
- Rep Power
- 0
Sorry I am struggling with starting the execution. I want to know, is there a way to add button to the tabbed pane. In tabbed pane we usually add panels which will display as tabs. I want to add a button in the place where the the tab icon is displayed.
Thank you.
- 10-07-2008, 06:56 PM #4
You can add the button to the panel and then add the panel.
- 10-10-2008, 06:32 AM #5
Member
- Join Date
- Jun 2008
- Posts
- 20
- Rep Power
- 0
Actually I dont need the button in the pannel. I need the button in the tabbed pane itself.
Thank you.
-
This doesn't make sense. Norm (I think) is talking about using a JPanel that is held by the tabbed pane, perhaps BorderLayout.CENTER, so that the JPanel actually becomes the tabbed pane, except for the tab. Are you talking about adding a JButton on the tab itself? Could you go into more detail?Actually I dont need the button in the pannel. I need the button in the tabbed pane itself.
- 10-11-2008, 03:36 AM #7
Does the API doc for tabbed pane have an add() method? What does it say?
- 10-13-2008, 07:02 AM #8
Member
- Join Date
- Jun 2008
- Posts
- 20
- Rep Power
- 0
Sorry! if I confused a lot. Here I have attached a image file which will give you a clear idea of my requirement.
FYI: Norm, the API doc for tabbed pane is having an add(component) method.
Thank you.
- 10-13-2008, 09:56 AM #9
On the Sun forum, you said "Yes, <link snipped/> this page is the answer."
Swing - How to draw a component on a Panel?
Another way is to add the button to the frame's glass pane, with an appropriate layout, and set the glass pane's visibility.Note that GridBagLayout isn't the only layour manager you can use to achieve this.Java Code:public class TabbedPanePlusButton { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new TabbedPanePlusButton().makeUI(); } }); } public void makeUI() { JTabbedPane tabbedPane = new JTabbedPane(); for (int i = 0; i < 3; i++) { JPanel panel = new JPanel(); panel.setName("tab" + (i + 1)); panel.setPreferredSize(new Dimension(400, 400)); tabbedPane.add(panel); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(tabbedPane); frame.pack(); Rectangle tabBounds = tabbedPane.getBoundsAt(0); Container glassPane = (Container) frame.getRootPane().getGlassPane(); glassPane.setVisible(true); glassPane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(tabBounds.y, 0, 0, 15); gbc.anchor = GridBagConstraints.NORTHEAST; JButton button = new JButton("My Button Position"); button.setPreferredSize(new Dimension(button.getPreferredSize().width, (int) tabBounds.getHeight() - 2)); glassPane.add(button, gbc); frame.setLocationRelativeTo(null); frame.setVisible(true); } }
db
- 10-13-2008, 02:30 PM #10
Very nice.
- 10-14-2008, 01:57 PM #11
- 10-15-2008, 06:34 AM #12
Member
- Join Date
- Jun 2008
- Posts
- 20
- Rep Power
- 0
Thank you Darryl,
This is what I expected, very cool.
Thank you.
- 10-15-2008, 08:16 PM #13
Similar Threads
-
Tabbed pane using struts 2.x......?
By prabhurangan in forum Web FrameworksReplies: 1Last Post: 07-19-2008, 06:48 AM -
Creating a tabbed display with a single tab
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:44 PM -
Creating a tabbed display with four tabs and a few controls
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:43 PM -
Layered Pane Demo
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:44 PM -
AWT can we make a Tabbed container?
By Panchitopro in forum AWT / SwingReplies: 0Last Post: 05-15-2008, 10:31 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks