Results 1 to 4 of 4

Thread: Layout manager for Swing Components in JAVA

  1. #1
    Join Date
    Apr 2008
    Posts
    242

    Layout manager for Swing Components in JAVA

    Hello friends , I am a student studying in the final year , i have a project this year ,first I was coding my project in the VB.net , I was successfully able to create the GUI of the project and all the required forms , but later on in the coding part it came up with some errors in it , so I switched my language and opted Java instead . I was being assured by my elder that it will be wise to use Java language , I have created the GUI but do not how to use the layout of my swing components , please help in this subject as it is taking me a lot of time.

  2. #2
    Join Date
    May 2009
    Posts
    637

    Re: Layout manager for Swing Components in JAVA

    There are a lots of layout manager available, it depends upon the type of components you use in your program , if you are using the simple buttons and text boxes , it is advisable that you use the flow layout , or else you can use the Border layout as well . But I do not know why many people now a days make use of Null layout, in which they pass the x and y co-ordinates of the of the components in order to place them in the exact location.

  3. #3
    Join Date
    May 2009
    Posts
    511

    Re: Layout manager for Swing Components in JAVA

    A layout manager is an object that generally deplyes and implements the LayoutManager interface and decides the size and location of the components inside a container. Although components can give size and position hints, a container's layout manager has the concluding say on the size and location of the components inside the container.

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Layout manager for Swing Components in JAVA

    As a regulation, the lone containers whose layout managers you require to concern about are JPanels and content panes. Every JPanel object is initialized to make use of a FlowLayout, if not you mention another way when creating the JPanel. Content panes make use of BorderLayout by default. If you are not fond of the default layout manager that a panel or content pane uses, you are permitted to modify it to a diverse one. However, if you are not using JToolBar, the FlowLayout and BorderLayout managers are just helpful for prototyping. Any actual application will require to reset the layout manager. Again, you must make use of an suitable tool to do this, rather than coding the manager by yourself.
    You can set a panel's layout manager use the JPanel constructor. For example:
    Code:
    JPanel panel = new JPanel(new BorderLayout());

Similar Threads

  1. Java SWING Components - Table Models
    By Isiah in forum Software Development
    Replies: 5
    Last Post: 21-07-2010, 01:34 AM
  2. How to use HTML in Swing Components?
    By Silent~Kid in forum Software Development
    Replies: 4
    Last Post: 12-02-2010, 03:55 AM
  3. Print in java using Swing
    By Sheenas in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 09:50 AM
  4. drawPolygon in java Swing?
    By JagdishP in forum Software Development
    Replies: 3
    Last Post: 07-08-2009, 11:33 PM
  5. Message Box example for Java Swing
    By Visala28 in forum Software Development
    Replies: 3
    Last Post: 31-07-2009, 05:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,578,303.14689 seconds with 17 queries