我试图弄清楚是否使用Java中的布局管理器创建了给定的GUI。如果有一个import语句,则表示GUI是使用布局管理器生成的吗?
import java.awt.*;
import javax.swing.*;
public class Interface extends WindowAdapter {
JFrame f;
Interface() {
int a=JOptionPane.showConfirmDialog(f,"Would you like to view statistics?");
if(a==JOptionPane.YES_OPTION) {
String displayText = "The amount of times it stalled " + String.valueOf(FollowTheLight.stalls) + "\n";
displayText += "Total travel time: " + String.valueOf(FollowTheLight.totaltime) + "\n";
displayText += "Number of stops: " + String.valueOf(FollowTheLight.invfwd);
JOptionPane.showMessageDialog(null, displayText);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
}
这是一种准确的方法吗?还有其他方法吗?