peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

this is your problem out = new FileOutputStream("inventory.dat"); .
Try this and see what happends out = new FileOutputStream("C:" + File.separator + "inventory.dat");

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1. Is there any reason for currCD = 0? Do you use it for something?

2. CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i); will retrive data about CD on position "i" of your list.
What is cdNameField.getText() for? Is it the way you retrieve CD name from cdEntry object?
Just checking few lines bellow it is not! cdNameField.setText(newCD.getName());

Ezzaral commented: Yes, he was completely missing all the hints I tried to give him. I really didn't want to just write code for him, but the points just wouldn't stick. +1
no1zson commented: Always helpful, even when I am showing little to no progress +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

My appology then :)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can replace "f, e & s" with names you want to use that was just quick example from Ezzaral. He should also remember that even if he is giving small code examples he should use meaningfull names to avoid confusion like now :).
This statement CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i); will retrive info about your CD from the list, starting from first position of list till the end or till it reach searched item. (Side note: Do you realy want to interupt that loop? What if you have more CD titles with searched keyword? Don't they count?)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Regular expression is answer to your problem. Ofcourse you can do it with substrings, but it is dirty work. Read up Sun tutorial on regular expressions here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Your code is messy. You should either call and execute commands in main method and remove private PieDataset readData() this method. Or from main method make call for the other one private PieDataset readData() which you place outside main method as you wanted previously by seing that bracklet commented out

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Instead of adding everything directly to JFrame getContentPane().add(artistLabel); add all components to JPanel

//First JPanel
JPanel allComponents = new JPanel();
allComponents.add(artistLabel);
allComponents.add(artistField);

=====================
//Second JPanel
JPanel myGraphic = new JPanel();
ShapesJPanel shapesJPanel = new ShapesJPanel();
myGraphic.add(shapesJPanel);


===========================
//Add JPanels to JFrame
getContentPane().add(allComponents);
getContentPane().add(myGraphics);

If you willing to learn you should not be ashamed of the mistakes that you do in process of learning. You should be ashamed if you would not want to learn just wanted results...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is what jwenting told me few months back while I had problem with my layout

Don't try to force your design into a single layoutmanager.
Layer your layout.
You could for example place a panel in the region of the gridbag that you want those two components to appear, set that to gridlayout, and place the components in the cells of that grid.
These cells can be individually configured to have different alignment properties.

Meaning, organize your component in groups of fever components, if necessary put them even on their own. Given them requered arrangement, in their own space and then after that put this separate layouts together. It is like building with LEGO.
Fastest solution for you will be to put all your existing components on to JPanel, create separate JPanel for graphic and then add these two JPanels to frame. That is the fastest you can do. Longer, but more satisfying would be doing some arrangements in existing code so it will not requere whole re-do. You have to admit no1zson that current layout is not best solution, specialy without fixed frame size....

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

It will not work as rest of your components(buttons, text fields and text area) just lay around un-organized and then you just try to show in another component.
I think people will argee with me when I say you need to group them.
This is what I do normaly

/* Default constructor of RenameImage object. */
    public void runRenameImage()
    {
    	renameFrame = new JFrame("Rename");    	
    	gbc.insets = new Insets(1, 1, 1, 1);
		buildGUI();
		renameFrame.setSize(470,470);
		renameFrame.setResizable(false);
		renameFrame.setLocation(150,150);
		renameFrame.addWindowListener(this);
    	renameFrame.setVisible(true);
		runRename = new RunRename(barProgress, labelProcess);
    }
    
    /* Method to setup GUI*/
    public void buildGUI()
    {
    	setupIndexPanel();
    	setupDestinationPanel();
    	setupOptPanel();
    	setupProcessPanel();
    	setupProgressPanel();
    	setupRenameLayout();
    }

=======================================

// Sortest example
public void setupProgressPanel()
    {
    	panelProgress = new JPanel();
    	Dimension size = new Dimension(440, 40);
        panelProgress.setPreferredSize(size);
    	panelProgress.setBorder(new TitledBorder(bs));
    	barProgress = new JProgressBar(0, 100);
        barProgress.setValue(0);
        barProgress.setStringPainted(true);
        barProgress.setPreferredSize(new Dimension(360, 20));
        panelProgress.add(barProgress);
    }


============================================

/* Method to will set layout of all panels*/
    public void setupRenameLayout()
    {
    	renameFrame.setLayout(gbag);
    	gbc.gridx = 0;
    	gbc.gridy = 0;
    	gbag.setConstraints(panelIndex, gbc);    	
    	gbc.gridx = 0;
    	gbc.gridy = 1;
    	gbag.setConstraints(panelDestination, gbc);
    	gbc.gridx = 0;
    	gbc.gridy = 2;
    	gbag.setConstraints(panelOptions, gbc);    	
    	gbc.gridx = 0;
    	gbc.gridy = 3;
    	gbag.setConstraints(panelProcess, gbc);
    	gbc.gridx = 0;
    	gbc.gridy = 4;
    	gbag.setConstraints(panelProgress, gbc);
    	renameFrame.getContentPane().add(panelIndex);
    	renameFrame.getContentPane().add(panelDestination);
    	renameFrame.getContentPane().add(panelOptions);
    	renameFrame.getContentPane().add(panelProcess);
    	renameFrame.getContentPane().add(panelProgress);
    }

This is my way to do it, other people may do it differently.
Here is also link to official Java tutorial

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is a code as I used on the end to remove any images from Temp folder. Pased argument in for of string is "del C:" + File.separator + "Temp" + File.separator + "*.tif /F";

public class DeleteRutine
{
	public void runDeleteRutine(String toExec)
	{
		try
    	{
    		// String storing the command to be executed
	    	String cmdCommand = "C:/WINDOWS/system32/cmd.exe";
	    	Process cmdProcess = Runtime.getRuntime().exec(cmdCommand);
	    	
	    	BufferedWriter buffWriter = new BufferedWriter(new OutputStreamWriter(cmdProcess.getOutputStream()));

	    	//Execute command 
    		buffWriter.write( toExec, 0, toExec.length());
    		buffWriter.newLine();
		    buffWriter.flush();
		    buffWriter.close();
	    	
	    	// Wait for the child to exit
	    	cmdProcess.waitFor();
	    	
	    	/*Just for checking purpose to see if CommandPropmt does it job
	    	 *and what is output of it*/
	    	BufferedReader cmdOutStream = new BufferedReader(new InputStreamReader(cmdProcess.getInputStream()));
	    	String temp = null;
	    	while ((temp = cmdOutStream.readLine()) != null)
	    	{
	    		System.out.println(temp);
	    	}	    	
	    	cmdOutStream.close();   
    	}
    	catch(Exception e)
    	{
    		e.printStackTrace();
    	}
	}
}

Clearly from thekashyap post on the line 14 you can see lChldProc.waitFor(); which state "Wait for the child to exit". Funny enough that "waitFor" is working perfectly.
>Please check the requirment before posting.
In the future please do not attack any other member or you may end up with no answers to your post...

Have nice day.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I gave you working solution on the beginning in linked post and you did not even considered to use when the other code did not work for you. What a shame....

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
String sql = "SELECT * FROM PIEDATA1;";

take out that semi-column, their are automaticaly inserted by driver

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

>Then, when I start going the other way, ie the NEXT button, ... hmmm,
What you have to do is just check if the NEXT is smaller then size of your list. When the moving position become equal to list size I would just simple disable button and that apply for oposite direction move, if moving position equals to zero disable PREVIOUS button.

>This affects also my First and Last records buttons as well.
>but for LAST, I do not know what last will be ... any help with this?
Simple, calling FIRST you call first position in the list, which is actualy zero position. For LAST there is method which actualy return last check API properly

with first I think you been trying to say

currCD = listModel.get(0);

and last will be like thhis

currCD = listModel.lastElement();

don't forget deal with exception

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This whole function is wrong

private void btnPrevActionPerformed(ActionEvent evt)
{
	// Grab Previous cd 
	CdwArtist newCD = (CdwArtist) listModel.get( currCD-- );
	newCD.setArtist(artistField.getText());
	newCD.setName(cdNameField.getText());	
	newCD.setItemno(Integer.parseInt(itemField.getText()));
	newCD.setNstock(Integer.parseInt(nstockField.getText()));
	newCD.setPrice(Float.parseFloat(priceField.getText()));		
			
}// end PREV

Why do you try to pull info from text field if your text field is EMPTY ! ! ! You cleared out after reading data with add method

artistField.setText(null);
cdNameField.setText(null);	
itemField.setText(null);
nstockField.setText(null);
priceField.setText(null);

Read data from JList

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Can you please provide remining classes for this application. So far I do no see any problems here so copaling whole thing would be better

no1zson commented: LOTS of help. Love to see his name in my thread. +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
JTextArea jta = new JTextArea();
jta.append("CD Description");
//Or you can do
jta.setText("CD Description");

Preferences up to you just look up API

no1zson commented: Thanks for trying. +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is Java Sun tutorial on basic shapes

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

How are we supposed to help if you do not provide any code?
Secondly is this problem sorted or still on going? If sorted you should clearly state so ...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
public static float calculateTotal(Inventory completeValue[]);			
	float totalValue = 0;
	for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
	{
		totalValue += completeValue[cdCount].getValue();
	} // end for
	return totalValue;
public static float calculateTotal(Inventory completeValue[])
{			
	float totalValue = 0;
	for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
	{
		totalValue += completeValue[cdCount].getValue();
	} // end for
	return totalValue;
}

That could be the case for start...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Programmers Talk can you please read what topic is about in the future? It clearly states "First Attempt at Arrays" !
no1zson is learning about use of array and you just jump miles ahead of what he is trying to do...

no1zson, nice job. It is join to find on the forum somebody who willing to learn and not only expecting solutions from us. Keep going, you doing right!

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In netbeans there is a JTree item in Pallete window, thats what I'm looking for .

Well that does not sort your problem if you do not understand how to use tree properly. And what will you do if you get a job in company where they do not use NetBeans and you will benot allowed to instal as they have licence for some other IDE or use only free versions?
So you better learn trees and will give few examples (duno why I do this...)

/* Demonstrate a tree events 
 */
 
 import java.awt.*;
 import javax.swing.*;
 import javax.swing.event.*;
 import javax.swing.tree.*;
 
 class TreeEventDemo
 {
 	JLabel jlab;
 	
 	TreeEventDemo()
 	{
 		// Create a new JFrame container
 		JFrame jfrm = new JFrame("Tree Event Demo");
 		
 		// Use the default border layout manager
 		
 		// give the frame an initial size
 		jfrm.setSize(200, 200);
 		
 		// terminate program when the user closes the application
 		jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 		
 		// create a label that will display the tree selection
 		jlab = new JLabel();
 		
 		
 		/* Begin creating the tree be defining the
 		 * structure and realtionship of its nodes*/
 		 
 		// First, create the root node of the ttree 
 		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Food");
 		 
 		/* Next, create twoo subtrees. One contains fruit.
 		 * The other vegetables.*/
 		  
 		// Create the root of the Fruit subtree
 		DefaultMutableTreeNode fruit = new DefaultMutableTreeNode("Fruit");
 		root.add(fruit); // add the Fruit node to the tree
 		
 		/* The Fruit subtree has two subtrees on its own.
 		 * The first is Apples, the second is Pears.*/
 		 
 		// Create an Apples subtree
 		DefaultMutableTreeNode …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I absolutely do not understand what you trying to say. If you ask question you better to explain it fully not in one wrong worded sentence...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That is fine but you should also learn how to do it from command line as you may not always have NetBeans

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Then do it with command propmpt here is some explanation

iamthwee commented: good +12
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you searched forum before you posted, you would find that just yeasterday I linked another post with same quastion to my post where I asked same thing few months ago with full elaboration of the problem. Here is link http://www.daniweb.com/forums/thread73182.html, enjoy reading and next time search before you post, there is huge possibility somebody already made a topic with same/similar problem

thekashyap commented: Seriously donno when will they learn to use search.. ! +3
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Code tag is the hash sign "#" in the toolbar when you create post or make answer to post in advanced view. This will paste [ c o d e] and [ / c o d e] in text area and you put the code you wish to post between these two tags. Also you may type these tags stright into message too.

ext thing, it will be nice if you can post solution to given problem for other people to see it

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Never do any changes to instalation of java! No copy&paste any files into bin folder or any other place.
Once you set your PATH, in command prompt you navigate to place where is your file saved ( for example you know your program is saved on C hard drive in folder JavaDevelopment/Chapter7, you do cd C:\JavaDevelopment\Chapter7 ).
Once there you compile your code javac MyProgram.java, if any error in code they will be displayed and you need to deal with them. However, if compile succesfull you will run your program as java MyProgram

If you not familiar with MS-DOS commands simply type help and press enter to read more about them

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is tutorial how to setup PATH for Java and there is also tutorial how to setup CLASSPATH which is used to tell system where are the extra JAR files which you downloaded and want to use. For example customized graphic user interface(look&feel)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

snakai415 it is nice for once that somebody tries to learn Java through command line. However, I hope this was just one of few examples which you had to copy and paste from somewhere else. So if the book come also with electronic version of source code for examples, try to avoid it and type it . You will make typos which will triger plenty of error message, but that way you will learn to handle them. With copy and paste you will never learn. So if you get in trouble just post here and we will be happy to help you...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Story of a Servlet
Basic Servlet Structure also there is more ont that site
Introduction to Servlets

And there many-many more you just need to specify what exactly you are looking for

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You aware that accessing any database with JSP is not recommended and should be avoid. Servlets been design for this task...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

if you check out JCreator forum you would find answer there

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

there is that funny thing called google search and it does bring lot of resources like wikipedia

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you look up the source code (do right click on Gallery, open link in new window/tab, then right click on new opened document and View Page Source) to that slide show, you will see that buttons are just images which can be swaped for anything you like

<A HREF="JavaScript:slideshowBack()" onmouseover="mouseOn('left');" onmouseout="mouseOff('left');">
<IMG SRC="../img/l_arrow_off.png" BORDER="0" NAME="left" id="left" ALT="Previous Image"></A>
<A HREF="JavaScript:slideshowUp()" onmouseover="mouseOn('right');" onmouseout="mouseOff('right');">
<IMG SRC="../img/r_arrow_off.png" BORDER="0" NAME="right" id="right" ALT="Next Image"></a>
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no need to use applets for slide show and you would only complicate your life. You may do it with JavaScript as I did it few years back in my coursework where I use buttons to move from image to image, but you can exclude buttons and use timer to change image every 3-5 seconds. Also same thing cam be done with Flash, PHP, Ajax and other things(flash slide show on top of the page on my website). Everything depends on you, if you wish to learn new language or new software application

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is old comment on one website here
This can be of some help http://mail-archive.objectweb.org/oscar/2004-08/msg00041.html
also here is something http://www.captain.at/programming/java/

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

3D Studio Max for the win or was opposite ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Try to read this tutorials http://java.sun.com/docs/books/tutorial/essential/io/. The task is not difficult and you should understand it, however if you will have any problems, just update your question and provide any code examples you working on

Good luck

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry just sleepy and spoted to late that you did all this on the end of your code. My bad;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Once created and initialized your coponent you need to add menu item to menu and then menu to menu bar
Just quick cut from your code

JMenuBar topMenu = new JMenuBar();
JMenu gameMenu = new JMenu();
JMenu soundMenu = new JMenu();
JMenu helpMenu = new JMenu();
JMenuItem helpItem = new JMenuItem("Help", KeyEvent.VK_T);

//other component initialized

helpMenu.add(helpItem); //add item to menu
topMenu.add(helpMenu); //add menu to menu bar
window.setJMenuBar(topMenu);  //add menu bar to frame
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

you need to be more specific, as what you ask is not clear.
Do you want to only paste name of the files from page_one to page_two or you want to upload file from local machine to remote directory?
These are to very different tasks...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

christianthag you did not answer my question...
If you care have look at this tutorial http://64.18.163.122/rgagnon/framesets/java-date.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

So what exactly is the problem? It does looks stright exercise...
What did you done so far?

PS: I hope you read the rules about homework http://www.daniweb.com/techtalkforums/announcement9-2.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Servlets and Java Server Pages http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
and on same site tutorial on sessions http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
but I will recommend to read basic about servlets and do JSP

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You either missing method main in your program or made mistake in speling of it

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Help will be provided when you give as problem to solve, but not whole homework

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

What ever you need to do with your number which you just get it from string...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The idea with using String is good

String mySubString = s.substring(0, 1);
int newInt = mySubString;

but you forgot to parse Integer int newInt = Integer.parseInt(mySubString) . Yes I know this work but it is bad habit. Why did SunMicrosystem made the method parseInt()? Just to have one extra method?. It is supposed to be used. So please use it...:cheesy:

To work recursively, here is what you need

for(int i = str.length(); i > 0; i--)
{
	int num = Integer.parseInt(str.substring(i-1, i));
        // other operation => add
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is not very good practice line.charAt(x) == mark you should use Character methods compareTo() which return integer

the value 0 if the argument Character is equal to this Character; a value less than 0 if this Character is numerically less than the Character argument; and a value greater than 0 if this Character is numerically greater than the Character argument (unsigned comparison). Note that this is strictly a numerical comparison; it is not locale-dependent.

or you can use method equals() which return boolean

true if the objects are the same; false otherwise.

More info can be found in Charecter class API documentation here