SwingJD project: CollapsablePanel

Posted by Unknown Saturday, December 8, 2012 0 comments

20121206Thursday, December 06, 2012

SwingJD project: CollapsablePanel

· CollapasablePanel is a Java Swing custom element that collapses/expands the upper and lower arrow clicks.CollapsablePane (10K)
The CollapasablePane is basically 2 parts.
1) TopPanel
2) ContentPanel

HeadingPanel (4K)


This is a custom JPanel.
Is simple stretching and JPanel replaces the paintComponent method.
public class extends JPanel TopPanel;
All logic associated with the HeadingPanel is under the
@ Override
{public void paintComponent (Graphics g)
Graphics2D g2d = g. create () (Graphics2D);
g2d. setRenderingHint (KEY _ANTIALIASING, RenderingHints.
RenderingHints. VALUE_ANTIALIAS_ON);
createPanelImage ();
g2d. drawImage (panelImage, null, 0, 0);
}
Things to do in paintComponent method ()
o create a table image
/**
* Creates the image of the table.
*/
{private void createPanelImage ()
panelImage = new BufferedImage (getWidth (), getHeight (),

BufferedImage. TYPE_INT_ARGB);
Graphics2D g2d = panelImage. createGraphics ();
g2d. setRenderingHint (KEY _ANTIALIASING, RenderingHints.

RenderingHints. VALUE_ANTIALIAS_ON);
g2d. setRenderingHint (java. awt. RenderingHints. KEY _TEXT_ANTIALIASING,
java. awt. RenderingHints. VALUE_TEXT_ANTIALIAS_ON);
drawShape (g2d);
} ·
Draw the shape of the table o
Background design and exterior rectangle
{private void drawShape (Graphics2D g2d)
int width = getWidth ();
int pnlHght = 30;
//Draw background and outer rectangle
If (themeType. equals ("GLOSSY")) {
contentPanel. setBorder (new LineBorder (new color (0, 0, 0, 50)));
g2d. setPaint (bgColor);
g2d. fillRect (0, startPoint, width, pnlHght);
g2d. setPaint (gradientPaint);
g2d. fillRect (2 + 2, startPoint, width-4, pnlHght/2);
g2d. setColor (new color (0, 0, 0, 150));
g2d. drawRect() (0, startPoint, width-1, pnlHght-1);
g2d. setColor (new color (255, 255, 255, 100));
g2d. drawRect() (1 + 1, startPoint, width-3, pnlHght-3);
} else {
g2d. setPaint (gradientPaint);
g2d. fillRect (0, startPoint, width, pnlHght);
g2d. setPaint (new color (50, 50, 50, 150));
g2d. drawRect() (0, startPoint, width-1, pnlHght-1);
g2d. setPaint (new color (255, 255, 255, 50));
g2d. drawRect() (1 + 1, startPoint, width-3, pnlHght-3);
}
}
o create the up/down arrow icon based isCollapsed status
To go for more information and source code to make the link below
CollapsablePanel

CollapsablePanel (51K)


GlossyCollapsablepanel1 (156K)
GlossyCollapsablepanel3 (159K)

For more information and source code click on the following link

Posted by Jeeru (Dec 06, 2011, 10: 55: 18 AM EST) Permalink


View the original article here

THANK YOU FOR YOUR VISIT
Title: SwingJD project: CollapsablePanel
Posted By Unknown
Blog Rating 5 dari 5
Hopefully this article useful to you. If you wish to quote, either part or all of the contents of this article please include a "dofollow links" to http://izone2.blogspot.com/2012/12/swingjd-project-collapsablepanel.html. Thank you for reading our articles and continue to follow this blog article.

0 comments:

Post a Comment

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of Info Zone.