gpt4 book ai didi

java - JApplet 程序 : error: ')' expected, 错误 : illegal start of type, 预期,错误: ';' 预期

转载 作者:行者123 更新时间:2023-12-01 22:38:41 30 4
gpt4 key购买 nike

代码:

import java.awt.*; 

import javax.swing.*;

import java.awt.event.*;

public class DoubleIt extends JApplet implements actionListener {

JLable lValue;

JTextField tValue;

JButton bDoubble;

public void init(){
setSize(200,400);
Container panel;
panel = getContent.Pane();
panel.setLayout( new FlowLayout());
lValue = new JLable("Int Value");
tValue = new Jtextfield(15);
tValue.SetText("125");
panel.add(lValue);
panel.add(tValue);
bDoubble = new JButton("*");
panel.add(bDoubble);
bDoubble.add.ActionListiner(this);
}//end init

public void actionPerformed(ActionEvent event);
int value;
value = Integer.parseInt(tValue.getText());
value = value * 2;
tValue.setText(" "+value);
}//end method
}//end main

错误:

DoubleIt.java:27:错误:需要标识符

        value = Integer.parseInt(tValue.getText()); 
^

DoubleIt.java:28:错误:需要标识符

        value = value * 2; 
^

DoubleIt.java:29:错误:需要标识符

        tValue.setText(" "+value); 
^

DoubleIt.java:29: 错误:类型非法开始

       tValue.setText(" "+value); 
^

DoubleIt.java:29: 错误:预期为“)”

        tValue.setText(" "+value); 
^

DoubleIt.java:29: 错误: ';'预计

        tValue.setText(" "+value); 
^

DoubleIt.java:29: 错误:类型非法开始

        tValue.setText(" "+value); 
^

DoubleIt.java:29:错误:需要标识符

              tValue.setText(" "+value); 
^

DoubleIt.java:29: 错误: ';'预计

        tValue.setText(" "+value); 
^

我的问题:

我有编译器说我缺少的所有东西,这是括号问题吗?

最佳答案

你的问题就在这里......

public void actionPerformed(ActionEvent event); <--- See the semi colen...

应该是..

public void actionPerformed(ActionEvent event) {

还有...

JLable lValue;
//...
lValue = new JLable("Int Value");

应该是...

JLabel lValue;
//...
lValue = new JLabel("Int Value");

还有...

tValue = new Jtextfield(15);

应该是...

tValue = new JTextField(15);

还有...

tValue.SetText("125");

应该是...

tValue.setText("125");

还有...

bDoubble.add.ActionListiner(this);

应该是...

bDoubble.addActionListener(this);

还有...

public class DoubleIt extends JApplet implements actionListener

应该是...

public class DoubleIt extends JApplet implements ActionListener

还有...

panel = getContent.Pane();

应该是...

panel = getContentPane();

记住,Java 区分大小写,大小写很重要

关于java - JApplet 程序 : error: ')' expected, 错误 : illegal start of type, <identifier> 预期,错误: ';' 预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26521613/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com