Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I'm making a system to convert Mose cord to English alphabet. I'm using jtextfeild called "write" to type text and another jtextfeild call "View" to view which is typed on write.</p> </blockquote> <ul> <li><p>use <code>DocumentListener</code> for <code>JTextComponent</code>s instead of low_level <code>KeyListener</code>, otheriwise you can't be able to input sequence of chars from (for example) <code>Ctrl+C</code> (SystemClipBoard), or remove selected chars, then output to anther <code>JComponent</code>s freeze without any, no changes are made, because <code>KeyListener</code> can firing an <code>Event</code> from single <code>Char</code> only </p></li> <li><p>plus you can use <code>DocumentFilter</code> in the case that you want to replace, remove, modify single <code>char</code> or <code>chars sequence</code> typed by user into <code>JTextField</code></p></li> </ul> <p>for example</p> <p><img src="https://i.stack.imgur.com/WBVYz.jpg" alt="enter image description here"></p> <pre><code>import java.awt.GridLayout; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; public class TextLabelMirror { private JPanel mainPanel = new JPanel(); private JTextField field = new JTextField(20); private JTextField field1 = new JTextField(20); public TextLabelMirror() { field.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateLabel(e); } @Override public void insertUpdate(DocumentEvent e) { updateLabel(e); } @Override public void removeUpdate(DocumentEvent e) { updateLabel(e); } private void updateLabel(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { field1.setText(field.getText()); } }); } }); mainPanel.setLayout(new GridLayout(1, 0, 10, 0)); mainPanel.add(field); mainPanel.add(field1); } public JComponent getComponent() { return mainPanel; } private static void createAndShowUI() { JFrame frame = new JFrame("TextLabelMirror"); frame.getContentPane().add(new TextLabelMirror().getComponent()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { createAndShowUI(); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload