Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, JTextArea has a getText and a setText method and String has a toUpperCase method. Check out this example: <a href="http://www.exampledepot.com/egs/javax.swing.text/ta_EditTextArea.html" rel="nofollow noreferrer">http://www.exampledepot.com/egs/javax.swing.text/ta_EditTextArea.html</a></p> <p><strong>EDIT</strong>:</p> <p>This might work:</p> <pre><code>JTextArea textArea = new JTextArea("some text"); int start = textArea.getSelectionStart(); int end = textArea.getSelectionEnd(); String replace = textArea.getSelectedText().toUpperCase(); textArea.replaceRange(replace, start, end); </code></pre> <p>EIDT 2:</p> <p>Here is a working example:</p> <pre><code>import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextArea; public class Test { JTextArea textArea = new JTextArea("some text"); public Test() { JButton button = new JButton("upper"); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { int start = textArea.getSelectionStart(); int end = textArea.getSelectionEnd(); String replace = textArea.getSelectedText().toUpperCase(); textArea.replaceRange(replace, start, end); } }); JFrame frame = new JFrame(); frame.add(textArea); frame.add(button, BorderLayout.SOUTH); frame.setSize(100, 100); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { new Test(); } } </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. 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