peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Check out the GridBagConstraints.anchor field.

I used it but get no changes when I used Absolute values. Only changes been when Baseline Relative values applied but with this I can acive my disired alignment

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

if that file actualy create table and than insert some vulues you can simple run command prompt

mysql -u user_name database_name<your_textfile+extension -p

[I]so it can look like this[/I]

mysql -u root dvdDatabase<myDvds.sql -p

then it will ask you for db password

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

OK, I started to break down even this two components panels, I though there is some simple/smart solution to this :confused:

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Give us code what you did, because without any attempt made nobody will help you here

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

Wrong website my friend, over here we help with problems in coding, but we do not provide code on demand. You have to go somewhere else, but be warned it will cost you a lot...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In the JPanel I placed JTextField and JButton, as the layout I'm using GridBagLayout which is left to default align (center). However because of the size of whole JFrame I would like to get JTextField to left and JButton to right. How do I do that :?:

private GridBagLayout gbag = new GridBagLayout();
private GridBagConstraints gbc = new GridBagConstraints();
private Border bs = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
.
.
.
.    
    public void setupIndexPanel()
    {
    	panelIndex = new JPanel();
    	panelIndex.setBorder(new TitledBorder(bs, "Index File Path"));
    	panelIndex.setLayout(gbag);
    	tfIndex = new JTextField(20);
    	tfIndex.setEditable(false);
    	gbc.gridx = 0;
    	gbc.gridy = 0;
    	gbag.setConstraints(tfIndex, gbc);
    	panelIndex.add(tfIndex);
    	btnIndex = new JButton("Get index");
    	btnIndex.setPreferredSize(new Dimension(100, 30));
    	btnIndex.addActionListener(this);
    	gbc.gridx = 1;
    	gbc.gridy = 0;
    	gbag.setConstraints(btnIndex, gbc);
    	panelIndex.add(btnIndex);
    }
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Can you please specify what problem? You just start sentence and cut it in middle :cheesy:

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

JSP is very bad choise for setting connection to database you better do it in servlet/front controler

then in JSP just say

<textarea rows="10" cols="30"> <%=stringToDisplay%></textarea>
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Have to be that way, just take e-bay (no advertising) what hell of database they have to run store all details about sellers, buyers and things for sale...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

never seen information like this, don't take me wrong but this can be limitless if you have proper resources. But take it like this, your size of database is either limited by storage capacity of you pc/network or your webservice provider

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I think you should reconsider your for loop

for(i='A';i<'D';i++)

I never heard that in java you can increase value of character type variable, this is possible but in Perl
Create array of characters and with use of "i" get the character from the array
so if char[] myArray = { 'A', 'B', 'C'}
then if i = 1
you get character B

ajay_tabbu commented: nice +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I think you didn't read the rules of this forum, we help here to people which willing to learn and we do not produce code on demand. There are other sites where they will happily do it for you just don't forget ready your "plastic money"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Can you please provide code.... <== was my original message

LOL iamthwee beaten me for faster response, good link which you provided

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Was browsing SourceForge for some advice and found this simple explanation

So absolute path can be something like this

$cfg['PmaAbsoluteUri'] = 'http://192.168.0.2/phpMyAdmin';
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If so, why not use an IDE?

Not everybody want to use IDE's and why....

Applet have be viewed in web browser or in AppletViewer, plus applet don't have main method

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Can somebody please help me to little customize the view of the phpMyAdmin?
Curently this is what I see but I would like to have as this. Simple, I don't like options to be displayed as list of links but as tabs.

What shall I change in config?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

you can search this site for other suggestions made not so long ago

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

it has nothing to do with JSP either (and anyone doing something like this in a JSP should be shot, preferably in the gut, and left for the vultures).

Hmmmm, was this addressed to me :?:

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I think I poineted you in wrong direction, you don't need random function that is useful dice games. Sorry my mistake. ;)
But you may want to create another array of type card to store data about cards which been used and should not be dealth again

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Did you tried a random function as I sugested???

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

all you do is sometthing like:

IF time > 12:59 then
time = time - 12
endif

so if i input 13:00 it would give me 1
and if i input 12:00 it would still give me 12

no way jbennet you took it wrong way, question is how to get 13:00 out of 1pm. Not oposite :cheesy:
Question is how the user enter time, in one go ass string (1pm, 4pm, etc)
or first entry is integer and second is string. So think about it what data you want to read in?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I did few small changes to your files

CARDS change in card constructor

public Card(int f, int s)
{
    // initialise instance variables
    face = f;
    suit = s;        //you had suit = SPADE
}

DECK change your constructor public Deck() (with 2 for loops) to a method to initialize cards, I call it public void setCards()

DRIVER use the new method setCards() before you suffle cards

if (choices[0].equals((String) selected))
{
            inDeck.setCards();
            inDeck.shuffle();
            System.out.println("card mixed");
            playCards();}

I would create random function to get my set of cards and check if these cards hasn't been dealt. So dealt cards should be store somewhere :?:

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to check your coding first, you have lot of mistakes there!

and I will give small example of working with database
establish connection with database

try
{
	conn = DriverManager.getConnection("jdbc:mysql://db_location/" 
		+ "database_name?user=user_name&password=user_password");
	stmt = conn.createStatement();
}
catch(SQLException ex)
{
	System.out.println("SQLException : " + ex.getMessage() );
}

Run query (get data grom db)

try
{				
	int i=0;
	String strQuery = "select event_type, ev_date, ev_time, 
       ev_description from calendar_events where userName='" 
	+ nUser.getUsername() + "' and cal_id='" + nUser.getCalId() + "'";
	rs = stmt.executeQuery( strQuery);
	while( rs.next())
	{
		eArr[i] = new CalendarData();
		eArr[i].setEventType(rs.getString("event_type") );
		eArr[i].setEventDate(rs.getString("ev_date") );
		eArr[i].setEventTime(rs.getInt("ev_time") );
		eArr[i].setEventDescription(rs.getString("ev_description") );
		i++;					
	} // end while loop
}//end try
catch(SQLException ex)
{
	System.out.println("SQLException : " + ex.getMessage() );
}	// end catch

and close conection

try
{
	if( stmt !=null) stmt.close();
	if(conn != null) conn.close();
}
catch(SQLException ex)
{
	System.out.println("SQLException : " + ex.getMessage() );
}

PS: For futhure, can you please use tag for inserting code into post, it is the # (hash) in post toolbar. Thanx

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

No, you don't need to. Anything you print to System.out will show up in the catalina.out logfile (as long as you have that activated).

LOL, always funn to search log file, personaly I do it as writen above your post :p

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

good day ,

i am new to java ,

i am using two different databases and i want to insert data from one table to other empty table using jdbc .and it consists of null values in one table along with some data .when ever we add new data to one table it should insert into other table and existence data should be updated after insert is executed.

can i have one example with these details.

Sorry, I don't see any problem with this as all datas which you save in first database are still stored in their original variables plus same string you use on first database can be send to second one, or may be modified before sending as neccesary. So what you do I presume is recive data from form, validate them, store in varables, open conection with first database, save data, close conection, open connection to second database, save data and close connection. Then go to other page or refresh original...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

pls

any one hv project using jsp and sql pls post the projects.........

Sorry my friend we help to sort problems with code you are developing not developing code for you. You are in wrong place.
Do your coding and if you get errors you can't solve it, we will try to help you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

hi all,

i am using the tomcat server..

can i show the java out puts(System.out.println) on the browser that is issude from java classes, not from the jsp pages.
i think there may be a way to change the configuration in the tomcat server..
thanks..

I think you looking to debug your code by way of using System.out.println. Yes you can do that, but you need to run tomcat in "command propmt" ( I don't know proper name for it) but you can find it in your tomcat folder under bin there is file called tomcat5.exe( like C:\Tomcat5.5\bin\tomcat5.exe). This will triger start of Tomcat in comand prompt view, use browser to run your jsp's and check System.out.println's in tomcat command propmt view

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

http://www.cs.princeton.edu/~ah/alg_anim/gawain-4.0/BubbleSort.html

Nice and simple explained :cheesy:

(applets didn't run my firefox ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is plenty of examples for sorting on internet. Did you looked at them? Please do so, just quick google search brought this
Why I'm telling this to you? Because right now we can only recomend that you follow theory in order to create some code. Then, if you have any problem with this fresh developed code we will advice.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

p.s.
I took a C++course and me and my friends wasnt good at c++ , we didnt get any benifits from that course beacuse of our bad teacher !!!

There is kind of chinees saying "there are no bad student only bad teachers"
but sometimes I would disagree when I see my school friends copying work from each other :sad:

Katrin, it is most unfortunate but this comunity is to help its members which show an interest in the subject of their study/work. If you have specific problem with your code please provide us with your code and we will try to help. However we can't do your job/coursework/assignment for you us you will never learn from it. It is a practice where you learn. So please do your coding and if you have problem come back we are happy to advice, but don't ask for solution

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Thanks there is some good help, The problem I have is that I am not sure what the formula is supposed to be, I have not have any exposure to this and this class is pretty fast pace. Here is what it is based on

payment = [$200,000(1 + .00575)360 x .00575] / [(1 + .00575)360 - 1] = $1167

But I dont know hwo to put that into code.

You missing operation markers between 200000 and bracklet of (1+0.00575) plus other places, interest is less then 0.5% acording to this, I do not understand why do you apply interest to number of months ( 360 * 0.00575) and last part what is point to take one of final calculation. That will be last step to your output. Shouldn't be like this (1+0.00575)*(360-1)? So if I take empty places are multiplication then code will be like this

payment = ( 200000 * (1 + 0.00575) * 360 * 0.00575) / ((1 + 0.00575) * 360 -1)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I give to 2 information
1. Don't use Calendar class but GregorianCalendar as calendar was depricated and is returning sometimes wrong values
2. If you have instalation of Tomcat, in jsp-examples is simple example how does it works or use google there plenty more

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Bracklets is what you missing in your calculation in first place as your line of code
double Payment = Loan * InterestRate / 1 - (InterestRate + 1) - 12 * Term;
Java's rules of operator precedence are

  1. Multiplication, division and reminder operations are applied first. If an expression contains several such operations, the operators are applied from left to right. Miltiplication, division and remainder have the same level of precedence
  2. Addition and subtraction operations are applied next. If an expresion contains several such operations, the operators are applied from left to right. Addition and subtraction operations have the same level of precedence
  3. If there are any bracklets, calculate first content of braclets using the first two rules and then run calculation on reminding expresion be following first two rules

so you expresion is
Payment = Loan * InterestRate / 1 - (InterestRate + 1) - 12 * Term
replace variables with values
Payment = 200000 * 0.0575 / 1 - ( 0.0575 + 1 ) - 12 * 360
Braclet first
Payment = 200000 * 0.0575 / 1 - 1.0575 - 12 * 360
Multiplications and division
Payment = 11500 / 1 - 1.0575 - 12 * 360
Payment = 11500 - 1.0575 - 12 * 360
Payment = 11500 - 1.0575 - 4320
Payment = 7178 (plus some reminder)

Your expresion is also not realy clear. Why 1 - (InterestRate + 1) ?
Thats gives only negative InterestRate. You could do it with simple -InterestRate

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Start from database. Remember everything coming out of database will be String and you have to to transfer it to appropriate format.
So in what type/form is your date stored?
What do you have to do, get your database date format to be comparable with data which you get from JSP/servlet ?
Once you sort this, getting relevant query will be the easies part of the job

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no add method for JScrollPane so you can't use it but there is JScrollPane constructor JScrollPane(Component view), which "Creates a JScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view." (taken fro JAVA API)
check Java API here

JTextArea t;
	JFrame f;
	JPanel c;
	JScrollPane b;
	//b = new JScrollPane();
	b.setAutoscrolls(true);
	f = new JFrame("JNotepad");
	f.setBounds(300, 200, 500, 500);
	c = new JPanel();
	f.setContentPane(c);
	t = new JTextArea();
	t.setFont(Font.decode("Courier New-14"));
	b = new JScrollPane(t);
	c.add(b);
	f.setJMenuBar(/* Menu bar is "m". This works just fine. */m);
	f.setVisible(true);
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

LOL, I didn't check date

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Yes you can runn PHP on same machine, even on Tomcat but that is more complex to set up

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

you need just one instalation and I would recomend you follow the setup from website to which I gived to you link

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

wowoooooooooo thanks!!!! so clever!!!!!!!!! so thats not hard at all yeah?? connecting SQL and java and transfering to and from

I don't see a problem there :cool: . They must showed you at school how to do it and query language is not so complex. Plus there is MySQL website with full documentation and lot of examples and if you look in daniweb MySQL section you get also lot of help there

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

When do I finaly learn where to use this bracklets ;) ?
data.length will return size of your array so you do not have to exactly say loop only 4 times then stop, you just ask for size of array and loop till you get last element in array

your index is just variable which you declared and then you tried to increase its value with each loop. To do this with index = 1, you get infinitive loop.

Plus you don't have to declare "i" outside of for statement

Nice job cassyjack, you doing well. Nice to see some mebers which do not only ask for code but actualy do their workload

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

what about this

int i;
int index = 0;
int largest;
largest = data[0];
for(i =0; i < data.lenght(); i++)
if(largest < data[i])
{
largest = data[i];
index = i;
}
return index;
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

HI guys, your code is soooo amazing~ i am doing something similar too but kinda stuck hope you can help me pleaseeee.basically i am also calculating the distance, but instead of having all the co ordinates typed in a text file, i am having a fill in blank for user to fill in the TO and FORM then i want it to search through my SQL database to find the matching co ordinates. for example user fill in TO: SE1 FROM SW5, then it will search the database to find the co ordinates of SE1 and SW 5 then cauculate. is that possible??? please help~ i was searching all night but no clue.

Searching internet all night LOL :lol:

Common sence my friend,
1. database with table contatining destination(example E2) and values to coordinates x & y
2. From form either in swing/JSP, you didn't say which one, you read two destinations
- check if their are not same as there is zore distance and no point to access database and run calculation
3. Connect to database get coordinates for your two destinations and run calculation

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

First instalation is the one which you need as you only wish to practice on your home pc/laptop. The second option is to setup hosting service I believe.
There is plenty of good tutorials on net, I personaly like this one http://mpcon.org/apacheguide/jsp.php which shows you how to set also Apache with PHP, plus MySQL, My phpAdmin and Rubby (you may want to install MySQL later on)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

well good think about html is if browser doesn't recognice a tag it will ignore it, or in worst it will display this tag as part of website. The second thing I seen only with very bad "web developers" which made they own tags, didn't close or close them in wrong place.

center tag don't worie about it, it will work for some time....

for the person with MS-DOS I have no idea, I have only if you willing to buy him new pc :mrgreen:

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Dear friend

next time when posting please use tag code which is under symbol #, its make it easier to read the code. Thank you.
To your code. I took time to check it after initiatial 3 errors which I sorted come another 38. All this errors are related to your un-standart code writing. When documentation say

import javax.swimg.JOptionPane;

it is not same as yours

import javax.swing.joptionpane;

Java is not benevolent HTML where capital and lower letters can be mixed up as you wish. So please check all your coding for these mistakes and corect it and post it again if you get into troubles

Bellow you find the first correction which I made after first compile

import javax.swing.joptionpane;
public class homework7
{
	public static void main(string args[])
	{	
		//prompt user to insert a value of signal array
		String getsizearraystring = Joptionpane.showinputdialog(null,
		"enter a value for the size of the array:","Homework7",
		Joptionpane.question_message);
		
		int getsizearray = integer.parseInt(getsizearrayString);
		
		//declare
		int[] getsignal = new int [getsizearray];
		
		getsignal = getsignal(getsizearray);
		
		int[]getsmoothsignal = smooth (getsizearray.getsignal);
		
		//display output
		Joptionpane.showinputmessagedialog(null,
		showoutput(getsizearray,getsignal,getsmoothsignal)+"complete\n",
		"homework7",Joptionpane.information_message);
		
		System.exit(0);
	}
		
	//return get array value method
	public static int[] getsignal(int s)
	{		
		//declare
		int[] getnumber = new int [s];
		
		//prompt user to insert values of the array
		for(int index = 0; index < s; index++)
		{		
			String getintstring = joptionpane.showinputdialog(null,
			"enter value of array:","homework7",
			Joptionpane.question_message);
			
			getnumber[index]=integer.parseInt(getIntstring);
			
			//error message is shown if the user value that are less than 2
			while (getnumber[index]<2)
			{		
				Joptionpane.showmessagedialog(null,
				"there is an error \n" …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

what is purpose of this program???

anyway here you go, you need to initialize variables Dot1 and Dot2, as program will try to increase value of Dot2 just few line down and then compare to Dot1

int Dots1 = 0;	// missing initialization
	int Dots2 = 0;	// missing initialization
	
	//Calculate Dots
	Dots1 = TotalDots - 1 - Word1.length() - Word2.length();
	
	//Dots Results
	String Results = "";
	
	do 
	{
		Results += (Dots);
		Dots2 ++;
	}while (Dots2 <= Dots1);
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Lol just found this post, I'm from Slovakia but living in London, doing my final year at uni :eek:

For happygeek, good on you with slivovica hope it wasn't home made that worster then tequila :twisted:

There is VideoForum 2007 between 6-8 February, Earls Court if anybody interested, but any day should be OK with me

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

LOL,hostsyst that sounds like advertising. Same username as company name, but hell looks like they have good prices duno how good is their service. There is also another option http://www.itanets.co.uk/

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I personally prefer an editor such as Textpad since it does not provide code completion so it really exposes to you to the language instead of writing the code for you (great for beginners).

Just small note on this, you can always switch this option in any of them if you don't like it or don't wanted :mrgreen:

Depending on what I do, if it is web application or big project I use NetBeans just for small "test" programs I use JCreator