Results 1 to 4 of 4

Thread: printing

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

    Question printing

    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:
    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");
        }
     
     
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: printing

    To have the program react to a button press, it needs to register a listener for the button. See the tutorial:
    How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: printing

    hmm....that means i have to use action listener...so can u give me some pieces of code?
    i cant seem to get the actionlistener to print my code...

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

    Default Re: printing

    Quote Originally Posted by harshit shah View Post
    i am pretty new to this forum, and just read the rules...so pardon if i am breaking rules here...
    Since you've read the rules, why did yo uviolate the second paragraph? You have already asked this question in another thread.

    In future, don't double pose the same question.

    can u give me some pieces of code?
    1. This is a technical forum. Please spell words in full. 'you' not 'u'
    2. Norm gave you a link to a tutorial that has code samples. Do you expect someone to replicate the tutorial here?

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

Similar Threads

  1. Replies: 0
    Last Post: 12-26-2011, 03:52 PM
  2. Help in Printing
    By kirly in forum Advanced Java
    Replies: 3
    Last Post: 10-03-2011, 03:40 PM
  3. Replies: 9
    Last Post: 08-19-2011, 12:59 AM
  4. printing string backwards and printing every other
    By droidus in forum New To Java
    Replies: 22
    Last Post: 03-10-2011, 09:17 AM
  5. GUI printing
    By uthpalaw in forum AWT / Swing
    Replies: 15
    Last Post: 06-09-2010, 12: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
  •