Skip to main content

Swing incorrect behaviour from JRE5 to JRE6

1 reply [Last post]
singhkanhaiya
Offline
Joined: 2009-07-16
Points: 0

When I am running my application with JRE5 it is working fine. While working with JRE6 I found below mentioned issue.

I am generating jframe. After that clicking on text tool of my toolbar I am opening a JTextPane (In JInternalFrame) on the frame with Linux xvkbd keyboard. Using keyboard focus button I should be able to give focus to JTextPane and add text when click on Linux xvkbd keyboard.

When running with JRE5 I am able to give focus to JTextPane and enter text. But in case of JRE6 I am not able to give focus to JTextPane while clicking on this, the focus is going to parent (blank buffered image page) not to JTextPane. I am pasting a sample code below.

I am adding the code below. This code is using xvkbd keyboard of Ubuntu/Linux keyboard. In case you don't see the xvkbd keyboard please execute this command in terminal.

apt-get install xvkbd (This command will install the xvkbd keyboard on your system).

After running the below code please click on the focus key of xvkbd keyboard and click on the JTextPane added on JIF. Try to enter text in JTextPane from xvkbd keyboard, on JRE5 I am able to enter text in the JTextPane but on the JRE6 could not. Please suggest something on this problem.

package com.focus;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JTextPane;

public class testFocus extends JFrame{

public JTextPane rtfTextPane = new JTextPane();

public testFocus()
{
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
internalFrame.add(rtfTextPane);
internalFrame.setPreferredSize(new Dimension(200, 200));
internalFrame.setSize(new Dimension(200, 200));
internalFrame.setBounds(50, 50, 200, 200);
internalFrame.setVisible(true);
add(internalFrame, BorderLayout.SOUTH);
}

MouseListener listener = new MouseAdapter(){

public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub

}

public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub

}

};
public static void main(String args[])
{
testFocus tf = new testFocus();
tf.setSize(400,400);
tf.setVisible(true);
try {
Process p = Runtime.getRuntime().exec("xvkbd");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

Regards,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
singhkanhaiya
Offline
Joined: 2009-07-16
Points: 0

Got the solution.