JTextField Unicode Problem

Discussion in 'Java' started by Badshah, Jan 29, 2007.

  1. Badshah

    Badshah Guest

    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();
    }
    }
    Badshah, Jan 29, 2007
    #1
    1. Advertising

  2. On Jan 30, 1:05 am, "Badshah" <> wrote:
    > 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.
    Andrew Thompson, Jan 29, 2007
    #2
    1. Advertising

  3. Badshah

    Badshah Guest

    On Jan 29, 7:45 pm, "Andrew Thompson" <> wrote:
    > On Jan 30, 1:05 am, "Badshah" <> wrote:
    >
    > > 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.
    >
    >
    > 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.
    Badshah, Jan 30, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Katie Moore

    JTextField Problem

    Katie Moore, Dec 1, 2003, in forum: Java
    Replies:
    1
    Views:
    488
    Harald Hein
    Dec 1, 2003
  2. Matthew Bailey

    JTextField.requestFocus problem

    Matthew Bailey, Jul 6, 2004, in forum: Java
    Replies:
    4
    Views:
    8,031
    Matthew Bailey
    Jul 8, 2004
  3. blue
    Replies:
    1
    Views:
    1,193
    Babu Kalakrishnan
    Dec 11, 2004
  4. Badshah

    JTextField Unicode Mysql

    Badshah, Jan 27, 2007, in forum: Java
    Replies:
    16
    Views:
    937
  5. Badshah

    JTextField Unicode Problem

    Badshah, Jan 29, 2007, in forum: Java
    Replies:
    0
    Views:
    380
    Badshah
    Jan 29, 2007
Loading...

Share This Page