Java Print the all components

Java Print the all components

This is my code. Please tell me the solutions

import javax.swing.table.*;

import javax.swing.*; import java.util.*; import java.awt.*; import java.awt.event.*; import java.awt.print.*; import java.awt.geom.*; import java.util.Calendar;

public class Salary_report extends JFrame implements ActionListener {

Vector data;
JTable table;
JLabel banner;  
ImageIcon images;
Container c;
Employee_report f1;
JButton print;
String s,days,basic,pf,hra,esi,bonus,advance,allowance,loan,incentive,dother,da,eother,gross,ded,net,leave;
double ge,td,np,l,l1;
public Salary_report(Employee_report f1)
{
    c=getContentPane();
c.setLayout(null);
setResizable(false);
setTitle("Employee Salary Report");
setBounds(250,50,700,750);

WindowShow.setNativeLookAndFeel();

s=f1.ename.getSelectedItem().toString();
basic=f1.txtbsalary.getText();
pf=f1.txtpf.getText();
hra=f1.txthra.getText();
esi=f1.txtesi.getText();
bonus=f1.txtbonus.getText();
advance=f1.txtadv.getText();
allowance=f1.txtsall.getText();
loan=f1.txtploan.getText();
incentive=f1.txtinc.getText();
dother=f1.txtoth.getText();
da=f1.txtda.getText();
eother=f1.txtoth1.getText();
l=Double.parseDouble(f1.txtleave.getText());
if(l<=1)
{
    leave="0";
}   
else
{
    Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH - 1);
        int date = 1;
        calendar.set(year, month, date);
        int day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        l1=(Double.parseDouble(basic)/day)*(l-1);
    leave=Double.toString(Math.round(l1));  
    days=Integer.toString(day);
}

ge=Double.parseDouble(basic)+Double.parseDouble(hra)+Double.parseDouble(bonus)+Double.parseDouble(allowance)+Double.parseDouble(incentive)+Double.parseDouble(da)+Double.parseDou

ble(eother); gross=Double.toString(ge); td=Double.parseDouble(pf)+Double.parseDouble(esi)+Double.parseDouble(advance)+Double.parseDouble(loan)+Double.parseDouble(dother)+Double.parseDouble(leave); ded=Double.toString(td); np=ge-td; net=Double.toString(np);

data = createData();
print=new JButton("Print");
print.setBounds(300,550,100,20);
c.add(print);
print.addActionListener(this);

SplitCellTableModel model = new SplitCellTableModel();
    table = new JTable(model);
    table.getColumnModel().getColumn(0).setCellEditor(new SplitTableCellEditor());
    table.getColumnModel().getColumn(1).setCellEditor(new SplitTableCellEditor());
    table.getColumnModel().getColumn(0).setCellRenderer(new SplitTableCellRenderer());
    table.getColumnModel().getColumn(1).setCellRenderer(new SplitTableCellRenderer());

    JScrollPane scroller = new JScrollPane(table);

    if(f1.cname.getSelectedItem().toString().equals("Teamwork Architecture"))
        images=new ImageIcon("TWA.jpg");
else if(f1.cname.getSelectedItem().toString().equals("Teamwork Techno Solutions"))
        images=new ImageIcon("TWT.jpg");
banner=new JLabel();
banner.setIcon(images);
banner.setBounds(60,50,600,150);
c.add(banner,BorderLayout.NORTH);


scroller.setBounds(60,250,600,260);
c.add(scroller);    
}

public void actionPerformed(ActionEvent ae)
{
    String str=ae.getActionCommand();
    if(str.equalsIgnoreCase("Print"))
    {   
        print.setVisible(false);
        PrintableDocument.printComponent(this);
    }
} 
public Vector createData()
{
    Vector result = new Vector();
Vector rec = new Vector();
    Object[] value = new Object[] {"Employee Name",s};
    rec.add(value);
    value = new Object[] {"Total Days",days};
    rec.add(value);
    result.add(rec);

    rec = new Vector();
    value = new Object[] {"", ""};
    rec.add(value);
value = new Object[] {"", ""};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"Earnings", ""};
    rec.add(value);
    value = new Object[] {"Deductions", ""};
    rec.add(value);
    result.add(rec);


