-2

i would ask a question.

WHAT and WHAT are the DIFFERENCE of FLOWLAYOUT and GRIDLAOUT in java.

advantages and disadvantages (if theres).

because my prof says about these terms to build a GUI in java.

and all i know is the JOption.

so what are these terms. thank you. hope anyone help me with these.


i google it , but no luck so this my last resort.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
jarnthrax
  • 146
  • 3
  • 4
  • 11
  • 3
    They are layout managers are that layout components different. Take a look at [A Visual Guide to Layout Managers](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) – MadProgrammer Nov 17 '13 at 01:55
  • There is a description of layout managers in the official Java tutorials, see [here](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html). What exactly is your question? – Robin Krahl Nov 17 '13 at 01:56
  • ahhh.. so those ----layout that create your custom GUI. and the JOptionPane is the predefined GUI. – jarnthrax Nov 17 '13 at 02:01
  • 5
    I'd work on those google skills. – roippi Nov 17 '13 at 02:04
  • `"i google it , but no luck so this my last resort."` -- Amen to @roippi's comment. Simply searching on `java flowlayout gridlayout` brings up the pertinent tutorial as the **first GD hit**. Voting this question for the worst Google skills of the day award. I wouldn't be surprised if it wins the award for the month. Congratulations. – Hovercraft Full Of Eels Nov 17 '13 at 06:05

2 Answers2

3

Straightforward tutorials and examples on both of these can be easily found. I recommend the official ones. Check out:

Both of those links have pictures, summaries, and examples, and are short and easy to read and understand. The other built-in layout managers are described in those tutorials as well. The link that MadProgrammer provided in the comments is also in that document set.

Those are both the first Google results for "FlowLayout" and "GridLayout", respectively.

Jason C
  • 38,729
  • 14
  • 126
  • 182
2

On the chance that what you need is a high-level description (which the tutorials, good and useful as they are, don't always provide):

GridLayout and FlowLayout are both layout managers.

A layout manager positions components within a container (such as a JPanel or a JFrame). Different layout managers do this in different ways, with different rules, for different purposes, but they all have that in common. The idea is that the programmer adds components to a container, and the layout manager determines their position.

Since top-level containers are (most?) often resizable by the end-user, one of a layout manager's primary jobs is to position components according to its rules when the container is larger or smaller than the "natural" size one would get after packing the components. When studying layout managers, this is one of the things you learn to pay close attention to, so that the UI behaves the way you want it to. Believe me, you don't want to write the code to handle all the possible circumstances for resize yourself.

GridLayout has rules that positions the components in a grid where each cell is the same size and all are stretched equally.

FlowLayout has rules for positioning components one after another, horizontally (and maybe vertically, I don't remember offhand), and 'wrapping' them if the container is made too small to contain them.

arcy
  • 12,845
  • 12
  • 58
  • 103