Results 1 to 9 of 9
  1. #1
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Question nothing visible in frame?

    code below dont understand why there is nothing in the frame?
    *i use bluej
    Java Code:
    import javax.swing.*;//importing essential packages
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    
    public class Admission
    {
        public void main(String arg[])
        {
            try//try-catch method
            {
                Admission_2 frame=new Admission_2();
                frame.setSize(700,150);
                frame.setLocation(400,400);
                frame.setVisible(true);//showing frame
            }
            catch(Exception e)//exception handler
            {System.out.println("JAVA EXEPTION TRIGGERED.PLEASE CHECK FOR YOUR FAULTS");
                System.out.println("FAULTS SUCH AS WRONG INPUTS, WRONG INPUT OR TYPE");
            }
        }
    }
    class Admission_2  extends JFrame 
    {
        JPanel panel;    JButton SUBMIT;//button for submitting data
        JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,label10,label11,label12,label13,label14,label15,label16,label17,label18,label19;
        JTextField  text2,text3,text4,text5,text6,text7,text8,text9,text10,text12,text13,text14,text15,text16,text17,text18,text19;
        public  void admission_2()
        {
            label1 = new JLabel();
            label2 = new JLabel();
            label3 = new JLabel();
            label4 = new JLabel();
            label5 = new JLabel();
            label6 = new JLabel();
            label7 = new JLabel();
            label8 = new JLabel();
            label9 = new JLabel();
            label10 = new JLabel();
            label11 = new JLabel();
            label12 = new JLabel();
            label13 = new JLabel();
            label14 = new JLabel();
            label15 = new JLabel();
            label16 = new JLabel();
            label17 = new JLabel();
            label18 = new JLabel();
            label19 = new JLabel();
    
            label1.setText("DETAILS OF CHILD :");
    
            label2.setText("Class in Which Admission Required");
            text2 = new JTextField(15);
    
            label3.setText("Student Name");
            text3 = new JTextField(50);
    
            label4.setText("Sex");
            text4 = new JTextField(6);
    
            label5.setText("Date of Birth");
            text5 = new JTextField(50);
    
            label6.setText("Nationality");
            text6 = new JTextField(50);
    
            label7.setText("Address");
            text7 = new JTextField(150);
    
            label8.setText("Mother Tongue");
            text8 = new JTextField(50);
    
            label9.setText("Identification Mark");
            text9 = new JTextField(500);
    
            label10.setText("Blood Group");
            text10 = new JTextField(3);
    
            label11.setText("PARENTAL DETAILS :");
    
            label12.setText("Name");
            text12 = new JTextField(100);
    
            label13.setText("email");
            text13 = new JTextField(50);
    
            label14.setText("Qualification");
            text14 = new JTextField(100);
    
            label15.setText("Occupation");
            text15 = new JTextField(50);
    
            label16.setText("Income P/M");
            text16 = new JTextField(15);
    
            label17.setText("Office Address");
            text17 = new JTextField(150);
    
            label18.setText("Office Telephone No.");
            text18 = new JTextField(11);
    
            label19.setText("Religion");
            text19 = new JTextField(20);
    
           
            SUBMIT=new JButton("login");
    
            panel=new JPanel(new GridLayout(3,1));
    
            panel.add(label1);
            panel.add(label2);
            panel.add(text2);
            panel.add(label3);
            panel.add(text3);
            panel.add(label4);
            panel.add(text4);
            panel.add(label5);
            panel.add(text5);
            panel.add(label6);
            panel.add(text6);
            panel.add(label7);
            panel.add(text7);
            panel.add(label8);
            panel.add(text8);
            panel.add(label9);
            panel.add(text9);
            panel.add(label10);
            panel.add(text10);
            panel.add(label11);
            panel.add(label12);
            panel.add(text12);
            panel.add(label13);
            panel.add(text13);
            panel.add(label14);
            panel.add(text14);
            panel.add(label15);
            panel.add(text15);
            panel.add(label16);
            panel.add(text16);
            panel.add(label17);
            panel.add(text17);
            panel.add(label18);
            panel.add(text18);
            panel.add(label19);
            panel.add(text19);
    
            add(panel,BorderLayout.CENTER); 
            setTitle("ADMISSION FORM");
        }
    
    
    
    }
    HELP PLZ>>
    Last edited by harshit shah; 01-13-2013 at 01:36 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: nothing visible in frame?

    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming then edit your post accordingly.

    How are you running that code? There's no entry point.

    The method that adds content to Admission_2 isn't called from anywhere. Not that a constructor must have the same name as the class (and Java is case sensitive) and have no return type, not even void.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Default Re: nothing visible in frame?

    yes i know its a blank form ya it sounds stupid but shouldn't it run??
    all i get is a blank jframe...

    i edited my post accordingly..
    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming then edit your post accordingly.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: nothing visible in frame?

    Thank you for editing your code/post. You code suffers from a "pseudo" constructor. Remember that constructors have no return type, not void, not anything. Also, constructor names should be spelled and capitalized *exactly* the same as the class name.

    So, not:
    Java Code:
    public void admission_2() {
    but rather:
    Java Code:
    public Admission_2() {

    Also your main method should be static. Also the code would benefit from use of arrays. Also, you'll want to use nested JPanels with their own layouts to get a better GUI layout, avoid setting sizes of anything, and calling pack() on the JFrame before displaying it to tell the layout managers to do their thing.
    Last edited by Fubarable; 01-13-2013 at 02:53 PM.

  5. #5
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Default Re: nothing visible in frame?

    hmmm yup my fault...
    but how do you suggest i arrange it properly?
    i want to give it a form-like look and feel...just the way see online registration forms...what do you suggest i should do?
    thanks a lot..

    Quote Originally Posted by Fubarable View Post
    Thank you for editing your code/post. You code suffers from a "pseudo" constructor. Remember that constructors have no return type, not void, not anything. Also, constructor names should be spelled and capitalized *exactly* the same as the class name.

    So, not:
    Java Code:
    public void admission_2() {
    but rather:
    Java Code:
    public Admission_2() {

    Also your main method should be static. Also the code would benefit from use of arrays. Also, you'll want to use nested JPanels with their own layouts to get a better GUI layout, avoid setting sizes of anything, and calling pack() on the JFrame before displaying it to tell the layout managers to do their thing.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: nothing visible in frame?

    Consider using a GridBagLayout for your JLabel/JTextField table of components and consider nesting JPanels, each using its own layout to create complex GUIs. You can find examples here:

  7. #7
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Default Re: nothing visible in frame?

    hmm....thanks a lot,but still can you help me arrange the JLabels using gridlayout
    i don't want a complex a program just basic...it will fetch me more marks than i require.

    edit:

    kk got it thanks by changing the panels grid layout.
    Last edited by harshit shah; 01-13-2013 at 05:48 PM. Reason: got it!

  8. #8
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Default Re: nothing visible in frame?

    SORRY i bumped this post can u tell me how to add a print button below my JFrame..to print the whole frame along with it contents..i would also like to add a local/online picture to the panel...any suggestions?

  9. #9
    harshit shah is offline Member
    Join Date
    Jan 2013
    Location
    Kolkata,India
    Posts
    86
    Rep Power
    0

    Default Re: nothing visible in frame?

    i am pretty new to this forum, and just read the rules...so pardon if i am breaking rules here...
    but i want to add a print button to my current frame so that it prints the whole frame with it's contents.
    also, i would like to add a picture(local/online) to the current frame as well.
    what do you suggest?
    my CURRENT code:
    Java Code:
    import javax.swing.*;//importing essential p[ackages
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    
    public class Admission
    {
        public static void main()
        {
            try//try-catch method
            {
                Admission_2 frame=new Admission_2();
                frame.setSize(1000,700);
                frame.setLocation(250,100);
                frame.setVisible(true);//showing frame
            }
            catch(Exception e)//exception handler
            {System.out.println("JAVA EXEPTION TRIGGERED.PLEASE CHECK FOR YOUR FAULTS");
                System.out.println("FAULTS SUCH AS WRONG INPUTS, WRONG INPUT OR TYPE");
            }
        }
    }
    class Admission_2  extends JFrame 
    {
        JPanel panel;    JButton SUBMIT;//button for submitting data
        JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,label10,label11,label12,label13,label14,label15,label16,label17,label18,label19;
        JTextField  text2,text3,text4,text5,text6,text7,text8,text9,text10,text12,text13,text14,text15,text16,text17,text18,text19;
        public Admission_2()
        {
            label1 = new JLabel();
            label2 = new JLabel();
            label3 = new JLabel();
            label4 = new JLabel();
            label5 = new JLabel();
            label6 = new JLabel();
            label7 = new JLabel();
            label8 = new JLabel();
            label9 = new JLabel();
            label10 = new JLabel();
            label11 = new JLabel();
            label12 = new JLabel();
            label13 = new JLabel();
            label14 = new JLabel();
            label15 = new JLabel();
            label16 = new JLabel();
            label17 = new JLabel();
            label18 = new JLabel();
            label19 = new JLabel();
    
            label1.setText("DETAILS OF CHILD :");
            label1.setForeground(Color.red);
            
    
            label2.setText("Class in Which Admission Required");
            text2 = new JTextField(15);
    
            label3.setText("Student Name");
            text3 = new JTextField(50);
    
            label4.setText("Sex");
            text4 = new JTextField(6);
    
            label5.setText("Date of Birth");
            text5 = new JTextField(50);
    
            label6.setText("Nationality");
            text6 = new JTextField(50);
    
            label7.setText("Address");
            text7 = new JTextField(150);
    
            label8.setText("Mother Tongue");
            text8 = new JTextField(50);
    
            label9.setText("Identification Mark");
            text9 = new JTextField(500);
    
            label10.setText("Blood Group");
            text10 = new JTextField(3);
    
            label11.setText("PARENTAL DETAILS :");
            label11.setForeground(Color.red);
    
            label12.setText("Name");
            text12 = new JTextField(100);
    
            label13.setText("email");
            text13 = new JTextField(50);
    
            label14.setText("Qualification");
            text14 = new JTextField(100);
    
            label15.setText("Occupation");
            text15 = new JTextField(50);
    
            label16.setText("Income P/M");
            text16 = new JTextField(15);
    
            label17.setText("Office Address");
            text17 = new JTextField(150);
    
            label18.setText("Office Telephone No.");
            text18 = new JTextField(11);
    
            label19.setText("Religion");
            text19 = new JTextField(20);
    
            SUBMIT=new JButton("login");
            panel=new JPanel(new GridLayout(38,2));
            panel.add(label1);
            panel.add(label2);
            panel.add(text2);
            panel.add(label3);
            panel.add(text3);
            panel.add(label4);
            panel.add(text4);
            panel.add(label5);
            panel.add(text5);
            panel.add(label6);
            panel.add(text6);
            panel.add(label7);
            panel.add(text7);
            panel.add(label8);
            panel.add(text8);
            panel.add(label9);
            panel.add(text9);
            panel.add(label10);
            panel.add(text10);
            panel.add(label11);
            panel.add(label12);
            panel.add(text12);
            panel.add(label13);
            panel.add(text13);
            panel.add(label14);
            panel.add(text14);
            panel.add(label15);
            panel.add(text15);
            panel.add(label16);
            panel.add(text16);
            panel.add(label17);
            panel.add(text17);
            panel.add(label18);
            panel.add(text18);
            panel.add(label19);
            panel.add(text19);
    
            add(panel,BorderLayout.CENTER); 
            panel.setVisible(true);
            panel.setBackground(Color.cyan);
            setTitle("ADMISSION FORM");
        }
    
    
    }
    Last edited by harshit shah; 01-14-2013 at 03:44 PM.

Similar Threads

  1. Replies: 7
    Last Post: 04-01-2012, 04:11 AM
  2. Replies: 4
    Last Post: 01-18-2011, 08:22 AM
  3. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  4. ERRORS: set visible
    By Johanis in forum New To Java
    Replies: 1
    Last Post: 11-07-2010, 11:39 AM
  5. Replies: 7
    Last Post: 11-02-2009, 06:31 PM

Tags for this Thread

Posting Permissions

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