Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT Need Help with Java-SWING progrmming

Have Programming Question? Ask it here!
 
 
 


sreejith
Need Help with Java-SWING progrmming
2 Answer(s)      5 years and 8 months ago
Posted in : Swing AWT



Advertisement
View Answers

September 1, 2008 at 10:23 AM


Hi Sreejith

check this source(easy way).
package library.code;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

@SuppressWarnings("serial")
public class ListIssueBook extends JInternalFrame implements Printable{

private JPanel headPanel,buttonPanel,tablePanel;
private JLabel headLabel;
private JButton exitButton,printButton;
private Container container;
private TableStructure tabStructure;
private JTable table;
private JScrollPane scrollPane;
private TableColumn column;
String issueQuery;
public ListIssueBook(){
container = getContentPane();
headLabel = new JLabel("List of Issued Book");
headLabel.setFont(new Font("Arial",Font.BOLD,16));
headPanel = new JPanel();
headPanel.add(headLabel);
container.add("North",headPanel);

issueQuery = "SELECT i.EmpId,b.BookID,b.Category,b.Name,b.Author,b.Publication,i.status FROM Books b, Issues i WHERE b.status = 'Issue' AND b.BookID = I.BookId AND i.status = 'Pending' ";
try{
tabStructure = new TableStructure();
tabStructure.setQuery(issueQuery);
}catch(Exception e){

}
table = new JTable(tabStructure);
table.setPreferredScrollableViewportSize(new Dimension(600,200));
scrollPane = new JScrollPane(table);
for(int i=0; i<5; i++){
column = table.getColumnModel().getColumn(i);
if(i == 0)
column.setPreferredWidth(7);
if(i == 1)
column.setPreferredWidth(15);
if(i == 2)
column.setPreferredWidth(25);
if(i == 3)
column.setPreferredWidth(25);
if(i == 4)
column.setPreferredWidth(25);
if(i == 5)
column.setPreferredWidth(7);
}
tablePanel = new JPanel();
tablePanel.setLayout(new BorderLayout());
tablePanel.add(scrollPane,BorderLayout.CENTER);
container.add("Center",tablePanel);

exitButton = new JButton("Exit");
printButton = new JButton("Print");
buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(printButton);
buttonPanel.add(exitButton);
container.add("South",buttonPanel);

setVisible(true);
pack();

exitButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent arg0) {
dispose();
}

});

printButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent arg0) {
PrinterJob prJob = PrinterJob.getPrinterJob();
prJob.setPrintable(ListIssueBook.this);
if(!prJob.printDialog())
return;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
prJob.print();
} catch (PrinterException e) {
e.printStackTrace();
}
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

});
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException {
if (pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D graphics2D = (Graphics2D)graphics;
graphics2D.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
getContentPane().paint(graphics2D);
return PAGE_EXISTS;
}
}


Regards
Rajanikant Mishra


September 1, 2008 at 10:26 AM


Hi friend,


Read for more information.


http://www.roseindia.net/java/example/java/swing/Print.shtml


Thanks.



