以下代码创建一个输入对话框。我该如何定位它?我尝试了 begin.setLocation(X,Y) 但这不起作用。我不知道为什么。
JFrame begin = new JFrame();
Object subjectnumber = JOptionPane.showInputDialog(begin, "Please enter subject number:");
最佳答案
调用 .setLocation()
不起作用,因为您将其分配给基本 Object
类型。
尝试调整您的定义
JOptionPane subjectnumer = new JOptionPane();
subjectnumber.setLocation(x, y);
String result = subjectnumber.show.....
基本的Object
没有方法setLocation
,但是JOptionPane
有。
关于java - 如何在Java中定位输入对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31997060/