rec = new Vector();
    value = new Object[] {"", ""};
    rec.add(value);                         
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"Basic",basic};
    rec.add(value);
    value = new Object[] {"PF",pf};
    rec.add(value);
    result.add(rec);


rec = new Vector();
    value = new Object[] {"HRA",hra};
    rec.add(value);
    value = new Object[] {"ESI",esi};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"Bonus",bonus};
    rec.add(value);
    value = new Object[] {"Salary Advance",advance};
    rec.add(value);
    result.add(rec);


rec = new Vector();
    value = new Object[] {"Special Allowance",allowance};
    rec.add(value);
    value = new Object[] {"Personal Loan",loan};
    rec.add(value);
    result.add(rec);


rec = new Vector();
    value = new Object[] {"Incentive",incentive};
    rec.add(value);
value = new Object[] {"Others",dother};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"DA",da};
    rec.add(value);
value = new Object[] {"Leave",leave};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"Others",eother};
    rec.add(value);
value = new Object[] {"", ""};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"", ""};
    rec.add(value);
value = new Object[] {"", ""};
    rec.add(value);
    result.add(rec);

    rec = new Vector();
    value = new Object[] {"Gross Earnings(A)",gross};
    rec.add(value);
value = new Object[] {"Total Deductions(B)",ded};
    rec.add(value);
    result.add(rec);

rec = new Vector();
    value = new Object[] {"Net Pay (A)-(B)",net};
    rec.add(value);
value = new Object[] {"", ""};
    rec.add(value);
    result.add(rec);
    return result;
}

public class SplitCellTableModel extends DefaultTableModel { public SplitCellTableModel() { }

public int getRowCount()
{
    return data.size();
}

public int getColumnCount()
{
    return 2;
}

public String getColumnName(int col)
{
    if (col == 0)
        return " ";
    else
        return "Date";
}

public Object getValueAt(int row, int col)
{
    Vector rec = (Vector)data.get(row);
    return rec.get(col);
}

public Vector getDataVector()
{
    return data;
}

public boolean isCellEditable(int row, int col)
{
    return false;
}

public void setValueAt(Object value, int row, int col)
{
    Vector rec = (Vector)data.get(row);
    rec.setElementAt(value, col);
}

}

public class SplitTableCellEditor extends AbstractCellEditor implements TableCellEditor { JPanel editingPanel; JTextField leftTextField; JTextField rightTextField;

public SplitTableCellEditor()
{
    super();
    editingPanel = new JPanel();
    editingPanel.setLayout(new GridLayout(1, 2));
    leftTextField = new JTextField();
    editingPanel.add(leftTextField);
    rightTextField = new JTextField();
    editingPanel.add(rightTextField);
}

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int colIndex)
{
    Object[] splitVal = (Object[])value; // cast to array of Object
    if (splitVal != null)
    {
        String leftStr = (String)splitVal[0];
        String rightStr = (String)splitVal[1];
        leftTextField.setText(leftStr == null ? "" : leftStr);
        rightTextField.setText(rightStr == null ? "" : rightStr);
    }
    else
    {
        leftTextField.setText("");
        rightTextField.setText("");
    }
    return editingPanel;
}

public Object getCellEditorValue()
{
    Object[] value = new Object[] {leftTextField.getText(), rightTextField.getText()};
    return value;
}

}

public class SplitTableCellRenderer implements TableCellRenderer { JPanel rendererPanel; JLabel leftLabel; JLabel rightLabel;

public SplitTableCellRenderer()
{
    super();

    rendererPanel = new JPanel();
    rendererPanel.setLayout(new GridLayout(1, 2));
    leftLabel = new JLabel("Adfasdf");
    leftLabel.setOpaque(true);
    leftLabel.setBackground(Color.white);
    rendererPanel.add(leftLabel);
    rightLabel = new JLabel("adsfsdf");
    rightLabel.setOpaque(true);
    rightLabel.setBackground(Color.white);
    rendererPanel.add(rightLabel);
}

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
{
    Object[] splitVal = (Object[])value; // cast to array of Object
    if (splitVal != null)
    {
        String leftStr = (String)splitVal[0];
        String rightStr = (String)splitVal[1];
        leftLabel.setText(leftStr == null ? "" : leftStr);
        rightLabel.setText(rightStr == null ? "" : rightStr);
    }
    else
    {
        leftLabel.setText("");
        rightLabel.setText("");
    }
    return rendererPanel;
}

}

}

