我即将制作我的第一个图形程序而且我被卡住了。我无法让它发挥作用,它没有错误,所以当我在日食上运行时看起来正确,但是新的窗口不会像它应该做的那样打开。它只是整个计划的一小部分。
这是我的代码:
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class Inlupp2 extends JFrame{
JTextField ordFält = new JTextField();
JTextArea display = new JTextArea();
Inlupp2() {
super("Inlupp2");
JPanel norr = new JPanel();
add(norr, BorderLayout.NORTH);
JLabel lab = new JLabel("Ny: ");
norr.add(lab);
norr.add(ordFält);
JButton searchKnapp = new JButton("Search");
norr.add(searchKnapp);
searchKnapp.addActionListener(new SearchLyss());
JButton hideKnapp = new JButton("Hide place");
norr.add(hideKnapp);
hideKnapp.addActionListener(new HideLyss());
JButton deleteKnapp = new JButton("Delete places");
norr.add(deleteKnapp);
deleteKnapp.addActionListener(new deleteKnapp());
JButton locationKnapp = new JButton("What is here?");
norr.add(locationKnapp);
locationKnapp.addActionListener(new locationKnapp());
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(600, 500);
setVisible(true);
}
class locationKnapp implements ActionListener{
public void actionPerformed(ActionEvent ave){
}
}
class deleteKnapp implements ActionListener{
public void actionPerformed(ActionEvent ave){
}
}
class HideLyss implements ActionListener{
public void actionPerformed(ActionEvent ave){
}
}
class SearchLyss implements ActionListener {
public void actionPerformed(ActionEvent ave) {
}
}
public static void String(String[] args) {
new Inlupp2();
}
}
答案 0 :(得分:3)
我认为在你写的地方:
public static void String(String[] args) {
new Inlupp2();
}
你应该写:
public static void main(String[] args) {
new Inlupp2();
}
答案 1 :(得分:0)
您意外地修改了main方法(这是一个起点/入口点),将其命名为String。
所以而不是
public static void String(String[] args) {
将其更改为:
public static void main(String[] args) {