|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionSometimes
during development of a project a need arises - components, by their
default implementation, do not have the functionality to meet the requirements
of the project. Because of this fact, developers have to extend given
components in order to bring them into a form which will match their needs. An
example of such a problem that occurs quite often is the customization of the
tabbed pane ( As a result,
you have to extend the Using the codeYou can avoid
such a problem by using another quite simple solution, compared to an overall custom tabbed pane creation. All you have to do is add a listener to
the standard tabbed pane, extended from the public class CloseTabbedPane extends JTabbedPane{
private TabCloseUI closeUI;
public CloseTabbedPane(){
addTab("TAB 1 ", new JPanel());
closeUI = new TabCloseUI();
closeUI.setTabbedPane(this);
addMouseMotionListener(closeUI);
addMouseListener(closeUI);
}
public void paint(Graphics g){
super.paint(g);
closeUI.paint(g);
}
}
Here you can see that in order to give your tabbed pane closing capability all you need to do is just
use Points of InterestThe interesting part of this project is that it was written without diving into the tabbed pane implementation, while achieving the desired functionality.
|
||||||||||||||||||||||