3

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/img833/8688/screenshotoftheproblem.jpg

Javier

2 Answers2

2

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.

1

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?

Awi
  • 285
  • 1
  • 3
  • 12
  • That is the only output I get about the program execution. `debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384 debug1: client_request_x11: request from 127.0.0.1 34408 debug1: channel 1: new [x11] debug1: confirm x11 ` My ssh is: OpenSSH_5.8p2, OpenSSL 1.0.0d 8 Feb 2011 The Host OpenSSH version is: OpenSSH_5.5p1 Debian-6, OpenSSL 0.9.8o 01 Jun 2010 – Javier J. Salmeron Garcia Jul 11 '11 at 17:06
  • I copied the code but did not work, I cannot edit the textbox. – Javier J. Salmeron Garcia Jul 12 '11 at 10:10
  • 1
    Could you try with your ssh session, if your input are being caught with a simple X Window application: xcalc or xterm? – Awi Jul 12 '11 at 13:51
  • Could you try the SimplestGUI within a virtual machine using the exactly same installation (Linux and JVM) than your ssh server? – Awi Jul 19 '11 at 23:30