【发布时间】:2015-03-05 20:33:31
【问题描述】:
我正在尝试制作一个刷新按钮,当我单击该按钮时,它基本上会重新启动程序。我不知道该怎么做。
我已经放置了我决定使用的图形用户界面来完成这个动作。任何和所有的帮助将不胜感激。
package pdfView;
import javax.swing.*;
import java.awt.*;
public class View extends JFrame {
public View() {
super("PDF Viewer");
setLookAndFeel();
setSize(500, 125);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flo = new FlowLayout();
setLayout(flo);
JTextField Search = new JTextField ("Search", 29);
JButton Search1 = new JButton("Search");
//this is where i have the button
JButton ReFresh = new JButton("ReFresh");
add(Search);
add(Search1);
add(ReFresh);
setVisible(true);
}
private void setLookAndFeel() {
try {
UIManager.setLookAndFeel(
"com.sun.java.squing.plaf.nimbus.NimbusLookAndFeel"
);
} catch (Exception exc){
}
}
public static void main(String[] args) {
View pdf = new View();
}
}
【问题讨论】:
-
当您的按钮被点击时,您需要使用事件处理程序来执行代码。然后你就可以执行你的刷新代码了。
标签: java swing button refresh listener