Home Answers Viewqa Java-Beginners HOW TO DISPLAY COMPONENTS ROW BY ROW AS A FORM? I want the below program to be modified so that i can get my java application to look like an entry form.. Please help me..

 
 


dineshkumar
HOW TO DISPLAY COMPONENTS ROW BY ROW AS A FORM? I want the below program to be modified so that i can get my java application to look like an entry form.. Please help me..
2 Answer(s)      8 months ago
Posted in : Java Beginners

    JFrame main=new JFrame("Home-THE SECURED PARKING SERVICE MAIN PAGE");
    main.getContentPane().setBackground(Color.blue);

    JPanel titlePanel=new JPanel();
    JLabel heading=new JLabel("*******THE SECURED PARKING SERVICES*******",JLabel.CENTER);
    heading.setOpaque(true);![alt text][1]
    heading.setBackground(Color.orange);
    heading.setForeground(Color.black);
    heading.setFont(new Font("Serif", Font.BOLD, 35));
    titlePanel.setBackground(Color.blue);
    titlePanel.add(heading);
    //entrypanel and textfields

    JPanel entryPanel=new JPanel();
    entryPanel.setLayout(new BoxLayout(entryPanel,BoxLayout.Y_AXIS));
    JTextField name=new JTextField(10);
    name.setBounds(0, 0, 20, 50);   
    JTextField custid=new JTextField(10);
    JTextField address=new JTextField(10);
    JTextField dob=new JTextField(10);
    JTextField vehiclename=new JTextField(10);
    JTextField vehiclereg_no=new JTextField(10);
    JTextField license_no=new JTextField(10);
    entryPanel.add(name);
    entryPanel.add(custid);
    entryPanel.add(address);
    entryPanel.add(dob);
    entryPanel.add(vehiclename);
    entryPanel.add(vehiclereg_no);
    entryPanel.add(license_no);![alt text][2]
    main.add(titlePanel);
    main.add(entryPanel);
    main.setLayout(new BoxLayout(main.getContentPane(),BoxLayout.Y_AXIS));
    main.setSize(1368,770);//exact window size
    main.setVisible(true);
    main.setDefaultCloseOperation(main.EXIT_ON_CLOSE);

My output is like this:

View Answers

September 3, 2012 at 4:19 PM


We have modified your code. Here it is:

JFrame main=new JFrame("Home-THE SECURED PARKING SERVICE MAIN PAGE");
    main.getContentPane().setBackground(Color.blue);

    JPanel titlePanel=new JPanel();
    JLabel heading=new JLabel("*******THE SECURED PARKING SERVICES*******",JLabel.CENTER);
    heading.setOpaque(true);
    heading.setBackground(Color.orange);
    heading.setForeground(Color.black);
    heading.setFont(new Font("Serif", Font.BOLD, 35));
    titlePanel.setBackground(Color.blue);
    titlePanel.add(heading);
    //entrypanel and textfields

    JPanel entryPanel=new JPanel();
    entryPanel.setLayout(new BoxLayout(entryPanel,BoxLayout.Y_AXIS));
    JTextField name=new JTextField(10);
    name.setBounds(0, 0, 20, 50);   
    JTextField custid=new JTextField(10);
    JTextField address=new JTextField(10);
    JTextField dob=new JTextField(10);
    JTextField vehiclename=new JTextField(10);
    JTextField vehiclereg_no=new JTextField(10);
    JTextField license_no=new JTextField(10);
    entryPanel.add(name);
    entryPanel.add(custid);
    entryPanel.add(address);
    entryPanel.add(dob);
    entryPanel.add(vehiclename);
    entryPanel.add(vehiclereg_no);
    entryPanel.add(license_no);
    main.add(titlePanel);
    main.add(entryPanel);
    main.setLayout(new BoxLayout(main.getContentPane(),BoxLayout.Y_AXIS));
    main.setSize(1368,770);//exact window size
    main.setVisible(true);
    main.setDefaultCloseOperation(main.EXIT_ON_CLOSE);

September 5, 2012 at 4:56 PM


Huh!! Nothing different. Please post me the correct one by indicating the incorrect ones..









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.