0

Hi i have a problem ,

i Cant use left and right key on Jtextfield to move cursor

When I want to change a sentence on Jtextfield it does not give me the hand to use left and right Keys

 jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane(jPanel1);
    jPanel1 = new javax.swing.JPanel();
    textField1 = new java.awt.TextField();
    textField2 = new java.awt.TextField();
    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();

    jTextArea1.setEditable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jTextArea1.setAutoscrolls(false);
    jTextArea1.setEnabled(false);
    jScrollPane1.setViewportView(jTextArea1);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setMaximumSize(new java.awt.Dimension(1500, 1500));
    setMinimumSize(new java.awt.Dimension(2000, 2000));
    getContentPane().setLayout(null);

    jScrollPane2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    jScrollPane2.setMaximumSize(new java.awt.Dimension(3000, 3000));
    jScrollPane2.setMinimumSize(new java.awt.Dimension(3000, 3000));

    jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    textField1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    textField1.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
    jPanel1.add(textField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 130, 2260, 70));

Thank you

jacky1234
  • 21
  • 3

1 Answers1

0

I think you refer that when you move the mouse pointer through the JTextField, you cannot see this pointer changing to "text select" mode. I think that you have to change the Cursor to textField1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

I hope it helps :)

  • Hi sorry this command doesnt work they just give me a hand on cursor, – jacky1234 May 11 '17 at 19:02
  • what i need is can use left and right button on keyboard – jacky1234 May 11 '17 at 19:02
  • I am sorry, I miss understood. To browse through the different components, Swing uses Tab key by default, otherwise you should set some listeners in order to manage what you want with the keys that you prefer. This link may give you some ideas about it: [Browse through JButtons using arrow keys](http://stackoverflow.com/questions/7065959/browsing-jbuttons-with-arrow-keys). Good luck :) – Daniel Hernandez May 12 '17 at 06:30