Related Tutorials/Questions & Answers:
Need Help with Java-SWING progrmming - Swing AWT
Need Help with Java-SWING progrmming  Hi sir, I am a beginner in java-swing programming. I want to know how we can use the print option with a program in swing. Could you help me with an example? Regards Sreejith 
Need Help To Connect XML as backend in Java-Swing
Need Help To Connect XML as backend in Java-Swing  Seat arrangment swing screenshot I made XML program to connect to swing like this. <?xml... problem is if i click the B1 label it need to change as(occupied-grey colour
Advertisements
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop.... This name list should get from the database. Please help me. By the way, I'm
Need help with this!
Need help with this!  Can anyone please help me... to a file at all at this time. Any help would be greatly appreciated, thank you... to effectivly end the loop with out the need to break it. for(i=(0); i <
Need Help on JMS - JMS
Need Help on JMS   Hi, In my application i need to create my own ques and my own QueueConnectionFactory..... Plz tell me how to create the same... Any help is appriciated,.. Thanks in advance
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
need help with program
need help with program  To write a program to read a set of words from a file and return the following 1)Each word in the file against its frequency 2) the frequency should be in the descending order of the frequencies
need help please
need help please  Dear sir, my name is logeswaran. I have a big problem that I can't find the solution for a program. How can I block a user from enter a page second time. Please help me. By the way I'm using Access database
Need Help in Java programming
Need Help in Java programming  Hello. Can someone please help me with writing the following program Java program that gives assignment details such as:assignment number,assignment name,due date,submission date,percentage marks
need help to create applet
need help to create applet  Can u help me..?? I get a task ...and i dont know how to make it... So I hope that u can help me... Here is the task... e) CardLayout If u can help me, then please
need help with program
need help with program  To write a program where we can take two integer array as input,Find the missing number from array"B" has all the numbers from array"A" except one,and find the fastest way in doing
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have... using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen(need to know how I can adjust it based on the cureen system's screen resolution
Friends need a help on ruby..
Friends need a help on ruby..  Friends i need a ruby script and the requirement is When i am running a ruby script in cmd, after executing my script, a html report will be generated having my console output details. For ex
Need some help urgently
Need some help urgently  Can someone please help me with this below question. I need to write a class for this. If you roll Y standard six-sided dice... need to write a class for this where X and Y are passed as parameter. If someone
hello there i need help
i am a beginner, and aside from that i am really eager to learn java please help...hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you
Need help with console program?
Need help with console program?  Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). thanks in advance.   Here is an example that repeatedly
Need Help With This Scenario
Need Help With This Scenario  The bonnet of a car is opened to determine if there is anything wrong with the engine. Firstly, the radiator water is checked. If the radiator water is below the minimum indicator level
Need Help With This Scenario
Need Help With This Scenario  The bonnet of a car is opened to determine if there is anything wrong with the engine. Firstly, the radiator water is checked. If the radiator water is below the minimum indicator level
Need Help - Java Beginners
Need Help  Hello Sir, Am a beginner of Java. Also i did course... projects in Java as well as J2EE... Can u help me and guide to do a project.../reference/tutorials/ http://netbeans.org/kb/trails/java-ee.html http
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced ‚?? n factorial‚??) and is defined as follows: n!=n . (n-1) . (n-2) . .... . 1 (for values of n greater than or equal to 1) and n!=1
Need Help on the script
Need Help on the script  hello there, My name is Femi and am a web developer using php. am working on a project. and am having some difficulties. i dont know if you can help me out with it. The platform am building will receive
need help - Java Beginners
need help  Need help in programming in Java  Simple java program that will show the output within quotes using system.out.println();DISPLAYING OUPUT " * " ," *** " ........I used System.out.print
Need help - Java Beginners
Need help   To Write a Java program that asks the users to enter a m * n matrix of integers, m and n being the number of rows and columns...; Hi Friend, Please try the following code. We hope that this code will help
seriously need help....
seriously need help....  Write a program that will prompt the user to select an appliance, lookup the energy the appliance uses and for each time... program. Use each of the following Java statements at least once in your program
Need help with my project
Need help with my project  Uses a while loop to perform the following steps: -Prompt the user to input two integers: firstNum and secondNum where secondNum is at least 10 greater than firstNum, both numbers are positive integers
Need help in java programming
Need help in java programming  Hello. Can someone please help me with writig the following programm. Assignment 20% Presentation 10% Mini Test 10% Exam 60% Java program that accepts the following details: student
need help...................please
need help...................please  I have a problem in my JSP Coding. How to retrive value from database in to text field when user select one value... on this area. Please help me. By the way, I'm using access Database and JSP coding
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
need help - Swing AWT
need help  Create a program to correct and grade a set of multiple choice test result. this is a console program that uses JOptionPane dialog boxes as well. Must read a set of 10 correct answers, using a JOptionPane dislog box
need help with a program - Java Beginners
Java algorithm - need help with a program  Java algorithm - need help with a program
need help with a program - Java Beginners
need help with a program   Part I An algorithm describes how... by the user. The output of the program should be the length and width (entered.... First you would need to make up the "test data". For this algorithm, the test data
need someone to do/help with code
need someone to do/help with code  i need someone to do a code for me. It is a restaurant menu that displays a list of 10 food items. A customer..., along with the number of items sold..please help did a code 500 times cant
Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming... don't know what to do. Please help!! #include<iostream.h> void main... help
Need help on mySQL 5 - SQL
Need help on mySQL 5  Dear Sir, I'm a beginner of mySQL 5 . I need help on mySQL5 command. This is the table which i created is called... by using Aggregate function(MAX). May i know that what command i need
PLZ Need some help JAVA...HELP !!
PLZ Need some help JAVA...HELP !!  Create a class names Purchase Each purchase contains an invoice number, amount of sale and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set
i need help - Development process
i need help  hello, i need help regarding this program. this program gives ping to the system. import java.net.*; import java.io.*; import...?   hi subhash hope this code can help you, public class PingTest
Need help in constructing bubble sort
Need help in constructing bubble sort  using a bubble sort, for each entry in the array, display the original index of the first dimension...://www.roseindia.net/java/beginners/arrayexamples/bubblesort.shtml http://www.roseindia.net/java
Java Programming Need Help ASAP
Java Programming Need Help ASAP  You are required to develop..., maths mark, communications mark. You will then need accessor and mutator methods... class that creates an array of Students and handles it. You will need
i need help - Development process
i need help  hello, i need help regarding this program. public class PingTest { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter
Netbeans Question need help desperately!!
Netbeans Question need help desperately!!   Ok here is my code- public class RollDie2 { public static void main(String[] args) { Random randomNumber = new Random(); int[][] frequency = new int[9][9]; int die1 = 0; int
i need help plz .... Quickly
i need help plz .... Quickly   how can i count how many numbers enterd by the user so the output would be like this Total number of Scores = .... this is my code :- import java.util.Scanner; public class SCORES { public
i need help to solve this problem
i need help to solve this problem  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input and prints them in reverse order. and Show step by step what queue will look like
hi need help with C++ programming!
hi need help with C++ programming!  how do i : b. Store numbers / characters into the file (output) c. Retrieve numbers / characters from the file (input thanks!   b) #include <iostream> #include <
Need *Help fixing this - Java Beginners
Need *Help fixing this  I need to make this program prompt user... and maybe add retrieve function //need help with this one badly. Thanks guys for all the help. import java.text.*; import javax.swing.*; import java.awt.event.
Need help writing a console program
Need help writing a console program  I need help cant seems to figure it out! Write a program that consists of three classes. The first class...): This is a test, this is only a test! This test is a test of your Java programming
Please help need quick!!! Thanks
Please help need quick!!! Thanks  hey i keep getting stupid compile errors and don't understand why. i'm supposed to use abstract to test a boat race...(); ^ 6 errors any help would be appreciated guys. Thanks so
need to fix errors please help
need to fix errors please help  it does have 2 errors what should i fix? import java.io.*; class InputName static InputStreamReader reader = new InputStreamReader(system.in); static BufferedReader input = new BufferedReader
Java swing
are displayed in the table..I need the source code in java swing...Java swing  If i am login to open my account the textfield,textarea and button are displayed. if i am entering the time of the textfield
Advertisements
 

 

 

DMCA.com