By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,844 Members | 836 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,844 IT Pros & Developers. It's quick & easy.

Increasing and decreasing the size of swing component on button click

P: 7
hi.........
i have problem in incresing and decreasing the component.

I have a one main panel (i.e. i used as _basewindowPanel) in that again two panel in that two panel like wise....
now when i m increasing the size of component only button and label size get increase.But Jcombobox,JTextfield and table size unchanged.Plz any one help me,here is my code for increasing the size........


public void incPanel(int size)
{
ArrayList<Component> allComponents = new ArrayList<Component>();
Component [] abc = _basewindowPanel.getComponents();
for(int i = 0 ; i<abc.length;i++)
{
if(abc[i] instanceof JPanel)
{
JPanel pn=(JPanel)abc[i];
Component [] panelComponents=pn.getComponents();
for(int j=0;j<panelComponents.length;j++)
{
if(panelComponents[j] instanceof JPanel)
{
JPanel pnInner=(JPanel)panelComponents[j];
Component [] innerPanelComponents=pnInner.getComponents();
for(int k=0;k<innerPanelComponents.length;k++)
{
int x1 = pnInner.getComponent(k).getBounds().x;
int y1 = pnInner.getComponent(k).getBounds().y;
int w1 = pnInner.getComponent(k).getBounds().width;
int h1 = pnInner.getComponent(k).getBounds().height;
pnInner.getComponent(k).setBounds(x1,y1,w1+size,h1 +size);

}
int x= pnInner.getBounds().x;
int y=pnInner.getBounds().y;
int w=pnInner.getBounds().width;
int h=pnInner.getBounds().height;

pnInner.setBounds(x,y,w+size,h+size);

}

}

}

}

}

value of size is 1.
Jan 9 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.