0

I have been working on a GUI for some time, I am required to plot my results in a scatter diagram, the problem is is that I need to create a drawing section to place the results of the GUI on.

What would be the best way to do this ?.

Is there an easier way to go about it while still using null layout ?

Thanks

user1020024
  • 41
  • 1
  • 7
  • 5
    There is no reason you need to use a null layout. Use a proper combination of layout managers and you won't have a problem. – camickr Nov 19 '11 at 23:15

3 Answers3

2

try to put everything into a JPanel and set a layout for that (i.e. a BoxLayout). then you add your diagram JPanel to the main JPanel.

2

Centering a component can be achieved easily using GridBagLayout (one of the few tasks for which I would use GBL). See the code for adding the image in the bottom right of this GUI for details1.

  1. OK, I'll admit, the 'short answer' is:

Add a component as the only component in a GridBagLayout with no constraint & it will be centered. Put the panel using GBL into a JScrollPane, and the job is done.


For a closer look at centering components using different layouts, see this example.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
2

In addition to the layout suggestions, you might find some ideas in this series of scatter plots that rely on .

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045