Ubuntu上JDialog之后的Java小程序JTextField不可访问
我在Ubuntu上使用java有两个问题:Ubuntu上JDialog之后的Java小程序JTextField不可访问,java,swing,ubuntu,jtextfield,jdialog,Java,Swing,Ubuntu,Jtextfield,Jdialog,我在Ubuntu上使用java有两个问题: JTextField无法访问,您无法在其中键入任何内容。要复制,您必须单击标签(“单击此标签”),它将打开我的扩展JDialog。使用“取消”按钮关闭后,JTextField将无法访问。问题是它不是一直都在发生。我想大概是1比10。发生这种情况时,您必须再次单击浏览器窗口上的其他位置或打开对话框 第二个问题是,当ubuntu打开JDialog时,它会创建另一个进程,显示在左侧的应用程序栏上。您可以单击对话框下小程序的某个位置,该对话框将进入浏览器,即使
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import client.utilities.GUIUtilities;
@SuppressWarnings("serial")
public class TestApplet extends JApplet {
public void init() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JApplet applet = TestApplet.this;
applet.setLayout(new FlowLayout());
JTextField ts = new JTextField("Test text");
ts.setColumns(10);
applet.add(ts);
applet.add(getCallCalendarButton(ts));
}
});
} catch (Exception e) {
System.err.println(e.getCause());
}
}
private JLabel callCalendarButton;
private MyDialog aDialog;
protected JLabel getCallCalendarButton(final JComponent cmp) {
if (callCalendarButton == null) {
callCalendarButton = new JLabel("Click this label!!");
callCalendarButton.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (callCalendarButton.isEnabled()) {
Frame parentFrame = null;
if (parentFrame == null)
parentFrame = GUIUtilities.getParentFrame(cmp);
System.out.println(parentFrame);
aDialog = new MyDialog(parentFrame, cmp);
aDialog.setVisible(true);
System.out.println("qwewqe");
cmp.requestFocusInWindow();
}
}
});
}
return callCalendarButton;
}
}
下面是扩展的JDialog类(MyDialog.java):
要使用此html运行小程序,请执行以下操作:
<html>
<body>
<Applet Code="TestApplet.class" width="200" height="100" >
</Applet>
</body>
</html>
在对话框消失后,尝试将焦点请求安排为200(?)毫秒。使用单个fire Swing计时器/ActionListener
调用它。不幸的是,小程序通常在一个或另一个浏览器中存在焦点问题。不幸的是,它无法工作。同样的问题依然存在。在我写这篇文章的时候,这个问题并不是因为焦点丢失,而是因为你不能用鼠标点击进入文本框。它被阻塞并且没有响应。激活它的唯一方法是单击html站点上的其他位置,然后再次单击小程序。类似的问题是,在mac osx上,请尝试在对话框消失后将焦点请求安排为200(?)毫秒。使用单个fire Swing计时器/ActionListener
调用它。不幸的是,小程序通常在一个或另一个浏览器中存在焦点问题。不幸的是,它无法工作。同样的问题依然存在。在我写这篇文章的时候,这个问题并不是因为焦点丢失,而是因为你不能用鼠标点击进入文本框。它被阻塞并且没有响应。激活它的唯一方法是单击html站点上的其他位置,然后再次单击applet。类似的问题,但在MacOSX上
<html>
<body>
<Applet Code="TestApplet.class" width="200" height="100" >
</Applet>
</body>
</html>