aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Regarding status bar resizing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Regarding status bar resizing" Watch "Regarding status bar resizing" New topic
Author

Regarding status bar resizing

ashok kandaswamy
Greenhorn

Joined: Aug 19, 2008
Posts: 16
hi ,

In Jframe ,i have designed status bar-inside status bar .i have added three panels and with respect to the frame size i am resizing the status panel with matching to the current frame size.(for that i am hide some panels and display the most prioritized one).it will works very fine..

with Componentlistener-ComponentRersized event...but it works only when resizing the frame with by dragging that horizontally or vertically and release the mouse.
But what i want is ....
if we can dragging the frame to reduce the size for that time concurrently the status bar also resizing .....

and am tried this also ,
Toolkit tk = baseFrame.getToolkit();
if (tk.isFrameStateSupported(JFrame.ICONIFIED)) {
statusBarResizing(frameWidth);
}
if (tk.isFrameStateSupported(JFrame.MAXIMIZED_VERT)) {
statusBarResizing(frameWidth);
}
if (tk.isFrameStateSupported(JFrame.MAXIMIZED_HORIZ)) {
setDynamicLayout(true);
}
but this also works after dragging.....

for that i had tried all the listeners event but nothing supports the concurrent resizing on both... ? ? ? ?

so what i want to do .....? please help me ....

Thanks in advance...
Ashok.....


Sk.Ashokkumar.....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

"s.k.a.k.",

Please read your private messages regarding an important announcement.

Thank you,

Rob


As for your problem, why not just use the default BorderLayout, and position your status bar using BorderLayout.SOUTH? It will then keep its preferred height, but the width will be whatever the width of the frame is.
You can't add components to the frame using BorderLayout.WEST or EAST though since those have precedence. The drawing order in BorderLayout:
- WEST and EAST go first, with their preferred width and frame height
- NORTH and SOUTH go next, with their preferred height and remaining frame width
- CENTER goes last, taking up all remaining space


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
ashok kandaswamy
Greenhorn

Joined: Aug 19, 2008
Posts: 16
Originally posted by Rob Prime:
"s.k.a.k.",

Please read your private messages regarding an important announcement.

Thank you,

Rob


As for your problem, why not just use the default BorderLayout, and position your status bar using BorderLayout.SOUTH? It will then keep its preferred height, but the width will be whatever the width of the frame is.
You can't add components to the frame using BorderLayout.WEST or EAST though since those have precedence. The drawing order in BorderLayout:
- WEST and EAST go first, with their preferred width and frame height
- NORTH and SOUTH go next, with their preferred height and remaining frame width
- CENTER goes last, taking up all remaining space


Thank you....

But for that also some confusion will be....

when the size of the frame is reduced somewhat..we want to compare the preferred and changed size of the component and if it is less we want to hide that and resize the remaining components to the current frame size.....(inside the status bar panel)....

is this thing also possible if we handle all the things with border layout..? ? ? ? ? ? ? ? ? ......
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Yes it is. This exactly what layout managers like BorderLayout are for.

And please read your private messages ASAP. The issue is still not fixed correctly.
[ August 19, 2008: Message edited by: Rob Prime ]
ashok kandaswamy
Greenhorn

Joined: Aug 19, 2008
Posts: 16
Originally posted by Rob Prime:
Yes it is. This exactly what layout managers like BorderLayout are for.

And please read your private messages ASAP. The issue is still not fixed correctly.

[ August 19, 2008: Message edited by: Rob Prime ]

hi Rob,
i have changed my name .please noted it out....

hi thank you.....okay..,..but what my issue is.....

please tell how can i implement it with border layout......(i can do but the result is not came properly..as of now....)
that's y am confused...am very new to layout concepts..
the following method i have used for Resizing the inner components of the stausbar..according to framesize.....

please anybody tell how can archive the live resizing.....? ?
if that is possible with border layout means..! HOW CAN...?

