JTextField Unicode Problem

B

Badshah

I am not able to get "♣" symbol on console when I press enter in jtf
after inserting "♣"

import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;

public class TestFrame
{
JTextField jtf = null;
public TestFrame()
{
try
{
JFrame fr = new JFrame("Testing Unicode Transfer From & To MySql
Database");
JPanel cp = new JPanel();
fr.setContentPane(cp);
cp.setLayout(null);

fr.setBounds(0,0,400,400);

jtf = new JTextField();
cp.add(jtf);
jtf.setBounds(20,300,100,40);

jtf.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.println(jtf.getText());
}
});
fr.setVisible(true);
}
catch(Exception ex)
{
System.out.println("Exception : " + ex);
}
}
public static void main(String args[])
{
new TestFrame();
}
}
 
A

Andrew Thompson

I am not able to get "♣" symbol on console when I press enter in jtf
after inserting "♣"

OK. It took me a little while to understand what
you mean, but I think I can help by adding..

The console does not understand the entire
range of characters as displayed in UTF-8.
If the console encounters a symbol for which
it has no equivalent, it will put '?' instead.

I suspect that dumping UTF-8 encoded data
to the console might not be very helpful in
telling what the inputs and outputs are.

What development environment or IDE are
you using? (Some have debugging tools
that might be especially helpful for finding
out what the inputs and outputs are.)

Andrew T.
 
B

Badshah

OK.  It took me a little while to understand what
you mean, but I think I can help by adding..

The console does not understand the entire
range of characters as displayed in UTF-8.
If the console encounters a symbol for which
it has no equivalent, it will put '?' instead.

I suspect that dumping UTF-8 encoded data
to the console might not be very helpful in
telling what the inputs and outputs are.


Andrew T.

Hello Andrew, I have checked that the console is supporting such
characters. I have pasted it on the console.

1) One more thing I will like to say to you that when I am getting
that particular character from database (mySql) [I have already
inserted this character in a field] and setting it in textbox , It is
showing a rectangle in textbox , But at the same time if I use
[after setText(rs.getString("Field Which Contains That Character"))]
"System.out.println(txtfield.getText());" it is showing that character
on console. Means the control is not able to display that character
properly if I use it with database connectivity.

2) And the thing I told you that when I press enter in the above given
code after inserting that character then also it doesnt show that
character on console.
What development environment or IDE are
you using? (Some have debugging tools
that might be especially helpful for finding
out what the inputs and outputs are.)

I am using Crimson Editor but it's debugger doesnt support this
characters.

Hope I am able to explain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,728
Latest member
FernMcmull

Latest Threads

Top