这是我的启动画面代码,
public class SplashScreen extends JWindow {
private static final long serialVersionUID = 1L;
private BorderLayout borderLayout = new BorderLayout();
private JLabel imageLabel = new JLabel();
private JProgressBar progressBar = new JProgressBar(0, 100);
public SplashScreen(ImageIcon imageIcon) {
imageLabel.setIcon(imageIcon);
setLayout(borderLayout);
add(imageLabel, BorderLayout.CENTER);
add(progressBar, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(null);
}
public void showScreen() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setVisible(true);
}
});
}
public void close() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setVisible(false);
dispose();
}
});
}
public void setProgress(final …Run Code Online (Sandbox Code Playgroud) String[] k1 = {"0.10", "0.2", "0.1", "0", "1.10", "1.2", "1.1", "1", "2.10", "2", "2.2", "2.1"};
double[] k2 = {0.10, 0.2, 0.1, 0, 1.10, 1.2, 1.1, 1, 2.10, 2, 2.2, 2.1};
Arrays.sort(k1);
Arrays.sort(k2);
System.out.println(Arrays.toString(k1));
System.out.println(Arrays.toString(k2));
Run Code Online (Sandbox Code Playgroud)
输出:
[0, 0.1, 0.10, 0.2, 1, 1.1, 1.10, 1.2, 2, 2.1, 2.10, 2.2]
[0.0, 0.1, 0.1, 0.2, 1.0, 1.1, 1.1, 1.2, 2.0, 2.1, 2.1, 2.2]
Run Code Online (Sandbox Code Playgroud)
我想拥有什么,
[0, 0.1, 0.2, 0.10, 1, 1.1, 1.2, 1.10, 2, 2.1, 2.2, 2.10]
Run Code Online (Sandbox Code Playgroud)
首先在小数之前和之后排序.像1,1.1,1.2,1.10,2,2.1等.
我怎么能为此写一个比较器?
例:
public class JFrameTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
JButton button = new JButton("Hello!");
frame.getContentPane().add(button);
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
frame.setLocationRelativeTo(null);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,即使没有错误,"按钮"对象也只添加一次.我问这个的原因是,我想在JFrame和JDialog上添加一个相同的JPanel对象(在某些表上双击以进行编辑/删除功能).我能够通过拥有两个JPanel对象来解决它,但只是想知道为什么它不可能.