Problem in writing file....
hi
i am using tomcat 5.0.19 what my application doing is allowing a user to upload a text file
and before processing it the file is writen to the Specified path on server directory(for backup purpose).
the problem is in writing the file. the file is written to the specified location but the size is
reduced to approx 1/3 ie a file of 100 kb to 30kb. the code which i am using is given below..
one more thing it is working fine except for one system . Is there any problem in tomcat or
the code is creating some probs...
plz help....
public void writeToFile(String fileName) throws IOException, FileNotFoundException{
//writes Uploaded File to the Specified path on server directory;
OutputStream bos = new FileOutputStream(fileName);
InputStream stream = destinationNumberFile.getInputStream();
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
//close the stream
bos.close();
stream.close();
}thanks in advance..
if so try to call the flush() method on bos before close it.Closing implies flushing, there is no need to invoke it "by hand".
Similar Messages
-
Problems with writing files after migration
I migrated my old Pismo HD to a new MacBook Pro (a frustrating process which I eventully had to accomplish using a clone of the Pismo disk and a firewire drive) and have a couple of issues.
The most troublesome at the moment is a problem with Safari. It will not let me download files when I am operating as the migrated user, although it will allow downloads if I log in as the user I established during initial setup.
I am also having trouble using Spotlight or the Find utility. Most of the time when I use these, the computer either goes into a kernel panic or grinds away for minutes and never finds anything before I give up in frustration. However, the find function on the top right of finder windows works well.
Any suggestions welcome, thanks!
Various Mac OS X (10.4.8)Thanks for the suggestions. I had already tried the "Get Info" route with Safari.
The "sudo mdutil -E /" seems to have worked for Spotlight. I did get an error message saying that my volume was not indexed; however, it seems to work now. (I'll get around to indexing the disk eventually.)
I repaired the permissions on my startup disk from the install CD, but the Safari problem is still there (same problem with Firefox).
Any other ideas most appreciated. -
JME Socket File Transfer - Problem with writing file
Hi everybody, i'm trying to code a P2P app for a school project and i have a problem when trying to write to a file.
This method recieves a file form a Socket Server computer that tries to send me a file to the mobile client.
The method recieves the IP adress (String add) and the port of the server.
Also, i would like to know about the buffer(byte) size.
This codes runs well in emulation, but it doesn`t write to a file.
And the main problem is:
"When i run this in the mobile, the file is created in the cellphone memory with a size of 0kb."
The server code was tested with a computer client and recieved the file succesfully.
The server recieves de socket connection form the cellphone without problem.
public void recibirArch(String add, int port) throws Exception {
try
recibArch.setText("Espere por favor...");
long start = System.currentTimeMillis();
int bytesRead;
int pasos = 12;
int current =0;
SocketConnection sock = (SocketConnection)Connector.open("socket://"+add+":"+port);
byte [] mybytearray = new byte [1024];
InputStream is = sock.openInputStream();
FileConnection fc = (FileConnection) Connector.open("file:///"+saveRoot+"5letras.txt",Connector.READ_WRITE );
if( !fc.exists() ){
fc.create();
} else
fc.truncate(0);
DataOutputStream fos = new DataOutputStream(sock.openOutputStream());
bytesRead = is.read(mybytearray,0,mybytearray.length);
current = bytesRead;
while ((current = is.read(mybytearray)) != -1)
fos.write(mybytearray, 0, current);
fos.flush();
current+=bytesRead;
long end = System.currentTimeMillis();
fos.close();
sock.close()
catch(Exception err)
String error = "ERROR: " + err.toString() + "\nDescripción: "+ err.getMessage();
System.out.println(error);
txtLog.setString(error);
Edited by: xtylo on Sep 30, 2008 10:56 AMThank you Tunde for looking at my issues!
The file size is not an issue here. We tested with empty files or files with smaller than 1KB sizes. They all showed problem. The frequency of file transfer shouldn't be a problem either. Through some user interaction on front panel, a couple of files will be transferred. That's basically how often the file transfer occurs.
Interestingly enough, I replaced the copy.vi with a subvi I created using DOS command with System Exec.vi and the issue of copying files went away. My co-worker tested on both XP machine and Windows 7 machine. The DOS command worked fine thru Lavview's System Exec.vi. I think I can take that as a work-around if we can't figured out why copy.vi wouldn't work. Still, it would be nice to know why it doesn't work.
Now I'm still facing some issues with the usage of Check If File or Folder exist.vi. Sometimes it can detect the existing files and sometimes it doesn't.
Thanks very much! -
Problem loading / writing files.
Hi, im trying to create and load a file to the user's home directory as follows:
File f = new File(System.getProperty("user.home") + "/settings.xml");
if (f.exists() == false)
try
// If the file doesn't exist, create one.
f.createNewFile();
// Get the url.
URL filePath = f.toURI().toURL();
The file is created properly and exists in the proper directory. However, when i try to use the URL to write out to
file later i get the following error:
C:\Documents%20and%20Settings\User\settings.xml (The system cannot find the path specified)
I believe this is due to the %20's within the URL, how can i remove / handle these? Am i doing something incorrectly?
Also, if the file exists, i try to load it with the following code:
URL filePath = this.getClass().getClassLoader().getResource(System.getProperty("user.home") + "/settings.xml")
However the URL that is return is null and i dont know why.
thanks for the help.Why do you want an URL for the file? Use the File object to create a FileInputStream or FileReader.
-
Problem while writing to fixed length flat file from xml
Hi,
I have a problem in writing data into a flat file of fixed length...
My input is a xml file and i want the output as a flat file. I am successful in converting the xml into flat file... But the main problem is, i am unable to insert spaces in between my fields in the flat file.
The data in the flat file comes without spaces... Any suggestions on writing the schema...
Regards
Surya.Have a look at this doc
http://otndnld.oracle.co.jp/document/products/as10g/101310/doc_cd/integrate.1013/b28994/nfb.htm#BGBBAJFD
your element should be something like this, it pads with a space using the paddedBy expression
<xsd:element name="C1" type="xsd:string" nxsd:style="fixedLength" nxsd:length="4" nxsd:paddedBy=" " nxsd:padStyle="tail" />if having trouble post what you want the file to look like, and the xsd you are using.
cheers
James -
Director 12- can't create a windows projector - problem writing file error
I am trying to create a windows projector of a project. when I get the following error - problem writing file - file name- Can't compress file that has been modified and not saved. The file has not been modified and has been saved. Any help would be great.
Hi.
You say you have tried publishing to a new empty folder. From the video I can see that the folder has table1.app in there (25 secs in) which is a Mac projector that has been published.
Yet you have Windows Projector checkbox ticked at the start of the video.
I publish Mac and Windows projectors to entirely seperate folders as a matter of practice.
I call the folders "Published" and "PublishedMac" and that is where the respective projectors for each piece of software lives.
Perhaps there is some mix up between Mac and Windows publishing that is going on because
you are publishing both to the same folder?
Hope this helps.
Richie -
whan i am writing the file to FTP in foreground it is working fine.but in backgruond it is failing .what would be the problem...
i using the below code..
FORM ftpfinanceaccess_download USING p_host
p_user
p_password.
DATA :
dest LIKE rfcdes-rfcdest VALUE 'SAPFTP',
compress TYPE c VALUE 'N',
host(64) TYPE c.
DATA: hdl TYPE i.
DATA: BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
DATA : key TYPE i VALUE 26101957,
dstlen TYPE i,
blob_length TYPE i.
host = p_host .
DESCRIBE FIELD p_password LENGTH dstlen IN CHARACTER MODE.
CALL 'AB_RFC_X_SCRAMBLE_STRING'
ID 'SOURCE' FIELD p_password ID 'KEY' FIELD key
ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD p_password
ID 'DSTLEN' FIELD dstlen.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = p_user
password = p_password
host = host
rfc_destination = dest
IMPORTING
handle = hdl
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc = 0.
CONCATENATE 'cd' ftppath INTO ftppath SEPARATED BY space .
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = ftppath
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc = 0 .
CLEAR result .
REFRESH result .
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = 'ascii'
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc = 0 .
DESCRIBE TABLE iresult LINES lines.
blob_length = lines * width .
clear : lines.
Delete the existing file
CONCATENATE 'del' ftpfile INTO delfile SEPARATED BY SPACE.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = delfile
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
*End of deleting the existing file
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = hdl
fname = ftpfile
blob_length = blob_length
CHARACTER_MODE = 'X'
TABLES
TEXT = iresult
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF sy-subrc <> 0 .
WRITE 'Error in writing file to ftp' .
ELSE.
WRITE 'File downloaded on the ftp server successfully'.
ENDIF.
ENDIF.
ELSE.
WRITE : 'Path on ftp not found : ' , ftppath .
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = hdl.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = 'SAPFTP'
EXCEPTIONS
OTHERS = 1.
ELSE.
WRITE 'Could not connect to ftp' .
ENDIF. -
Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db. No indication what the problem is. How do I get adobe help with these problems?
Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db. No indication what the problem is. How do I get adobe help with these problems?
-
Problem while writing data on xls file using jxl API
Hi,
I am getting problem while writing data on excel file using jxl api.
When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
here is code:
FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
WritableWorkbook this.workbook = Workbook.createWorkbook(os);
after writing data following handler are closed:
this.os.flush();
this.workbook.write();
this.workbook.close();
this.os.close();
this.os = null;
can any body help me.
Thanks in advanceErr, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
But it happens often enough that it also makes me think I'm just wasting my time. Probably I am. -
Error reading/writing file message when opening garageband and/or files
I've been recently getting this message when I open garageband and files
"Error reading/writing file\U201Ccom.apple.garageband.cs\U201D
I've been in and repaired disk permissions and all that it says it is all fine, reinstall garageband and message still comes up, weird.
not only is garageband being a nuisance, Mac OS X 10.6.2 is being a pain when shutting down telling me to restart the computer. This only happened since upgrading to 10.6. No one as yet knows this promble so I'm gonna have to ring apple and see what is going on here.
and also my other problem is that mac doesn't seem as snappy anymore I noticed this before upgrading to 10.6 and made no difference when "cleanly" installing 10.6. I get a colour wheel popping up and i'm having to wait with simple tasks. iMac only 2 years old.i give up with this discussion forum no no one knows anything
-
Problem with writing and reading using serialization
I am having a problem with writing and reading an object that has another object in it. The purpose of the class is to write a order that has multiple items in it. And there will be several orders. This is for an IB project, where one of the requirements is to utilize a hierarchical composite data structure. That is, it is "one that contains more than one element and at least one of the elements is a composite data structure. Examples are, an array or linked list of records, a record that has one field that is another record, or an array". The code is shown below:
The error produced is
java.lang.NullPointerException
at SamsonRubberIndustries.CustomerOrderDetails.createCustOrdDetailsScreen(CustomerOrderDetails.java:150)
at SamsonRubberIndustries.CustomerOrderDetails$1.run(CustomerOrderDetails.java:78)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
public class CustOrdObject implements Serializable {
public int CustID;
public int CustOrderID;
public Object OrderDate;
public InnerCustOrdObject[] innerCustOrdObj;
public float GrandTotal;
public int MaxItems;
public CustOrdObject() {}
public CustOrdObject(InnerCustOrdObject[] innerCustOrdObj,
int CustID, int CustOrderID, Object OrderDate,
float GrandTotal, int innerarrlength, int innerarrpos, int MaxItems) {
this.CustID = CustID;
this.CustOrderID = CustOrderID;
this.OrderDate = OrderDate;
this.GrandTotal = GrandTotal;
this.MaxItems = MaxItems;
this.innerCustOrdObj = new InnerCustOrdObject[MaxItems];
public InnerCustOrdObject[] getInnerCustOrdObj() {
return innerCustOrdObj;
public void setInnerCustOrdObj(InnerCustOrdObject[] innerCustOrdObj) {
this.innerCustOrdObj = innerCustOrdObj;
public int getCustID() {
return CustID;
public void setCustID(int custID) {
CustID = custID;
public int getCustOrderID() {
return CustOrderID;
public void setCustOrderID(int custOrderID) {
CustOrderID = custOrderID;
public Object getOrderDate() {
return OrderDate;
public void setOrderDate(Object orderDate) {
OrderDate = orderDate;
public void setGrandTotal(float grandTotal) {
GrandTotal = grandTotal;
public float getGrandTotal() {
return GrandTotal;
public int getMaxItems() {
return MaxItems;
public void setMaxItems(int maxItems) {
MaxItems = maxItems;
public class InnerCustOrdObject implements Serializable{
public int ItemNumber;
public float UnitPrice;
public int QuantityRequired;
public float TotalPrice;
public InnerCustOrdObject() {}
public InnerCustOrdObject(int ItemNumber, float
UnitPrice, int QuantityRequired, float TotalPrice){
this.ItemNumber = ItemNumber;
this.UnitPrice = UnitPrice;
this.QuantityRequired = QuantityRequired;
this.TotalPrice = TotalPrice;
public int getItemNumber() {
return ItemNumber;
public void setItemNumber(int itemNumber) {
ItemNumber = itemNumber;
public int getQuantityRequired() {
return QuantityRequired;
public void setQuantityRequired(int quantityRequired) {
QuantityRequired = quantityRequired;
public float getTotalPrice() {
return TotalPrice;
public void setTotalPrice(float totalPrice) {
TotalPrice = totalPrice;
public float getUnitPrice() {
return UnitPrice;
public void setUnitPrice(float unitPrice) {
UnitPrice = unitPrice;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems;
private static boolean FileExists, recFileExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.dat");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord-1);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
//TotPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++CurrentRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
setInnerFieldText(currentItem);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
//readOrder();
setInnerFieldText(currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
writeRecordNumber(MaxRecord);
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
currentItem++;
setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
System.err.println("currentItem" + currentItem);
getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07
Message was edited by:
Kilik07ok i got reading to work to a certain extent... but the prob is i cnt seem to save my innerCustOrdObj proprly...when ever i look for a record using the gotorecordbtn, the outerobject, which is the orderDetails, seems to change but the innerCustOrdObj remains the same... heres the new code..
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems = 1;
private static boolean FileExists, recFileExists;
private static boolean RecordExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.ser");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
//CurrentRecord--;
//System.out.println("Current Rec Here"+CurrentRecord);
if(orderDetails[CurrentRecord] == null){
System.err.println("CustomerOrderObj 1 is null !!");
}else{
System.err.println("CustomerOrderObj 1 is not null !!");
if(orderDetails[CurrentRecord].getInnerCustOrdObj() == null){
System.err.println("InnerCustomerOrderObj is null !!");
}else{
System.err.println("InnerCustomerOrderObj is not null !!");
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord);
getInnerFieldText(MaxItems);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
//CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
TotPriceTxt.setEditable(false);
TotPriceTxt.addFocusListener(new FocusAdapter(){
public void focusGained(FocusEvent evt){
TotPriceTxt.setText(""+Integer.parseInt(UnitPriceTxt.getText())*Integer.parseInt(QuantityReqTxt.getText()));
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println("Current Record " + CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
CurrentRecord = MaxRecord;
orderDetails[CurrentRecord] = new CustOrdObject();
writeRecordNumber(MaxRecord);
MaxItems = 1;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
setInnerFieldText(MaxItems);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
MaxItems++;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
System.out.println("Max Items "+MaxItems);
currentItem = MaxItems;
orderDetails[CurrentRecord].setMaxItems(MaxItems);
///setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
gotorecordbtn = new JButton("Go To Record", createGotoButtonIcon());
gotorecordbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt){
* The text from the GotorecordTxt textfield will be taken and assigned
* to a temporary integer variable called Find.
int Find = Integer.parseInt(CustOrderIDTxt.getText());
for(int j=1; j <= MaxRecord; j++){
* Using a for loop, each record can be read using the readCustRecord
* method.
getFieldText(j);
* An if condition is utilized to check whether the temporary stored variable, Find,
* matches a field in a record. If this record is found, then using the RecordExists
* which was declared at the top, either a true or false statement can be assigned
* If the record exists, then a true statement will be assigned, if not a false
* statement will be assigned.
if(orderDetails[j].getCustOrderID() == Find){
RecordExists = true;
break;
}else{
RecordExists = false;
if(RecordExists == false){
* If the RecordExists is assigned a false statement, then a message will be
* displayed to show that the record does not exist.
JOptionPane.showMessageDialog(null, "Record Does Not Exist!", "Error Message", JOptionPane.ERROR_MESSAGE, createErrorIcon());
}else{
getFieldText(Find);
buttonpanel.add(gotorecordbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setMaxItems(MaxItems);
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
orderDetails[orderID].getInnerCustOrdObj();
System.err.println("currentItem" + currentItem);
//getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
/* System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());*/
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07 -
Logic froze while I was working on something so I forced quit. Now every time I open LOGIC a message pops up that says:
"Error reading/writing file
“com.apple.logic.pro.cs”:
Logical end-of-file reached during read operation."
The only button option is cancel so I press it and another message appears that says:
"The Preferences are not loaded completely.
Do not save them, as you would overwrite the Preferences file with incomplete data."
Then when i close logic a box appears saying:
"The Preferences are not loaded completely.
Save them to "com.apple.logic.pro.cs" anyway?"
There are 3 button options to press; ok, cancel or dont save.
I press "don’t save" cuz I don't want to ruin anything.
I found a discussion located here: https://discussions.apple.com/message/9564253#9564253 that says if I delete the file "com.apple.logic.pro.cs" it will resolve the problem. If I do this will I loose or mess anything up at all, automation, saved channel strips customizations, saved effects, synth, or ultrabeat customizations etc? Or especially will I loose any work I've done? I have hundreds pieces of music files I've created. I'm scared to mess anything up with all the hours and months of work I've done. Is there anyway to fix this without loosing anything? I'm using Logic Pro 8.
Thank youYou can safely delete this file - its the preference file for control surface settings - you haven't said whether you're actually using a control surface or not, if so, you will have to set it up again. A new file will be created when you fire Logic up again, but of course it will contain default settings. If you have a complicated control surface setup, remember to keep a backup copy somewhere in case any future problems arise.
Other than that, you really have nothing to be scared about - hopefully your problem is as simple as that and there isn't an underlying problem (a corrupt hard drive, for example). You seem concerned about losing work, so I guess you want to think about backing that up on a regular basis too. If you're saving your projects to your system drive, do get an external one for this. And also check that you have plent of free space on your system drive - you need to keep about a quarter or third of it free for your OS and programs to run properly (some temporarily stored files can be quite large). -
I tried to move my PE6 install and catalog to a new computer. It was on a Dell Windows XP machine, and I moved it to a Toshiba Windows 7 (64 bit) machine. I have always kept my photo files on an external hard drive. My photo library is 50GB, 10,000 files. Here is what I did.
Copied the original PE6 install file to the Toshiba. Installed but didn’t activate it.
Copied the entire My Catalog folder to the proper Windows 7 location.
Plugged the external drive into the Toshiba. Made sure the same drive letter as before (E).
Fired up PE6 on Toshiba. Looked good in Organizer. Everything seemed to be there, but I didn't try to make changes at that point.
Deactivated PE6 on the Dell. Activated on the Toshiba.
Then I realized that it is not right. I can edit Keywords and Rating stars on the pics, but not dates, captions or notes. I get “An error occurred while reading files or writing files to disc. The disc may be full or there may be problems with the source media.”
Only a fraction of the external drive is in use.
I can access the files on the external drive with another app (Windows Photo Viewer).
I tried Reconnect All Missing Files. Somewhat ambiguously, it says “There are no files to reconnect.”
In the properties in the Organizer for each picture are the proper file names and paths. Folder view works fine in Organizer.
I can put new files in the same external drive directories, import them into PE6, then edit them normally.
What is the easiest way to get Organizer properly connected to my files? I suppose I could reimport all the pics on the new machine, but I assume I'd lose some of my metadata. So that is out of the question.
Thanks,
BillAre you sure that file paths are correct? I say this because under XP they would have originally pointed to Documents & Settings/My Pictures whereas on W7 it will be User/Pictures, albeit you are using an external hd.
Take a look at this knowledge base note on the correct procedure for back-up and restore.
I think writing metadata to files for such a large catalog will be a thankless task.
http://helpx.adobe.com/photoshop-elements/kb/backup-restore-move-catalog-photoshop.html -
Problem with Local File Identification in RFC
Dear all,
We are working on a scenario where we have to integrate an external application with SAP system. The external application would use SAP DMS as document repository; It will send us a local file path and we have to upload the document located in that path as an attachment to a DMS Document Info Record. We have designed a wrapper RFC for this purpose, which encapsulates the standard Fm BAPI_DOCUMENT_CREATE2. This BAPI takes a file path input under table parameter DOCUMENTFILES. Problem is, when we are running the RFC from SAP GUI, the document info record is created correctly with the document as attachment, but when we invoke the RFC from the external application, the process fails and we get an error message stating:"Error while checking in Original Files". We debugged the scenario and found out that, while running under SAP GUI, the BAPI is able to identify a GUI Link, and hence succeeds; but while calling from the external application, the BAPI fails to find a GUI Link, tries to start a FTP Server using RFC Destination SAPFTP, and fails. So, obviously, the BAPI is not able to parse the local file path because of non-existence of GUI Link. So,in this regard, my question is: is there no way that we can pass a local file path from an external application to SAP, and get the same identified and get the document uploaded? Is there any alternative to our approach?
Awaiting answers.
Regards,
SidSolved the problem by:
Converting file content to binary->transferring binary content to a wrapper RFC->writing the content into a temporary file in application server->then calling BAPI_DOCUMENT_CREATE2 to create the document without attachment->then calling CVAPI_DOC_CHECKIN to checkin the temporay file from application server.
Related references:
http://wiki.sdn.sap.com/wiki/display/PLM/DMSandbackground+processing
https://websmp130.sap-ag.de/sap/support/notes/504692
How to upload file from Web Dynpro into R/3 (BAPI_DOCUMENT_CREATE2)
Thanks to All who have contributed to the Solution.
Sincere Regards,
Sid -
Why am I getting the following error: An error occured while reading files or writing files to disc. The disc may be full or there may be a problem with the source media. I am running PSE10 on a iMac using OS X 10.7.3, my Mac has a 1TB hardrive of which about 150GB is used. I get this error when trying to delete a file out of the Organizer. The software worked fine until I installed it on my laptop, also a Mac, and tried to share files.
Hmm. What happens if you disable sharing, just as a test?
I don't think you can share organizer photos that way, since your versions don't really exist as images, just as a set of directions to organizer for recreate that state of your editing when needed, and you can't run organizer on a network drive, which is pretty much what you're trying to do if you mean you have PSE installed on the other computer and are tryng to use the same catalog for both.
Maybe you are looking for
-
I need to send a PDF document and have it display within the body of the email instead of as a download icon. I'm using Mail and it previews before I send it, but the end user gets a blank email with an attachment icon. Any ideas?
-
Update Software does not work anymore...
two days ago i`ve tried to download updates from software update option on Mac OS X 10.5.2 and then it tells me that: you`re not connected to the internet, try again later... when i come home from work, ive tried again and then the update software te
-
How to make own .sh to schedule?
hi i need to do some downloading stuff at night.i want that my linux system will woke up at 2.30am and do all the work.how to do this stuff? my specifically my actual questions are: Q1.how to scheduling a specific .sh file? Q2.how to make her awaken
-
I am sending data from R/3 to XI through abap Proxy . Data is not going to XI. It gives error HTTP status code 401 : Unauthorized I have checked the sm59 transaction of R/3.I have test the connection there but it gives message Http 1.0 empty request
-
Specified Order Grouping does not show if Distinct Count is Zero
Post Author: Hieu CA Forum: General Hello, I'm using Crystal Reports XI R2 with SQL data source. I have a cross-tab report with grouping in specified order. It's a report of applicants applying to a college. The grouping is of various majors (degrees