If i click print button then my current window is print in a paper.

The paper contain only half of the output. But i want full screen output.

Please tell me the solutions

View Answers









Related Tutorials/Questions & Answers:
Java Print the all components
Java Print the all components  This is my code. Please tell me...; JLabel banner; ImageIcon images; Container c; Employee_report f1; JButton print... = createData(); print=new JButton("Print"); print.setBounds(300,550,100,20); c.add(print
how to print all colors using awt
how to print all colors using awt  how to print all colors using awt
Advertisements
ModuleNotFoundError: No module named 'nester_print_all'
ModuleNotFoundError: No module named 'nester_print_all'  Hi, My... named 'nester_print_all' How to remove the ModuleNotFoundError: No module named 'nester_print_all' error? Thanks   Hi, In your
how to print all possible combination that sum to zero??
how to print all possible combination that sum to zero??  Ã?Â.... Print all possible combinations that sum to zero Example Enter a num : 7 1... each of the digits so that the resultant sum is zero. Print all posible
what are the components of java platform ?
what are the components of java platform ?  what are the components of java platform ? plz if any1 perfectly know help me to override my conflicts.plz explain briefly
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
How to print this in java?
How to print pattern in Java?  How to print a particular pattern in Java...;  How to print this in java
Print Form - Java Beginners
Print Form  Hello Sir I have Created Admission Form when user fills data and submit that data to access database,then when i Click on PRINT Button I want to get Print of that forms Contents,How I can Do it with JAVA SWING,plz
Java Print Dialog
Java Print Dialog  Using java.awt.print.PrinterJob and javax.print.attribute.PrintRequestAttributeSet. I call .printDialog(ps) and the standard print dialog is displayed with options preset to my chosen attributes. Now I can
Simplest way to print an array in Java
Simplest way to print an array in Java  Simplest way to print an array in Java
print rectangle pattern in java
print rectangle pattern in java  * * * * * * * how to generate this pattern in java??   Hi friend try this code may this will helpful for you public class PrintRectangle { public static void main
print a rectangle - Java Beginners
print a rectangle  how do I print a rectangleof stars in java using simple while loop?Assuming that the length n width of the rectangle is given.  Hi friend, I am sending running code. import java.io.
how to print - Java Beginners
how to print  how to print something on console without using System.out.print() method ?  Hi Friend, You can use PrintWriter to write anything on the console. import java.io.*; public class Print{ public static
Print
Print  In system.out.println,what meant ln..?   System: It is a class made available by Java to let you manipulate various operating system... into the stream and, as opposed to print() method, gets you to the new line after the text
print only Form Fillup Contents through Text File - Java Beginners
print only Form Fillup Contents through Text File   Hello Sir ,I have Designed Employee Details Form using java swing components Now i want to print contents which is filled by employee,How i can Print it,and also i want print
httpservletrequest print all headers
httpservletrequest print all headers
httpservletrequest print all headers
httpservletrequest print all headers
Print in a long paper - Java Beginners
Print in a long paper  how to print text in long paper?? each print text, printer stops. not continue until the paper print out. Thanks
How to print the following pattern in java?
How to print the following pattern in java?  How to print the following pattern in java? he he is he is going he is going in   import java.io.*; class StringPattern { public static void main(String[] args
Reading Files and Print - Java Beginners
the Particular name "School A" and print all contents in the file(s). I give... where more than one student are from the same school it should print all...Reading Files and Print  Hey Guys, I'm a beginner to java and I
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
How to pretty print XML from Java?
How to pretty print XML from Java?  How to pretty print XML from Java
Version of servicemix-components>servicemix-components dependency
List of Version of servicemix-components>servicemix-components dependency
how to print from right to left in java????
how to print from right to left in java????   can anyone pls tell how to print from right to left in java
Components
Components in Flex4 is the simple extension of the components of Flex3. In this section, you will learns different types of spark components to be used in Flex4. Here is the list of spark components
Print Screen Using Java Swing
Print Screen Using Java Swing       In this section, you will learn how to print in java swing. The printable that is passed to setPrintable must have a print method
Create Layout Components in a Grid in Java
Create Layout Components in a Grid in Java   ... layout components with the help of grid in Java Swing. The grid layout provides.... And last is the vertical gap between components. This constructor takes all
java awt components - Java Beginners
java awt components  how to make the the button being active at a time..? ie two or more buttons gets activated by click at a time
I want to know the all possible syntax for EL code to print the first element of an array.
I want to know the all possible syntax for EL code to print the first element of an array.  Which is the correct EL codes syntax to print the first element of an array named employeeArray. ${employeeArray["0"]} or ${employeeArray
Java Programming Implement a virtual print queue
Java Programming Implement a virtual print queue  Implement a virtual print queue. A single print queue is servicing a single printer. Print... records: q,3,10 is a q type record which indicates that a print job, # 3, shall
accept sentence from user and print all word starts with vowel and end with consonent
accept sentence from user and print all word starts with vowel and end with consonent  Write a program to accept a sentence. Print all the words that starts with vowel and end with a consonant. e.g. input by user "the purpose
Print Only Forms Contents - Java Beginners
Print Only Forms Contents  Hello Sir I Have Created Simple Registration Form with Database Connectivity, Now I Want To Print Registration form... the following link: http://www.roseindia.net/java/example/java/swing
Version of exo>exoplatform.jsf.core-components dependency
List of Version of exo>exoplatform.jsf.core-components dependency
Version of exo>exoplatform.jsf.exo-components dependency
List of Version of exo>exoplatform.jsf.exo-components dependency
Version of plexus>plexus-components dependency
List of Version of plexus>plexus-components dependency
Version of servicemix>servicemix-components dependency
List of Version of servicemix>servicemix-components dependency
Version of com.jsftoolkit>components-base dependency
List of Version of com.jsftoolkit>components-base dependency
Version of com.nitorcreations>wicket-components dependency
List of Version of com.nitorcreations>wicket-components dependency
Version of com.trello>rxlifecycle-components dependency
List of Version of com.trello>rxlifecycle-components dependency
AWT Components
AWT Components       The class component is extended by all the AWT components. More of the codes can be put to this class to design lot of AWT components. Most of the AWT
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I have this code: public class Names { public static void main(String[] args... word and print in alphabetical order to produce this output: {bob=1, jim=1, tim=1
viewing the ms word in print layout from jsp - Java Beginners
viewing the ms word in print layout from jsp  Hi all, I am trying to export ms word from jsp in print layout format.I used the code... is to open in print layout format. If u have any code for converting into print
Maven dependency for com.trello - rxlifecycle-components version 0.1.0 is released. Learn to use rxlifecycle-components version 0.1.0 in Maven based Java projects
to use  com.trello - rxlifecycle-components version 0.1.0 in Java projects... project First of all you have to create a new Java project based on maven project... and includes  com.trello - rxlifecycle-components version 0.1.0 java library
Maven dependency for com.nitorcreations - wicket-components version 1.1 is released. Learn to use wicket-components version 1.1 in Maven based Java projects
to use  com.nitorcreations - wicket-components version 1.1 in Java... a Maven project First of all you have to create a new Java project based...-components released The developers of   com.nitorcreations - wicket
Maven dependency for com.nitorcreations - wicket-components version 1.5 is released. Learn to use wicket-components version 1.5 in Maven based Java projects
to use  com.nitorcreations - wicket-components version 1.5 in Java... a Maven project First of all you have to create a new Java project based...-components released The developers of   com.nitorcreations - wicket
Maven dependency for com.trello - rxlifecycle-components version 0.6.0 is released. Learn to use rxlifecycle-components version 0.6.0 in Maven based Java projects
to use  com.trello - rxlifecycle-components version 0.6.0 in Java projects... project First of all you have to create a new Java project based on maven project... and includes  com.trello - rxlifecycle-components version 0.6.0 java library
Java AWT Components
Java AWT Components      ... components available in the Java AWT package for developing user interface for your program. Following some components of Java AWT are explained : ADS
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt

Ads