public int statusBarResizing(int Width) {

//GET THE CURRENT WIDTH AND HEIGHT......
int frameWidth = baseFrame.getWidth();
System.out.println(frameWidth);

int frameHeight = baseFrame.getHeight();
System.out.println(frameHeight);

scrollPaneHeight = frameHeight - statusPanelHeight;
stausPanel.setBounds(0, scrollPaneHeight, frameWidth, 110);
stausPanel.setVisible(true);
sp.setBounds(0, 0, frameWidth - 9, scrollPaneHeight);
mainPanel.setBounds(0, 0, frameWidth, frameHeight);

//CHANGED THE WIDTH FOR EACH PANEL......

changedDescriptionWidth = (frameWidth * 68) / 100;
changedClockWidth = (frameWidth * 10) / 100;
changedPageWidth = (frameWidth * 20) / 100;

int pageStartPoint = (frameWidth * 80) / 100;
int descriptionStartPoint = (frameWidth * 10) / 100;

System.out.println("changedDescriptionSize:" + changedDescriptionWidth);
System.out.println("changedClockSize:" + changedClockWidth);
System.out.println("changedPageSize" + changedPageWidth);

//GET THE PRIORITY BASED ON COMPARE THE PREF SIZE WITH CHANGED SIZE.....

//PRIORITY METHOD.....
public int getPriority() {
int priority = 0;

if (changedDescriptionWidth < prefDescriptionWidth) {
priority = 3;
return priority;
} else if (changedClockWidth < prefClockWidth && changedPageWidth >= prefPageWidth) {
priority = 1;
return priority;
} else if (changedClockWidth < prefClockWidth && changedPageWidth < prefPageWidth) {
priority = 2;
return priority;
}
return priority;

}

int switchPrior = getPriority();
System.out.println("Current Priority:" + switchPrior);

switch (switchPrior) {

case 1: {
describePanel.setVisible(true);
pagingPanel.setVisible(true);
noOfComponentsInStatusPanel--;
clockPanel.setVisible(false);
int changedWidthForResizing = changedClockWidth / noOfComponentsInStatusPanel;
changedPageWidth += changedWidthForResizing;
int changedWidthOfRemainder = (changedClockWidth + changedPageWidth) % noOfComponentsInStatusPanel;
changedDescriptionWidth += (changedWidthForResizing + changedWidthOfRemainder);
descriptionStartPoint = 0;
pageStartPoint = (frameWidth * 80) / 100;

pagingPanel.setBounds(pageStartPoint, 0, changedPageWidth, 100);
describePanel.setBounds(descriptionStartPoint, 0, changedDescriptionWidth, 100);
noOfComponentsInStatusPanel++;
return changedDescriptionWidth;

}
case 2: {
describePanel.setVisible(true);
noOfComponentsInStatusPanel--;
clockPanel.setVisible(false);
pagingPanel.setVisible(false);
int changedWidthForResizing = (changedClockWidth + changedPageWidth) / noOfComponentsInStatusPanel;
int changedWidthOfRemainder = (changedClockWidth + changedPageWidth) % noOfComponentsInStatusPanel;
changedDescriptionWidth += (changedWidthForResizing + changedWidthOfRemainder);
descriptionStartPoint = 0;

describePanel.setBounds(descriptionStartPoint, 0, changedDescriptionWidth, 100);
describePanel.setVisible(true);
noOfComponentsInStatusPanel++;
return changedDescriptionWidth;
}
case 3: {
stausPanel.removeAll();
return changedDescriptionWidth;
}
default:
{
describePanel.setVisible(true);
pagingPanel.setVisible(true);
clockPanel.setVisible(true);
clockPanel.setBounds(0, 0, changedClockWidth, 100);
describePanel.setBounds(descriptionStartPoint + 5, 0, changedDescriptionWidth, 100);
pagingPanel.setBounds(pageStartPoint + 10, 0, changedPageWidth, 100);
}
return changedDescriptionWidth;
}

}

THANKS,
ASHOKKUMAR.K
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60990
    
  65

"ashok", please check your private messages for an important administrative matter. Again.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ashok kandaswamy
Greenhorn

Joined: Aug 19, 2008
Posts: 16
Originally posted by Bear Bibeault:
"ashok", please check your private messages for an important administrative matter. Again.


hi Bear Bibeault,
I will hpoe now i can do it properly....

Thanks,,

Ashokkumar.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60990
    
  65

Please check your private messages once more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding status bar resizing