Results 1 to 3 of 3

Thread: Flow layout

  1. #1
    Shahnawaz is offline Member
    Join Date
    Sep 2011
    Posts
    20
    Rep Power
    0

    Default Flow layout

    can anyone tell how can i make the items listed below to appear in new lines??

    import java.awt.*;
    import javax.swing.*;
    import java.sql.*;

    public class assignmnt {


    public static void main(String[] args)
    {
    JFrame fr1 = new JFrame("Student Database");
    fr1.setBackground(Color.GREEN);
    fr1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
    fr1.setSize(300,300);
    fr1.setLocationRelativeTo(null);
    fr1.setLayout(new FlowLayout());

    //setting form layout:
    JPanel p1 = new JPanel();
    //JLabel m = new JLabel("AUP Student DataBase");
    JLabel rno = new JLabel("R.NO:");
    JLabel name = new JLabel("Name: ");
    JLabel fname = new JLabel("Father Name: ");
    JLabel gpa = new JLabel("GPA: ");
    JTextField rntf = new JTextField(2);
    JTextField ntf = new JTextField(20);
    JTextField fntf = new JTextField(20);
    JTextField gptf = new JTextField(4);
    JButton search = new JButton("Search");
    JButton add = new JButton("Add");
    p1.add(rno);
    p1.add(rntf);

    p1.add(search);

    p1.add(name);
    p1.add(ntf);

    p1.add(fname);
    p1.add(fntf);

    p1.add(gpa);
    p1.add(gptf);

    p1.add(add);

    fr1.add(p1);
    fr1.setVisible(true);
    }

    }

  2. #2
    camickr is online now Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: Flow layout

    If you want to use a FlowLayout, then you need to use multiple panels. Add pairs of components to individual panels and then add these panels to the another panel that uses a BoxLayout.

    Or you can use a GridBagLayout or maybe a SpringLayout.

    See: A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container) for more information.

  3. #3
    Shahnawaz is offline Member
    Join Date
    Sep 2011
    Posts
    20
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 10-03-2011, 03:45 PM
  2. Flow-Charting?
    By danthegreat in forum Forum Lobby
    Replies: 4
    Last Post: 09-12-2011, 06:24 AM
  3. Web Service flow
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-06-2011, 09:56 AM
  4. Custom JButton with flow layout
    By phil128 in forum AWT / Swing
    Replies: 1
    Last Post: 01-17-2011, 10:44 PM
  5. How to generate Data Flow Diagram(Work Flow Diagram)
    By stsivaraj in forum AWT / Swing
    Replies: 1
    Last Post: 12-22-2010, 11:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •