开发者

Can't write to textbox in a Swing application executed from console via ssh

I made a swing application with a JFrame. But when I execute this application from the console with java -jar when I am logged via ssh, I cannot write in any of the textboxes. Everything that I write appears in the console rather than in the textbox. See the image attached to show what happens. How can I solve this? Thank you very much in advance.

The problem http://img833.imageshack.us/im开发者_开发百科g833/8688/screenshotoftheproblem.jpg

Javier


I had this problem also but solved by using ssh -Y (instead of -X). Found on forums that some java applications requires trusted (-Y) ssh to work properly. Hope that help others.


I'm assuming you are dealing with unix like operative systems, even you don't mention it. What version of JVM are you using? Is the same version in your ssh server and client? I had a problem with OS X's JVM, I could not run GUI through ssh from a Linux client, but between same Linux flavour, there were no problems. You might want to add debug output to your ssh command line, through "-v" switch. I would recommend trying a very simple application, a trivial example: just a text box on a JFrame; to rule out any possible layout stack or listener issues.

Could you try these code, and see if you can modify the JTextField

public class SimplestGUI extends JFrame
{
    public static void main(String [] args)
    {
        SimplestGUI window = new SimplestGUI();
        window.start();
    }

    public SimplestGUI()
    {
        initGUI();  
    }

    private void initGUI()
    {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(150,100);
        JTextField textField = new JTextField();
        textField.setText("123 probando");
        getContentPane().add(textField);
    }

    public void start()
    {
        setVisible(true);
    }
}

To compile and run use these command (assuming you have a JDK on your PATH):

javac SimplestGUI.java ; java -cp . SimplestGUI 

If that works, then you should start adding your components, listener, adapters, etc. one by one, and see which one is causing the text fields not getting the input. If doesn't work either, then my guess is that you might have a problem with different X Window versions or implementations. ¿Can you share your code to try it on another environment?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