JTextField and bidi text

I need to use JTextField control in oreder to type characters from right to left. (hebrew)
I saw that there is a class java.text.bidi (jdk1.4).
that support hebrew.
how can i combine the two?
is there away for JTextField to be right to left oriented?

I moved this to Java Desktop - Java2D forum.

Similar Messages

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Reading values from JTextField and using them?

    Hello,
    I am trying to make a login screen to connect to an oracle database. Im pretty new to creaing GUI. I need help with reading the values from the JTextField and to be able to use them for my connection. So do I need to apply a listener? How do I go about doing that in this project. Thanks for any code or advice.
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.sql.*;
    public class UserDialog
        String databaseURL;
        String driver;
        String database;
        String username;
        String password;
        String hostname;
        String port;
        UserDialog() {
            getInfo();
        static String[] ConnectOptionNames = { "Login", "Cancel" };
        static String   ConnectTitle = "Login screen";
        public void getInfo() {
            JPanel      connectionPanel;
            JLabel     databaseURLLabel = new JLabel("Database URL:   ", JLabel.LEFT);
         JTextField databaseURLField = new JTextField("");
         JLabel     driverLabel = new JLabel("Driver:   ", JLabel.LEFT);
         JTextField driverField = new JTextField("");
            JLabel     databaseLabel = new JLabel("Database:   ", JLabel.LEFT);
         JTextField databaseField = new JTextField("");
            JLabel     usernameLabel = new JLabel("User Name:   ", JLabel.LEFT);
         JTextField usernameField = new JTextField("");
            JLabel     passwordLabel = new JLabel("Password:   ", JLabel.LEFT);
         JTextField passwordField = new JPasswordField("");
            JLabel     hostnameLabel = new JLabel("Host Name:   ", JLabel.LEFT);
         JTextField hostnameField = new JTextField("");
            JLabel     portLabel = new JLabel("Port:   ", JLabel.LEFT);
         JTextField portField = new JTextField("");
         connectionPanel = new JPanel(false);
         connectionPanel.setLayout(new BoxLayout(connectionPanel,
                                  BoxLayout.X_AXIS));
         JPanel namePanel = new JPanel(false);
         namePanel.setLayout(new GridLayout(0, 1));
         namePanel.add(databaseURLLabel);
         namePanel.add(driverLabel);
            namePanel.add(databaseLabel);
            namePanel.add(usernameLabel);
            namePanel.add(passwordLabel);
            namePanel.add(hostnameLabel);
            namePanel.add(portLabel);
         JPanel fieldPanel = new JPanel(false);
         fieldPanel.setLayout(new GridLayout(0, 1));
         fieldPanel.add(databaseURLField);
            fieldPanel.add(driverField);
            fieldPanel.add(databaseField);
            fieldPanel.add(usernameField);
         fieldPanel.add(passwordField);
            fieldPanel.add(hostnameField);
            fieldPanel.add(portField);
         connectionPanel.add(namePanel);
         connectionPanel.add(fieldPanel);
            // Connect or quit
            databaseURL = databaseURLField.getText();
            driver = driverField.getText();
            database = databaseField.getText();
            username = usernameField.getText();
            password = passwordField.getText();
            hostname = hostnameField.getText();
            port = portField.getText();
            int n = JOptionPane.showOptionDialog(null, connectionPanel,
                                            ConnectTitle,
                                            JOptionPane.OK_CANCEL_OPTION,
                                            JOptionPane.PLAIN_MESSAGE,
                                            null, ConnectOptionNames,
                                            ConnectOptionNames[0]);
            if (n == 0) {
                System.out.println("Attempting login: " + username);
                String url = databaseURL+hostname+":"+port+":"+database;
             // load the JDBC driver for Oracle
             try{
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   Connection con =  DriverManager.getConnection (url, username, password);
                System.out.println("Congratulations! You are connected successfully.");
                con.close();
                System.out.println("Connection is closed successfully.");
             catch(SQLException e){
                System.out.println("Error: "+e);
            else if (n == 1)
                    System.exit(0);
        public static void main (String args []) {
             UserDialog ud = new UserDialog();
    }thanks again,
    James

    the reason why you can't get the text is because you are reading the value before some actually inserts anything in any fields.
    Here is what you need to do:
    Create a JDialog/JFrame. Create a JPanel and set that panel as contentPane (dialog.setContentPane(panel)). Insert all the components, ie JLabels and JTextFields. Add two buttons, Login and Cancel to the panel as well. Now get the username and password field values using getText() inside the ActionListener of the Login.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class LoginDialog extends JDialog
    String username, password;
      public LoginDialog( ){
        setTitle( "Login" );
        JPanel content = new JPanel(new GridLayout(0, 2) ); // as many rows, but only 2 columns.
        content.add( new JLabel( "User Name" ) );
        final JTextField nameField = new JTextField( "" );
        content.add( nameField );
        content.add( new JLabel( "Password" ) );
        final JTextField passField = new JTextField( "" );
        content.add( passField );
        JButton login = new JButton( "Login" );
        login.addActionListener( new ActionListener(){
          public void actionPerformed( ActionEvent ae ){
            username = nameField.getText();
            password = passField.getText();
            // call a method or write the code to verify the username and login here...
        content.add( login );
        JButton cancel = new JButton( "Cancel" );
        cancel.addActionListener( new ActionListener( ){
          public void actionPerformed( ActionEvent ae ){
            dispose(); // close the window or write any code that you want here.
        content.add( cancel );
        pack( ); // pack everything in the dialog for display.
        show(); // show the dialog.

  • JTextField and TextListener

    I am using an JTextField and I want to be notified when the text there have been changed. But there is no TextListener accessible in JTextField. Do I have to modify a CaretListener ?
    many Thanks/ Sam

    I am using an JTextField and I want to be notified
    when the text there have been changed. But there is no
    TextListener accessible in JTextField. Do I have to
    modify a CaretListener ?DocumentListener.

  • JTextField and transparency

    I have a JTextField and I am trying to set it up so it is somewhat transparent.
    mTextField.setBackground(new Color(255,255,255,50));
    But what happens when i do that is this: the textfield as a text value gets the text that i have set up for one of the neighbouring components.
    I am not sure why this happens.
    Has anyone experienced this problem before? Is there a fix to it?
    I tried setting up the text using setText to an empty string but it happens agian. I dont have this problem when the transparency is Not set.
    Cheers
    Dan

    I am not sure why this happens. An opaque component is responsible for painting the entire area of the component, which basically means that the RepaintManager doesnt' have to worry about the garbage that may exist where the component is about to be repainted.
    Since you background is somewhat transparent, you can see the garbage left behind. (Don't ask me what its left behind from, thats in the details of the Swing repaint manager which I know nothing about).
    Michaels suggestion makes the component transparent which means Swing will paint the background of the components parent. However when you do this, the background of your component isn't painted.
    So heres a solution that paints the background of the parent and the child:
    JTextField textField = new JTextField("Some Text")
         protected void paintComponent(Graphics g)
              g.setColor( getBackground() );
              g.fillRect(0, 0, getSize().width, getSize().height);
              super.paintComponent( g );
    textField.setBackground(new Color(0, 255, 255, 50));
    textField.setOpaque( false );

  • JTextField not displaying Text

    Hi everyone,
    I have this really bizarre problem. When i use setText the text does not appear in the text field. However if i use getText after setText the correct output appears to the console. So why isn't the JTextField displaying the text? Checked the font and it is black, checked the positioning of the text and set it to Left to make sure it displays.
    If anyone out there could help it would be very appreciated!! I've never had this problem before and hope i don't have to start all over again.
    Thanks Alyssa.

    @_AlyssaK
    Are you sure that the same text field component is used when you called getText and setText methods ?
    @Booh1
    You have the same problem : You created text fields in the EditCall class but you never used them after.
    Here a possible implementation:
    EditCall
    import java.awt.Component;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class EditCall extends JPanel {
        GridBagConstraints c = new GridBagConstraints();
        public EditCall() {
            setLayout(new GridBagLayout());
            int x, y;
            AssetInfo assetinfo = new AssetInfo();
            CallInfo callinfo = new CallInfo(assetinfo);
            addGB(callinfo, x = 0, y = 0);       
            addGB(assetinfo, x = 0, y = 1);
        public void addGB(Component component, int x, int y) {
            c.anchor = GridBagConstraints.NORTHWEST;
            c.gridx = x;
            c.gridy = y;
            add(component, c);
        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(595, 1000);
            frame.setLocation(100, 100);
            frame.setContentPane(new EditCall());
            frame.pack();
            frame.setVisible(true);
    CallInfo
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class CallInfo extends JPanel implements ActionListener {
        JComboBox contactBox, deptBox;
        JTextField asset;
        ArrayList<String> items = new ArrayList<String>();
        AssetInfo astinfo;
        public CallInfo(AssetInfo astinfo) {
            this.astinfo=astinfo;
            setLayout(new GridLayout(9, 2));
            Font font = new Font("Arial", Font.PLAIN, 22);
            setFont(font);
            add(new JLabel("ASSET NO"));
            asset = new JTextField();
            add(asset);
            asset.addActionListener(this);
        public void actionPerformed(ActionEvent ae) {
            if (ae.getSource() == asset) {
                String sdata = (String) asset.getText();
                int data = Integer.parseInt(sdata);
                astinfo.assetForm(data);
    AssetInfo
    import java.awt.Font;
    import java.awt.GridLayout;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class AssetInfo extends JPanel {
        JTextField assetnum, contact;
        public AssetInfo() {
            setLayout(new GridLayout(2, 2));
            Font font = new Font("Arial", Font.PLAIN, 14);
            setFont(font);
            add(new JLabel("Asset No"));
            assetnum = new JTextField("Hello");
            assetnum.setEditable(false);
            add(assetnum);
            add(new JLabel("Dept Contact Name"));
            contact = new JTextField("World");
            contact.setEditable(false);
            add(contact);
        public void assetForm(int AssetNo) {
            String anum = "Goodbye";
            String DContact = "TextBox Changed!!";
            assetnum.requestFocus();
            assetnum.setText(anum);
            System.out.println(assetnum.getText());
            contact.setText(DContact);
            System.out.println(contact.getText());
    }

  • How to for JTextField and JButton..

    How can i set the size of the JTextField and getting the words alignment to be in Center format?? Can i use JButton, click on it and key in value to be displayed in text form?

    Hi,
    you can change the alignment really simple:
    JTextField textField = new JTextField("Your Text");
    textField.setHorizontalAlignment(JTextField.LEFT);
    textField.setHorizontalAlignment(JTextField.CENTER);
    textField.setHorizontalAlignment(JTextField.RIGHT);The size can be set by
    setPrefferedSize(int w, int h)or try
    setColumns(int columns)L.P.

  • Use VBA and Excel to open Dreamweaver HTML (CS5), find and replace text, save and close

    I wish to use VBA and Excel to programmatically open numbered Dreamweaver HTML (CS5) and find and replace text in the code view of these files, save and close them.
    I have  5000 associations between Find: x0001 and Replace: y0001 in an Excel sheet.
    I have the VBA written but do not know how to open, close and save the code view of the ####.html files. Please ... and thank you...
    [email protected]

    This is actually the code view of file ####.html that I wish to find and replace programmatically where #### is a four digit number cataloguing each painting.... In 1995 I thought this was clever... maybe not so clever now :>)) Thank you for whatever you can do Rob!
    !####.jpg!
    h2. "Name####"
    Oils on acrylic foundation commercial canvas - . xx X xx (inches) Started
    Back of the Painting In Progress </p> </body> </html>
    Warmest regards,
    Phil the Forecaster, http://philtheforecaster.blogspot.ca/ and http://phils-market.blogspot.ca/

  • I have an iphone 4s and the text i send to a friend with a galaxy 4s he is not receiving any help?

    i have an Iphone 4S and the text i send to a friend with a galaxy 4s he is not receiving. Any help?

    Then it's sending as SMS and not iMessage (that's good) so deleting the contact probably didn't help. It also seems iMessage isn't redirecting his texts as he's not used and apple device on the account previously. Can he receive a picture message from you instead? Does he receive texts from other  apple devices? (iPhones,pods/pads) try sending a text through Verizon online using your account on a web browser. If it is also blocked then it confirms the issue is with his device, well at least points you there rather than guessing if it's yours or his or both. There's some ideas, let me know- Joe
    Sent from my iPhone

  • HT4623 my iPhone can call out and receive text messages and emails but is not receiving any incoming calls

    my Iphone can call ut and receive text/email messages but is not receiving incoming calls.  What is your thought?

    Hi Baileyfour,
    Welcome to the Support Communities!
    The articles below may be able to help you with this issue.
    Click on the link to see more details and screenshots. 
    iPhone: Can't hear through the receiver or speakers
    http://support.apple.com/kb/TS1630
    There are two places where vibrations can be set.
    One is the Settings > Sounds
    The other area is Settings > Notifications
    If you have an app set to Alert, it may have a vibration set for it.
    iOS: Understanding Notifications
    http://support.apple.com/kb/ht3576
    Information about Notifications settings can also be found in the iPhone User Guide (pages 131, 132)
    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf
    I hope this information helps ....
    Have a great day!
    - Judy

  • Anchor tag error, also copy and pasting text comes up "null"

    After the recent update I am receiving anchor tag errors telling me to start with an alphabetic letter, which I was. Also no longer lets me copy and paste text onto a page, instead it says "null". Any ideas on a fix ?

    I don't see a closing </body> tag in your code.  There's an opening tag, but no closing tag, hence unbalanced.
    ^_^

  • My iphone 4S stopped receiving and sending text messges. Help!

    My iphone 4S stopped receiving and sending text messges. Help!

    Hi J.A. Curie!
    Here is an article that can help you troubleshoot this issue:
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    Thanks for coming to the Apple Support Communities!
    Cheers,
    Braden

  • Difference in a string and the text retrieved from JTextBox

    Hello,
    I am facing a peculiar problem. Please see the following code fragment:
    m.replaceAll(";\ngo;);
    where m is a matcher. This is working fine. But whenever I am doing
    m.replaceAll(myTextBox.getText());
    and placing ";\ngo;" in the text Field is not working as before. This is because that getText() returns a string in text form(doesnot take the newline into consideration). Any idea how to solve this?
    Regards,
    Saurav

    Here is the following code:
    File fin = new File(file);
    File fout = new File("C:\\Temp\\temp123.txt");
    FileInputStream fis = new FileInputStream(fin);
    FileOutputStream fos = new FileOutputStream(fout);
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));
    Pattern p = Pattern.compile(find);
    Matcher m = p.matcher("");
    String aLine = null;
    while((aLine = in.readLine()) != null) {
    m.reset(aLine);
    String result = m.replaceAll(replace);
    out.write(result);
    out.newLine();
    in.close();
    out.close();
    What I intend to do is that the user will provide a fileName from the GUI and also the text to find and the text to repalce with. Both of them will be in a JTextBox. Now
    suppose I want to replace ";" in the line "Hello;" with ";\nHow are u?" so that the line looks like
    "Hello;
    How are u?"
    But what is happening is that the line looks like
    "Hello;\nHow are u?" after replacement.
    This happens because getText() doesnot considers that as a special character...
    I tried to harcode the replace string and it worked perfectly....
    Thats the problem.....I need the same behaviour with getText().
    Regards,
    Saurav

  • Sending Email using both HTML and plain text

    I could use some advise on how to start researching email for
    both HTML and plain text messages.
    I have a script called class.phpMail.php, but the code is
    alittle advanced for me. Basically I can't get
    it to work on my server and I don't know where to begin the
    learning process here.
    I talked to my provider, "HOST" company goDaddy.com and I was
    told that to connect so that I could send email I would need this
    line of code. They didn't say it should by in my php.ini file but
    that was where I found it.
    SMTP = relay-hosting.secureserver.net
    This is the smtp address that my provider uses to make the
    connection with my mail client.
    I was told that with this line of code I would not need a
    password or username
    I did some further reseach and I found an article that stated
    that my original error:
    Warning: fsockopen() expects parameter 2 to be long, string
    given in ...../php/class.smtp.php on line 105
    was being caused by this code because the $port value needed
    to be between 1 - 65365:
    $this->smtp_conn = fsockopen($host, # the host of the server
    $port, # the port to use ----- "this is line 105"
    $errno, # error number if any
    $errstr, # error message if any
    $tval); # give up after ? secs
    In particular the $port value was coming in corrupted and
    that I needed to cast it.
    I did as they suggested and made it an (int) as they
    suggested.
    $this->smtp_conn = fsockopen($host, # the host of the server
    (int)$port, # the port to use
    $errno, # error number if any
    $errstr, # error message if any
    $tval); # give up after ? secs
    It resolved part of the error message however, the other half
    of the error message is shown below:
    Message could not be sent.
    Mailer Error: Language string failed to load: connect_host
    What exactly is the connect_host they refer to in this
    message?
    Would it be the string in my php.ini file refering to the
    SMTP = relay-hosting.secureserver.net
    I have allot of what I think are disconnected questions as I
    really have just begun to work
    with the mail() function. If anyone has the time to educate
    this newbie into the wonderful
    world of email() I would appreciate it.
    Thank You
    Kevin Raleigh

    Sorry to dig up an old post, but we've spent the last few days trying to work out why an email campaign being sent from BC is going into the Junk folder of recipients that use MS Exchange. We've fixed quite a lot of issues, including the fact that Legacy Templates have random JS injected just before they get sent, so we had to switch to the new template system. We've narrowed the issue down to one of three things:
    1. A missing alt tag on the tracking image that BC drops into the email (pretty unlikely)
    2. The BC Europe IP (54.240.14.45) is blacklisted here: UCEPROTECTL2 (possible, but if you actually look it's not the IP itself, but another IP on the same network, so unlikely)
    3. The fact that the HTML email has no text component.
    I agree, BC is late on this but I think that it needs to be added, even if most users have HTML-ready email clients, spam checkers do seem to prefer multi-MIME emails.
    This is backed up by the following SpamAssassin rule, which we are currently unable to resolve:
    -1.105
    MIME_HTML_ONLY
    Message only has text/html MIME parts
    You should also include a text version of your message (text/plain)
    So in my opinion, BC do still need to add this as a feature, otherwise the system is not viable for our customers and we'll have to look elsewhere.

  • I can make calls and send text messages on my new iPhone 5, but incoming calls and texts still go to my old (non-Apple) phone. Is this a problem with the phone set up, or is it a problem with my old carrier or my new carrier?

    I can make calls and send texts on my new iPhone 5,  but all incoming calls and texts are received by my old (non-Apple) phone.

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Try each of these in order until the issue is resolved.

Maybe you are looking for