how to set input text onscreen swing keyboard to system caret?










0















i want to write any text or key from swing onscreen keyboard to any caret location like browser notepad office word. i get some example layout, but dont know how to work to system caret. please teach me how it work.



this example code



public class keyboard extends JFrame 

private JPanel contentPane;
public static void main(String args)
EventQueue.invokeLater(new Runnable()
public void run()
try
keyboard frame = new keyboard();
frame.setVisible(true);
frame.setAlwaysOnTop(true);
catch (Exception e)
e.printStackTrace();


);

public keyboard()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(3, 3));
for(int i = 1; i <= 9; i++)
createButton(Integer.toString(i));

pack();


private void createButton(String label)

JButton btn = new JButton(label);
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(100, 100));
contentPane.add(btn);


public void actionPerformed(ActionEvent e)

addMouseListener(new MouseAdapter()
public void mousePressed(MouseEvent e)


);













share|improve this question






















  • You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

    – Sergiy Medvynskyy
    Nov 15 '18 at 7:55












  • thanks sir, i will try and learn it. :D

    – Dzulfikar Fatahillah
    Nov 15 '18 at 11:17















0















i want to write any text or key from swing onscreen keyboard to any caret location like browser notepad office word. i get some example layout, but dont know how to work to system caret. please teach me how it work.



this example code



public class keyboard extends JFrame 

private JPanel contentPane;
public static void main(String args)
EventQueue.invokeLater(new Runnable()
public void run()
try
keyboard frame = new keyboard();
frame.setVisible(true);
frame.setAlwaysOnTop(true);
catch (Exception e)
e.printStackTrace();


);

public keyboard()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(3, 3));
for(int i = 1; i <= 9; i++)
createButton(Integer.toString(i));

pack();


private void createButton(String label)

JButton btn = new JButton(label);
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(100, 100));
contentPane.add(btn);


public void actionPerformed(ActionEvent e)

addMouseListener(new MouseAdapter()
public void mousePressed(MouseEvent e)


);













share|improve this question






















  • You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

    – Sergiy Medvynskyy
    Nov 15 '18 at 7:55












  • thanks sir, i will try and learn it. :D

    – Dzulfikar Fatahillah
    Nov 15 '18 at 11:17













0












0








0








i want to write any text or key from swing onscreen keyboard to any caret location like browser notepad office word. i get some example layout, but dont know how to work to system caret. please teach me how it work.



this example code



public class keyboard extends JFrame 

private JPanel contentPane;
public static void main(String args)
EventQueue.invokeLater(new Runnable()
public void run()
try
keyboard frame = new keyboard();
frame.setVisible(true);
frame.setAlwaysOnTop(true);
catch (Exception e)
e.printStackTrace();


);

public keyboard()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(3, 3));
for(int i = 1; i <= 9; i++)
createButton(Integer.toString(i));

pack();


private void createButton(String label)

JButton btn = new JButton(label);
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(100, 100));
contentPane.add(btn);


public void actionPerformed(ActionEvent e)

addMouseListener(new MouseAdapter()
public void mousePressed(MouseEvent e)


);













share|improve this question














i want to write any text or key from swing onscreen keyboard to any caret location like browser notepad office word. i get some example layout, but dont know how to work to system caret. please teach me how it work.



this example code



public class keyboard extends JFrame 

private JPanel contentPane;
public static void main(String args)
EventQueue.invokeLater(new Runnable()
public void run()
try
keyboard frame = new keyboard();
frame.setVisible(true);
frame.setAlwaysOnTop(true);
catch (Exception e)
e.printStackTrace();


);

public keyboard()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(3, 3));
for(int i = 1; i <= 9; i++)
createButton(Integer.toString(i));

pack();


private void createButton(String label)

JButton btn = new JButton(label);
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(100, 100));
contentPane.add(btn);


public void actionPerformed(ActionEvent e)

addMouseListener(new MouseAdapter()
public void mousePressed(MouseEvent e)


);










java swing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 5:33









Dzulfikar FatahillahDzulfikar Fatahillah

64




64












  • You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

    – Sergiy Medvynskyy
    Nov 15 '18 at 7:55












  • thanks sir, i will try and learn it. :D

    – Dzulfikar Fatahillah
    Nov 15 '18 at 11:17

















  • You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

    – Sergiy Medvynskyy
    Nov 15 '18 at 7:55












  • thanks sir, i will try and learn it. :D

    – Dzulfikar Fatahillah
    Nov 15 '18 at 11:17
















You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

– Sergiy Medvynskyy
Nov 15 '18 at 7:55






You can try to use java.awt.Robot to post native events. Here is an example. But you can get some problems with the focus management, because the key events goes posted to the active frame. So when your onscreen keyboard posts an event, this event goes to your app and not to another program. Probably you can avoid this problem by calling the method setFocusableWindowState(false) on your frame.

– Sergiy Medvynskyy
Nov 15 '18 at 7:55














thanks sir, i will try and learn it. :D

– Dzulfikar Fatahillah
Nov 15 '18 at 11:17





thanks sir, i will try and learn it. :D

– Dzulfikar Fatahillah
Nov 15 '18 at 11:17












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313026%2fhow-to-set-input-text-onscreen-swing-keyboard-to-system-caret%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313026%2fhow-to-set-input-text-onscreen-swing-keyboard-to-system-caret%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo