Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change the shape of Tabs in Tabbed pane to oval

 
Archana Venu Aradhyula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I use a JTabbed pane in my application. I want to change the shape of the tabs to oval or round.Do i need to override the paint method of JTabbed pane?


Thanks
-- Archana
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you will need to dig into the tabbedPaneUI
 
Archana Venu Aradhyula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please help me with the code.
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Archana Venu Aradhyula:
Can you please help me with the code.


Sure. You go first.
 
Archana Venu Aradhyula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to start with.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please dont ask for code... But this is the way it is to be done.
1) First you have to extend BasicTabbedPaneUI
2) Override paintContentBorder() and draw ovals (instead of fillRect as in BasicTabbedPaneUI) and don't call super.paintContentBorder()
3) Override paintTabArea() to draw Ovals or images or whatever.
4) Dont forget to set the UI of your tabbedpane to the new ui class you just made above
Trust me its simple. Just start doing..

cheers, suraj
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple is relative. I'd recommend just finding a Look and Feel that already does it for you. If you are using Java1.6 Nimbus L&F has corner rounded tabs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic