Gabor Beke

Greenhorn
+ Follow
since Jul 11, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gabor Beke

UPDATE: Ok Guys I found it out myself. I used BufferedImage as ImageIcon, and set it to jlabel.

Topic can be closed:)



Hi!

I need help on drawing a buffered image on my j panel:

here are my classes:

PreviewEnvelope:



and in the other class that calling this:



I want to draw the buffered image everytime the table row is selected.

Thanks in advance
10 years ago
Hy guys!

I need a little assist on this because I cant really figure it out what I'm doing wrong. I'm working on an envelope writing program. The program have 4 JTextField.
Name, City, Addres, Postal Code. I use keylistener on Name JTextField to recognize the Enter button, and add a new Name JTextField. (Basicly, it sets the 2nd Name JTextField Visible). So total you could have 4 Name JTextField and the others (city, address, postal code) total 7. Also has print jbutton, jtable for viewing already written envelopes waiting for printing so on. When I use g.drawString() I use a predefined x,y value which are changing dynamicly according to the Names field's text length measured by Font Metrics' StringWidth() method and calculating with the right side margin value.. whatever. My Main problem is here:



Can you tell me what I did wrong? I dont think this should be very complicated, I must missing something little.

Thanks in advance
10 years ago
I resolved it. I copied TableColumnAdjuster java content to my main java file, and its working now, although I dont know why It cant access to it if its in another class file. Thank you all.
11 years ago
its still not working even I've changed it to vector, the jtable rows arent drawned after compiling it and running the jar file. Altough in netbeans its working. How come? I found it out!

My table column adjuster caused the problem, can somebody check for me why isnt working with it?
11 years ago
First of all thank you for answering. Here's all the part of the code with jtable.




And the TableColumnAdjuster java (that makes columns autosize its wide according the text length)


11 years ago
Hi there!

I have jtable with rows added dynamicly by vectors. In netbeans its working when I add new row to my jtable, but when I compile my program and run the jar file it doesnt work, its show up only when I hold down the left mouse button and moving over the jtable then the new rows are drawned. What's wrong? what am I missing?

I use



to add a new row to my jtable by a Jbutton that has actionlistener for it. in netbeans when I run it its working. How come in netbeans its working then when I compile it ,its not?
11 years ago

Ivan Jozsef Balazs wrote:

Gabor Beke wrote:
The point here is, that setting up java client side for transferring into mysql database without the user have to configure anything. So once the user gives the sql user/pass everything else going automaticly. Its needed because on default, java's default charset isnt latin2, so isnt enough to setting up mysql database to latin2 utf8 if you put data through a java program.




There is a default (platform) encoding, but that applies to the byte stream to (or from) character stream encoding. The JDBC API works in the term of strings, and JDBC takes care of the encoding itself. According to my experience (admittedly with Oracle thin driver) it was neither possible nor necessary to fiddle around with the JDBC encoding.



I can say only that, until I didnt do this I got ? marks in my database fields, and if I add this its working, simple solution for me, there's nothing overexplaining about this.
11 years ago

Paul Clapham wrote:If I recall correctly, my solution was just to configure MySQL to use UTF-8 as its default character set when I installed it. (That did require exporting all of the data, reinstalling MySQL with the "use UTF-8" option, and then reimporting all of the data.) I don't have anything in my connection string which mentions Unicode or any charset at all, and I don't have any SQL code which mentions charsets either.

And I do have place names from Slovakia and Iceland in my tables, so I have pretty good test data. Haven't been to Hungary yet but I would like to get there one day.



The point here is, that setting up java client side for transferring into mysql database without the user have to configure anything. So once the user gives the sql user/pass everything else going automaticly. Its needed because on default, java's default charset isnt latin2, so isnt enough to setting up mysql database to latin2 utf8 if you put data through a java program.
11 years ago
Here are the solution:

Setting up the mysql connection: (my server is located on localhost for testing)




put this line right after the question mark. Sorry about this code blocks have character limits :-/





mysql table create example with hungarian charset:




After these you will have no more problems with any hungarian letters:) Have a nice day:)
11 years ago
Nevermind I found it out by myself.



11 years ago
Hi guys!

I'm looking for a solution for setting up my mysql database table for Hungarian character set. My problem is that when I insert data to the database (Mysql) some letters turns into a "?" mark. When I add data into database directly through for example with navicat its working fine.

I have problems with the following hungarian letters:

"ö", "Ő", "ű" ,"Ű"

All these letters are turning into ? when I insert the data through my java program. So please can you help me how to set up this correctly? UTF8 and latin2 charsets contains the hungarian charsets I guess but I still dont know how to set it up in my java.

Here is my create table syntax from my java program:



Also what would happen if I would replace "ö", "Ő", "ü" "Ű" with the ASCII code for "ö", "Ő", "ü", "Ű" ? after insert into db it would be viewed as letters or it whould show only the ASCII code? and vice versa.

So far I tried to set table's char set, field char sets but I guess its not enogh, something still missing from java side?

I want to make table with the right settings so users dont have to mess with it.

Thanks.
11 years ago
Its working now:) Thank you all for helping me:) The problem was this line:



Dropping and recreating the table right after connection means that you'll lose all data from previous runs of your application. Might be good for testing, but definitely not for production code, unless you're creating some kind of temporary tables this way.



This would be really the problem as you said. Everytime I write data to the database it will always dismiss the old table and create new one, ofc I cant see my newly insert datas. Thank you for pointing that out for me. I will try it out once I go home, and repost here what happened:) Btw I misunderstood syntax about creating table. I thought if I drop table if exists its perevent to erease my data,
First of all thank for the answer Martin!

I'm using MySQL Community Server 5.5.28 hosted on localhost. I'm using Navicat for MySQL to browse and check out the database. I'm trying with the both way to get it work ( with preparedstatement and w/o)



Without preparedstatement:


With preparedstatement:



My question is which one should I use? I would prefer PreparedStatement more because its more readable and easier for me. Is the syntax is correct or did something wrong? I want to make table create automatic through my java program once the connection has been established. Ofc both case I close the connection in the end. The create table syntax is good? primary key is enough for ID or its need Unique or Index? if yes can you show me how should Include those?

If I dont use preparedstatement and I want to insert data retrived from jtextfiled, this syntax should work or not? if not whats the right syntax for doing this?

Thank you all for the answers:) Maybe I found out whats wrong, I didnt make primary key with autoincrement in my table, so when I executed sql statement it couldnt make new row in the database, instead of overwriting the only 1 existing row all the time. Altough I didnt tried out my solution, because I'm at work now, and I dont have here jdk neither jre to test this out. BTW AUTO_INCREMENT is always needed for tables to make new row?