java对话框转圈圈
时间: 2024-05-04 20:13:49 浏览: 12
以下是使用Java编写的一个转圈圈对话框的示例代码[^1]:
```java
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SpinnerDialogExample {
public static void main(String[] args) {
JFrame frame = new JFrame("Spinner Dialog Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
JButton button = new JButton("Open Spinner Dialog");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JDialog dialog = new JDialog(frame, "Spinner Dialog", true);
dialog.setSize(200, 100);
dialog.setLocationRelativeTo(frame);
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
dialog.add(progressBar, BorderLayout.CENTER);
dialog.setVisible(true);
}
});
frame.add(button, BorderLayout.CENTER);
frame.setVisible(true);
}
}
```
这个示例使用了Java的Swing库来创建一个带有转圈圈进度条的对话框。当点击按钮时,会弹出一个对话框,其中包含一个转圈圈的进度条。这个进度条会不断旋转,表示正在进行某个操作。