JWindow class please help me
sir<br>
i design a splash window by the use of JWindow class
i use the following constructor
public class splash extends JWindow
//get content pane and set by the setContentPane method
and add the three panels in it.
One JPanel have a JTextField
but JTextField is not accept the input or focus
means i try to write text in it but it not work
the code as follows
//Create Jwindow
import javax.swing.*;
import java.awt.*;
public class SplashScreen extends JWindow
public static void main(String args[])
new SplashScreen().setVisible(true);
//define Variables
Toolkit tk=Toolkit.getDefaultToolkit();
Container cp=getContentPane();
SplashScreenPanel1 p1;
SplashScreenPanel2 p2;
SplashScreenPanel3 p3;
SplashScreen()
Dimension d=tk.getScreenSize();
p1=new SplashScreenPanel1(d.getWidth(),d.getHeight());
p2=new SplashScreenPanel2(d.getWidth(),d.getHeight());
p3=new SplashScreenPanel3(d.getWidth(),d.getHeight());
this.setSize(d);
this.setContentPane(cp);
this.getContentPane().setLayout(null);
cp.setBackground(new Color(47,168,122));
p1.setBounds(new Rectangle(0,(int)(d.getHeight()-100),(int)d.getWidth(),100));
p2.setBounds(new Rectangle(0,0,(int)d.getWidth(),100));
p3.setBounds(new Rectangle(0,100,(int)(d.getWidth()),400));
this.getContentPane().add(p1);
this.getContentPane().add(p2);
this.getContentPane().add(p3);
p1.b1.requestFocus();
}//end of spalshscreen
create JPanel
public class spashscreenpanel3 extends JPanel
JTextField t=new JTextField();
splashscreenpanel3
this.setSize(200,100);
this.setLayout(null);
t.setBounds(10,20,100,20);
this.add(t);
}//end of JPanel
Please help me i am very thankful to u
Some helpful information is here:
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
import javax.swing.*;
import java.awt.*;
public class hamad extends JFrame
public static void main(String args[])
new hamad();
//define Variables
SplashScreenPanel1 p1;
SplashScreenPanel2 p2;
SplashScreenPanel3 p3;
JWindow window;
public hamad()
createWindow(this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(300,200);
setLocation(500,300);
setVisible(true);
private void createWindow(JFrame frameReference) {
window = new JWindow(frameReference);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d=tk.getScreenSize();
p1=new SplashScreenPanel1();
p2=new SplashScreenPanel2();
p3=new SplashScreenPanel3();
window.getContentPane().add(p1, "North");
window.getContentPane().add(p2, "Center");
window.getContentPane().add(p3, "South");
window.setSize(d.width/4, d.width/4);
window.setLocation(100,100);
window.setVisible(true);
private class SplashScreenPanel1 extends JPanel
JTextField field;
public SplashScreenPanel1()
setBackground(new Color(200,150,190));
setPreferredSize(new Dimension(100,50));
field = new JTextField();
field.setPreferredSize(new Dimension(100, 20));
add(field);
private class SplashScreenPanel2 extends JPanel
JTextField field;
public SplashScreenPanel2()
setBackground(new Color(220,90,180));
field = new JTextField();
field.setPreferredSize(new Dimension(75,20));
add(field);
//create JPanel
private class SplashScreenPanel3 extends JPanel
JTextField t=new JTextField();
public SplashScreenPanel3()
setBackground(Color.pink);
setPreferredSize(new Dimension(100,50));
setLayout(null);
t.setBounds(10,20,100,20);
add(t);
}//end of JPanel
}//end of spalshscreen
Similar Messages
-
Error in creating a process using runtime class - please help
Hi,
I am experimenting with the following piece of code. I tried to run it in one windows machine and it works fine. But i tried to run it in a different windows machine i get error in creating a process. The error is attached below the code. I don't understand why i couldn't create a process with the 'exec' command in the second machine. Can anyone please help?
CODE:
import java.io.*;
class test{
public static void main(String[] args){
try{
Runtime r = Runtime.getRuntime();
Process p = null;
p= r.exec("dir");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
System.out.println(br.readLine());
catch(Exception e){e.printStackTrace();}
ERROR (when run in the dos prompt):
java.io.IOException: CreateProcess: dir error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:63)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:550)
at java.lang.Runtime.exec(Runtime.java:416)
at java.lang.Runtime.exec(Runtime.java:358)
at java.lang.Runtime.exec(Runtime.java:322)
at test.main(test.java:16)
thanks,
DivyaAs much as I understand from the readings in the forums, Runtime.exec can only run commands that are in files, not native commands.
Hmm how do I explain that again?
Here:
Assuming a command is an executable program
Under the Windows operating system, many new programmers stumble upon Runtime.exec() when trying to use it for nonexecutable commands like dir and copy. Subsequently, they run into Runtime.exec()'s third pitfall. Listing 4.4 demonstrates exactly that:
Listing 4.4 BadExecWinDir.java
import java.util.*;
import java.io.*;
public class BadExecWinDir
public static void main(String args[])
try
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("dir");
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<OUTPUT>");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("</OUTPUT>");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
A run of BadExecWinDir produces:
E:\classes\com\javaworld\jpitfalls\article2>java BadExecWinDir
java.io.IOException: CreateProcess: dir error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at BadExecWinDir.main(BadExecWinDir.java:12)
As stated earlier, the error value of 2 means "file not found," which, in this case, means that the executable named dir.exe could not be found. That's because the directory command is part of the Windows command interpreter and not a separate executable. To run the Windows command interpreter, execute either command.com or cmd.exe, depending on the Windows operating system you use. Listing 4.5 runs a copy of the Windows command interpreter and then executes the user-supplied command (e.g., dir).
Taken from:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
NewInstance from variable class(Please Help)
I want to generate an object from xml
example :
<com.toto.titi.variable>
<name>tata</name>
<age>20</age>
</com.toto.titi.variable>
my java code :
str = "com.toto.titi.variable" ;
int idx0 = str.lastIndexOf(".");
String testObj = str.substring(idx0+1);
Class cls = Class.forName(str);
o_ = (testObj)cls.newInstance(); //testObj it's variable, i dont now origin class or Interface
this code is not work
Please help
Thanksdo a search on here for "beanbox"....that shows how to do object persistence and creation using xml.
-
HT1386 Trying to Sync - Unable to load data class - please help
I just cleared my I-Pod Touch to put new music on it and my computer is prompting the following. "I-Tunes was unable to load data class information from sync sevices." Reconnect of try again later. Another prompt that keeps appearing is "the application apple mobile device help quit unexpectedly." Please help me...
Apple Mobile Device Restart. Disable all security software ex. Firewalls and Antivirus. Follow article http://support.apple.com/kb/TS1567 . The above listed article is correct by lllaass. I resolve it by unchecking the different categories in itunes sync pages... Plug in device, click on name on left side of itunes, Click on different sync pages like summary, info, music, movies, etc. You need to uncheck the main check box to sync content. An example would be unchecking "Sync Music" . You will then need to sync once for each category until you locate the source of your corrupt files or folders. Syncing without it checked removes content from device. Follow this step even if there is nothing on the device. Once you identify if it is picture or music etc. you will need to delete corrupt files or move them somewhere else on the computer so itunes can't find it anymore.
-
What am i doing wrong with this class please help
What am i doing wrong with this class? I'm trying to create a JFrame with a JTextArea and a ScrollPane so that text can be inserted into the text area. however evertime i run the program i cannot see the textarea but only the scrollpane. please help.
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class Instructions extends JFrame{
public JTextArea textArea;
private String s;
private JScrollPane scrollPane;
public Instructions(){
super();
textArea = new JTextArea();
s = "Select a station and then\nadd\n";
textArea.append(s);
textArea.setEditable(true);
scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.getContentPane().add(textArea);
this.getContentPane().add(scrollPane);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Instructions");
this.setSize(400,400);
this.setVisible(true);
}//end constructor
public static void main(String args[]){
new Instructions();
}//end classI'm just winging this so it might be wrong:
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class Instructions extends JFrame{
public JTextArea textArea;
private String s;
private JScrollPane scrollPane;
public Instructions(){
super();
textArea = new JTextArea();
s = "Select a station and then\nadd\n";
textArea.append(s);
textArea.setEditable(true);
scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// Here you already have textArea in scrollPane so no need to put it in
// content pane, just put scrollPane in ContentPane.
// think of it as containers within containers
// when you try to put them both in at ContentPane level it will use
// it's layout manager to put them in there side by side or something
// so just leave this out this.getContentPane().add(textArea);
this.getContentPane().add(scrollPane);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Instructions");
this.setSize(400,400);
this.setVisible(true);
}//end constructor
public static void main(String args[]){
new Instructions();
}//end class -
Accessing a thread from a main class, please help!
Hi, I have a thread, T1, that I need to access from my main class. I cannot use runnable, it's got to be done with extands thread. I can start it alright, but I cannot stop it;
MAIN CLASS
public class Uppgift1 {
public static void main(String args[]) throws InterruptedException {
// Start Thread 1
Thread trad1 = new T1( );
trad1.start( );
//Wait for 5 seconds
Thread.sleep(5000);
//Stop the Thread
trad1.stopIt();
public class T1 extends Thread {
boolean go = true;
public void run ( ) {
while(go){
System.out.println("T1: Trad 1");
try{
Thread.sleep(1000);
} catch( InterruptedException e ) {
public void stopIt(){
go = false;
Why can't I run stopIt from my main class?
Please help me.manswide wrote:
The reason I have to use Thread is that it's for a school thing; I guess I gotta learn to do it the bad way in order to learn why to love the good way later on.Good plan. Making mistakes is a fantastic learning tool
How do I declare a reference to my own class?
T1 t1 = new T1(); -
Calling an instance of a class please help
Hi all,
I hope this is the right forum to post this topic.I am doing so cause I am dealing with servlets.In the init() method of a servlet.I want to call an instance of another class UserPresent.java .I will post the code below
public void init() {
UserPresent userpresent = new UserPresent();
userpresent.initDatabase();
}The compiler keeps complaining saying that .......
AuthenticateServlet21.java:12: cannot resolve symbol
symbol : class UserPresent
location: class package1.structure.AuthenticateServlet21
UserPresent userpresent = new UserPresent();
I have included the package package1.structure in both the servlet code and the UserPresent code.
Kindly let me know what could be the problem.
Help would be appreciated
Thanks
ASThe compiler can't find the UserPresent class in your servlet.
You may need to import it ie import package1.structure.UserPresent
What package is the UserPresent class in? What package is your servlet in? Is your class public? -
Oc4j startup classes - please help!
I am trying to create a startup class for my Oc4j container. I have created a new class with all the required code. However when I come to update my server.xml config file like so:
<startup-classes>
<startup-class classname="MyStartupClass" failure-is-fatal="true">
<execution-order>0</execution-order>
</startup-class>
</startup-classes>
The container on initialisation says that the class cannot be found. I have also tried giving the fully qualified package name as the class name i.e. com.blah.blahh.MyStartupClass. However still no success.
Anyone know why this is happening and how I can get the container to find my startup class?make a jar of ur classes and put it in(u can put single class also)
jdev--\j2ee\home\applib
put this line in the server.xml file
<init-library path="../applib" />
try this...
Hope this helps
N@vin -
Can't find MenuAdapter class,please help
Hello!In the book I'm reading the author said that if i want to disable some menu items i should add a listener to the JMenu that contains the respective JMenuItems.The only problem is that i don't seem to find the class MenuAdapter.I looked over the net and seen that it should be in the package org.eclipse.swt.events.MenuAdapter.I have installed JDK6u14 and in my c:\jdk6u14\src\org i don't have this eclipse folder.What am i missing guys? Thank you
Alex_Denny wrote:
Excuse i'm beginner but are you saying that i should use the Eclipse IDE so that i can have that class? (cause i'm using NetBeans).What he's actually saying is: Ask a specific question. It's impossible to answer such a vague, contextless question. We don't even know what you're trying to do, and I suspect that org.eclipse.swt.* has nothing to do with it, and that your guess that it might has just muddied the water.
So... What are you trying to do... give us everything you know... and then ask a specific question.
An SSCCE might be a good place to start.
Cheers. Keith. -
Adapters vs anonymous inner class (please help)
I am trying to clean up my code by using anonymous inner classes to handle some action events. My code looks like this but I get an error
Button.addActionListener(new MyClass() {
public void actionPerformed(ActionEvent e) {
my_Button_actionPerformed(e);
it says that it cant find MyClass, but I thought I dont need to define it becaue I am defining it here, isnt that the point of a anonymous inner classyourBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
});(BTW: use code tags in posting!) -
Graphing Classes: Please Help
I am in need of a real-Time trend graph implementation. I have not seen this on the net anywhere. I am porting over a QNX application to Java. QNX through PhaB has a real-time trend widget, we used to model data over time. Has anyone seen something similar done in Java? Any help would be appreciated. Thanks.
JFreeChart might do what you want:
http://www.object-refinery.com/jfreechart/index.html
It's not really designed for real time charts (each data change redraws the whole chart) but if you are only updating the chart every 5 seconds or so, it might meet your requirements.
JFreeChart is open source (LGPL) so it will only cost you your time to evaluate it...
Regards,
Dave Gilbert
www.object-refinery.com -
ACCT Determination question- Very urgent please help
URGENT:
When I was using transaction MB1C (Enter Good Receipts):
I wanted to post goods receipt for material-A for 100 pieces.
I am getting the following error
Account determination for entry RRKA TAW QJ01 ___ 9910 not possible
I went on to look for help I got the following diagnosis:
The system did not find an account for this transaction. This means that the account determination for key TAW QJ01 ___ 9910 is not maintained in MM Customizing (Valuation). The key is made up of:
Chart of account
Transaction key (= Posting transaction)
Valuation grouping code
Account grouping code
Valuation class
Please help me what I should do!!!!
This very urgentEnter T_Code OBYC
Slect account assignment and proceed with below steps
.Chart of account-RRKA
Transaction key (= Posting transaction)-TAW
Valuation grouping code-QJO1
Account grouping code-BLANK
Valuation class-9910
AND enter GL a/c No. with the help of FI/CO Buddy's
ok
Otehrwise in diagonisis click proceed it will shows the path and what u can take the inputs on this issue.U will know automaatically. -
Unable to SetUP JMF2.1.1 in XP .... Please Help
I just unable to setting up the PATHs in my XP Home Edition. I had followed all the setps on setting up the JMF & the PATH as well.
I installed the JMF at C:/Program Files/JMF2.1.1
CLASSPATH=%JMFHOME%\lib\jmf.jar;%JMFHOME%\lib\sound.jar;.;%CLASSPATH%
After that, the JMF Diagnostics Applet unable to find my JMF classes
please help me...
CalIt might be worth trying installing the JMF folder at the root of C after uninstalling again. It worked on my machine (running XP Home).
Lewis -
Please help with my helper class
Hi,
plz I need some assistance with this:
I have a big table which consist of 200 columns. This table gets fields from different tables. It has records of orders which may have several items and each item can have up to 8 taxes. So i have fields reaping for other order order records. I need to display an order then have a navigation to list items in details, with all its taxes, one by one.
Here is how I have decided to do it in a nutshell. I have decided to get all taxes of a particular item and put in a map with tax_codes as values and tax details arraylist as values. I then add this to an item with its other details. then I add items to a particular order. I have separated orders,items and taxes in their separate beans. Im trying to first the implimentation for each order, item and taxes by displaying them on a JSP. However am currently getting the following error with taxdetails:
java.lang.ClassCastException: OrderItems.ItemTax cannot be cast to java.lang.String
at OrderItems.OrderDetails.getItemTaxDetails(OrderDetails.java:166)
at OrderItems.Controller.processRequest(Controller.java:57)
at OrderItems.Controller.doGet(Controller.java:72)
I have a list of all itemTaxCodes am iterating and am casting to string...am not casting ItemTax object.Here is my code below:
OrderDetails.java
package orderitems;
import java.sql.*;
import java.util.*;
public class OrderDetails {
private LineOder lineOrder;
private Map lineItems;
//returns an item number, key_item, from its unique keys
public int getItemNumber(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
int itmNum = 0;
* key_item a unique number for an item.
* key_year,key_office,key_client,key_company unique keys
* for each order where this key_item is taken
* from.
String select = "SELECT key_item FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
if(rst.next()){
itmNum = Integer.parseInt(rst.getString("key_item"));
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itmNum;
//get a list of item number(item codes)
public List getAllItemNumbers(String key_year,
String key_office,String key_client,String key_company){
List itemNumbers = new ArrayList();
LineItem itemNumber = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
itemNumber = new LineItem();
itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
itemNumbers.add(itemNumber);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemNumbers;
//get a list of tax codes
public List getAllTaxCodes(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
ItemTax taxCode;
List taxCodes = new ArrayList();
int itemNum = getItemNumber(key_item, key_year,
key_office,key_client,key_company);
String select = "SELECT key_tax_code FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
taxCode = new ItemTax();
taxCode.setKey_tax_code(rst.getString("key_tax_code"));
taxCodes.add(taxCode);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return taxCodes;
//use tax code to get tax details
public Map getItemTaxDetails(String key_year,String key_office,
String key_client,String key_company,int key_item){
ItemTax taxDetail = null;
List taxDetails = new ArrayList();
List itemTaxCodes = new ArrayList();
Map itemTaxdetails = new HashMap();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//get a list of all tax codes of an item with a
//given item number
itemTaxCodes = getAllTaxCodes(key_item,key_year,///a list of tax codes
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
String taxCode = (String)taxCodeIter.next();/////casting taxtCode to string***exception occurs from here
String select = "SELECT tax_type,tax_value," +
"tax_limit_val FROM "+ Constants.WEB_TABLE +
" WHERE key_item = "+ key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'" +
" AND key_tax_code = '" + taxCode + "'";///tax code string
rst = stat.executeQuery(select);
while(rst.next()){
taxDetail = new ItemTax();
//records to be displayed only
taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
taxDetail.setTax_value(rst.getString("tax_value"));
taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
//////other details records ommited//////////////////////////
taxDetails.add(taxDetail);
//a HashMap of all tax code as keys and list of details as values 4 each key
for(int i = 0;i<itemTaxCodes.size(); i++){
itemTaxdetails.put(itemTaxCodes.get(i),taxDetails.get(i));
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemTaxdetails;
//details of an item with all its taxes
public List getAllItemDetails(String key_year,
String key_office,String key_client,String key_company){
List lineItems = new ArrayList();
List itemNumbers = new ArrayList();
Map taxDetails = new HashMap();
LineItem item = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//A list of all item numbers in the declaration
itemNumbers = getAllItemNumbers(key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
int itemNumber = ((Integer)itemIter.next()).intValue();
String select = "SELECT item_description,item_mass," +
"item_cost" +
" FROM " + Constants.WEB_TABLE +
" WHERE key_year = '"+key_year+"'" +
" AND key_office = '"+key_office+ "'"+
" AND key_client = '"+key_client+ "'"+
" AND key_company = '"+key_company+ "'"+
" AND key_item = " + itemNumber;
rst = stat.executeQuery(select);
while(rst.next()){
item = new LineItem();
item.setItem_description(rst.getString("item_description"));
item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
//////other details records ommited//////////////////////////
//A HashMap of all itemTaxeCodes as its keys and an ArrayList of itemTaxedetails as its values
taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
item.getKey_client(),item.getKey_company(),item.getKey_item());
//item tax details
item.setItmTaxes(taxDetails);
//list of items with tax details
lineItems.add(item);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineItems;
public Set getDeclarations(String key_year,String key_cuo,
String key_dec,String key_nber){
List lineItems = new ArrayList();
Set lineOrders = new HashSet();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
LineOder lineOrder = null;
String select = "SELECT * FROM " + Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_cuo = '" + key_cuo + "'" +
" AND key_dec = '" + key_dec + "'" +
" AND key_nber = '" + key_nber + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
lineOrder = new LineOder();
lineOrder.setKey_year(rst.getString("key_year"));
lineOrder.setKey_office(rst.getString("key_cuo"));
lineOrder.setKey_client(rst.getString("key_dec"));
lineOrder.setKey_company(rst.getString("key_nber"));
////list of items with all their details
lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
lineOrder.getKey_client(),lineOrder.getKey_company());
//setting item details
lineOrder.setItems(lineItems);
//a list of order with all details
lineOrders.add(lineOrder);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineOrders;
} and my testing servlet controller
Controller.java
package orderitems;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Controller extends HttpServlet {
private Map taxDetails = new HashMap();
//private List itemDetails = new ArrayList();
//private Set orderDetails = new HashSet();
private OrderDetails orderDetails = null;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String key_year = "2007";
String key_office = "VZX00";
String key_company = "DG20";
String key_client = "ZI001";
int key_item = 1;
String nextView = "/taxdetails_list.jsp";
//String nextView = "/order_list.jsp";
//String nextView = "/items_list.jsp";
orderDetails = new OrderDetails();
taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
key_company,key_client,key_item);
//Store the collection objects into HTTP Request
request.setAttribute("taxDetails", taxDetails);
RequestDispatcher reqstDisp =
getServletContext().getRequestDispatcher(nextView);
reqstDisp.forward(request,response);
protected void doGet(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
protected void doPost(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
}I have not included code for beans to reduce on bulk.please help and with suggestions...
Thanx in advance.
Edited by: aiEx on Oct 3, 2007 8:13 AMaiEx wrote:
sometimes a tap on the head is needed to really learn and understand :-)You're casting them to the String type while they are of the ItemTax type and you've confirmed it yourself. Likely you misunderstood the concepts behind "casting" and you was expecting some magic that they are automatically converted somehow from the ItemTax type to the String type while the ItemTax class isn't a subclass of the String class :) -
Please help me for Calendar class
Now i am working in SAP.Now we are doing Internal project for Company Timesheet of the employee,they are using Java,javascript,html,jsp,mysql.
Please give Support for developing this task
I am trying to do employee's timesheet( i.e. daily working hours).Here i attach my documents.here in that screen i am selecting fig1 calendar date for 19th july 2006 now we can see it in fig2 there we will see 15th july 2006 to 21st july 2006 is visible. The scnario is when ever we select the any of the day of the week we need to display whole week sun,mon to sat.
when i am selecting (select week days by using javascript) total weekly working hours should come.please guide me and give me sample code.
I think you understand what i am asking. using javascript calendar i am selecting the date.and from database i have to get the daily working hours of the perticular employee. I am not so familiar in java,that's why only i am asking .Please help me
Advance thanks for You
code i am pasting here
thanks&Regards
Vijaya
********** Java code******************
import java.util.Calendar;
import java.util.Date;
class FirstAndLastDay4
public static void main(String[] args)
//int i=1;
try{
Calendar date=Calendar.getInstance();
int day = date.get(Calendar.DAY_OF_WEEK);
switch(day){
case(1):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK));
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(2):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(3):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-2);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(4):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-3);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(5):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-4);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
/*for(int i=0,j=1;i<7;i++)
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+i);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(6):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-5);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(7):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-6);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
}catch(Exception e){
e.printStackTrace();
}Hi All,
I am trying to do employee's timesheet( i.e. daily working hours).Here i attach my documents.here in that screen i am selecting fig1 calendar date for 19th july 2006 now we can see it in fig2 there we will see 15th july 2006 to 21st july 2006 is visible. The scnario is when ever we select the any of the day of the week we need to display whole week sun,mon to sat.
when i am selecting (select week days by using javascript) total weekly working hours should come.please guide me and give me sample code.
Thanks in advance
thanks & regards
<code>
import java.util.Calendar;
import java.util.Date;
class FirstAndLastDay
public static void main(String[] args)
try{
Calendar date=Calendar.getInstance();
int day = date.get(Calendar.DAY_OF_WEEK);
switch(day){
case(1):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK));
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(2):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-1);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(3):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-2);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(4):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-3);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(5):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-4);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(6):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-5);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
case(7):
{ System.out.println("\n Input date [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)-6);
System.out.println("First day [" + new java.util.Date(date.getTimeInMillis()) + "]");
date.set(Calendar.DAY_OF_WEEK, date.get(Calendar.DAY_OF_WEEK)+6);
System.out.println("Last day [" + new java.util.Date(date.getTimeInMillis()) + "]");
break;
}catch(Exception e){
e.printStackTrace();
</code>
Maybe you are looking for
-
I need to download a DVD and some CDs to my new MacBook Pro but alas, no CD/DVD drive. What now?
-
Pictures not viewable in Firefox
Added another page to my website last night, when I came to work this morning to check out the pictures, I realized that they are not viewable using my firefox browser, safari and IE work fine, any ideas? I had a similar problem when the .me changeov
-
How to un-group columns on my the report and how to add an export to PDF
Hello OBIEE developers... So, I have this report with about 7 columns, I just submitted to my boss he came back saying "Don't group the columns, the users typically want to see data on each row".... I am not quite sure what in the world he is talkign
-
Imovie has Idvd in the share drop down but i can't find it
movie has Idvd in the share drop down but i can't find it
-
Preview goes to Homepage, not file
When I press preview, a new instance of the browser is opened up and it defaults to the home page, not the file I am editing and trying to preview. Any solutions?