私はGUIインターフェースをやっています。オブジェクトを作成しているときに、エラー メッセージが表示されます。エラー メッセージは MainApp のコメント Building an object for subClass の下にあります。前もって感謝します。コンストラクターに class(class は Java のキーワード) を入れるのを間違えました。
//インポートします。//MainApp.
import javax.swing.JFrame;
public class MainApp
{
public static void main(String[] args)
{
//Building an object for subClass.
subClass class = new subClass();
class.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class.setSize(275,275);
class.setVisible(true);
}
}
//Imports.
//subclass.
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
//
public class subClass extends JFrame
{
private JLabel item1;
//
public subClass()
{
// Sets the Title of the window.
super("Title");
// Sets the layout of the window. FlowLayout is the default layout.
setLayout(new FlowLayout());
item1 = new JLabel("This is a sentence.");
item1.setToolTipText("This is going to show up on hover.");
add(item1);
}