Results 1 to 9 of 9
- 04-14-2011, 09:19 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
AutoSizing of windows in GridBagLayout is not working
I have placed 4 charts with JFreeChart in a grid layout, but the diagrams are not completly shown :eek:. Somehow there must be an autosizing option available to make sure the diagrams are auto-sized.
I would appreciate any idea - Thanks :confused:
- 04-14-2011, 09:37 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,158
- Rep Power
- 5
Do you use frame.pack() or frame.setSize()? You should be using pack() so that all components will be displayed at their preferred sizes.
- 04-14-2011, 09:53 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Thanks for the advise, but I cannot make it work. The construction I have is: Tabs --> GirdLayout --> Diagram.
I thought I would need to do chartUpdated.pack();, but this option is not availble. Or is there may be another 'add' contructor I can use for the last line code?Java Code:// Creating the tab panel JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setPreferredSize(new Dimension(810, 550)); ... // Creating the first tab JPanel panelMonth = new JPanel(new GridLayout(1, 2, 5, 5)); panelMonth.setPreferredSize(new Dimension(1000, 650)); ... // creating the diagram DashboardChart chartUpdated = new ChartPieUpdated(); ... panelMonth.add(chartUpdated);
- 04-14-2011, 09:57 PM #4
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,158
- Rep Power
- 5
Don't set the preferred size of your compnents. Each component is responsible for determining its own preferred size. The pack() should work properly.panelMonth.setPreferredSize(new Dimension(1000, 650));
Or
- 04-15-2011, 08:03 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
I guess the problem is, since the pack only works on Frames not on Panels. You (or anyone is welcome to) know how to expand this or to work around it?
- 04-15-2011, 03:59 PM #6
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,158
- Rep Power
- 5
There is no problem and there is nothing to work around. YOu add all you components to the frame and then pack() the frame. Its that simple. If it doesn't work you are doing something wrong.
If you need more help then post your Short, Self Contained, Correct Example that demonstrates the problem. And don't post JFreeChart code since that is non standard code.
- 04-15-2011, 09:33 PM #7
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Hello, here is the code I have and I hope that I gave everything, which is required to give you a good impression. Otherwise I am happy to share more code.
tab1.pack(); does not work, there is not such option available. Is there may be something else than new Dimension ... I can write?Java Code:// ----- TAB CONFIGURATION ----- JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setPreferredSize(new Dimension(810, 550)); // --- TAB 1 JPanel tab1 = new JPanel(new GridLayout(1, 2, 5, 5)); tab1.setPreferredSize(new Dimension(1000, 650)); tabbedPane.addTab("Tab1", iconLabelMonth, Tab 1, "Text"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); // Chart in tab1 DashboardChart chart = new ChartPie(); tab1.add(chart);
Thanks for your advise.
- 04-15-2011, 09:41 PM #8
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,158
- Rep Power
- 5
Have you even read my suggestions???
In my second reply I specifically stated NOT to use setPreferredSize().
I asked for a SSCCE. Did you read the link? How is that code compileable?
I specifically mentioned not posting JFreeChart code. DashboardChart and ChartPie, sure like like non standard classes to me.Last edited by camickr; 04-15-2011 at 09:43 PM.
- 04-16-2011, 02:21 PM #9
Member
- Join Date
- Feb 2011
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
Applet is not working properly on windows 7 with java update 23
By Sagar tandale in forum Java AppletsReplies: 1Last Post: 02-19-2011, 08:36 AM -
Under windows, java2d applet is working in eclipse but not in web browser
By tametick in forum Java AppletsReplies: 1Last Post: 08-19-2010, 12:47 PM -
Gridbaglayout not working as expected
By berkeleybross in forum AWT / SwingReplies: 7Last Post: 07-06-2010, 12:11 PM -
Eclipse debug not working on Windows Vista
By mathew.vinay in forum EclipseReplies: 5Last Post: 04-04-2009, 01:06 PM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks