gpt4 book ai didi

Java :Multiple markers at this line - Syntax error on token “)” , ;预期 - token “(” 上的语法错误,{ 预期

转载 作者:行者123 更新时间:2023-11-29 06:58:41 28 4
gpt4 key购买 nike

我找不到错误。 Eclipse 给我这个错误。每个 { } 都是匹配的。请帮忙。

Multiple markers at this line - Syntax error on token “)”, ; expected - Syntax error on token “(”, { expected

我的代码如下:

import javax.swing.*;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;

import matlabcontrol.MatlabConnectionException;
import matlabcontrol.MatlabInvocationException;

import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

class BackgroundImageJFrame1 extends JFrame {

public BackgroundImageJFrame1() {

JButton b1;
JLabel l1;
final JFileChooser fc = null;
final JTextField textField;
final JButton jb1 = null;
setTitle("Parallel Session");
setSize(400, 400);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);

getContentPane().setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("giphy.gif")));
getContentPane().setLayout(new FlowLayout());

l1 = new JLabel("Parallel Simulation Model");
l1.setForeground(Color.RED);
l1.setFont(new Font("Palatino Linotype", Font.BOLD, 20));
l1.setToolTipText("Getting Started");
l1.setBounds(86, 54, 219, 45);

b1 = new JButton("\n\n LET'S GO!");
b1.setVerticalAlignment(SwingConstants.BOTTOM);
b1.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 14));
b1.setForeground(Color.BLUE);
b1.setBackground(Color.YELLOW);
b1.setToolTipText("To begin click here!");
b1.setBounds(120, 210, 272, 186);

JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
progressBar.setToolTipText("Progress");
progressBar.setBounds(130, 207, 146, 14);

getContentPane().add(l1);
getContentPane().add(b1);
getContentPane().add(progressBar);
// Just for refresh :) Not optional!
setSize(399, 399);
setSize(400, 400);

b1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
JFrame Frame1 = new JFrame();
final JPanel panel1 = new JPanel();

JLabel j1 = new JLabel("Select your model");
panel1.add(j1);
JTextField jt1 = new JTextField();
jt1.setPreferredSize(new Dimension(160, 20));
panel1.add(jt1);
new JButton("Browse");
jb1.setPreferredSize(new Dimension(100, 20));
panel1.add(jb1);

JLabel label1 = new JLabel("Enter the number instances");
Frame1.setVisible(true);
Frame1.setSize(300, 300);
Frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1.add(label1);
Frame1.getContentPane().add(panel1);
panel1.setBackground(Color.CYAN);

final JTextArea t1 = new JTextArea("Enter here");
panel1.add(t1);

JButton b11 = new JButton("SET");
panel1.add(b11);

jb1.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBrowseActionPerformed(null);
}

});
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {
if (fc == null) {
fc = new JFileChooser(".");
}

// Show it.
int returnVal = fc.showOpenDialog(null);

// Process the results.
if (returnVal == JFileChooser.APPROVE_OPTION) {
textField.setText(fc.getSelectedFile().getPath());
} else {
textField.setText("");
}

// Reset the file chooser for the next time it's shown.
fc.setSelectedFile(null);

}


//done
b11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String a = t1.getText();
System.out.println(" " + a);
try {
int itr = Integer.parseInt(a);
for (int i = 1; i <= itr; i++) {
multi m = new multi();

JLabel l1 = new JLabel("MANUEVER DETAILS");
JTextArea p = new JTextArea(
"Enter the manuever here");
panel1.add(l1);
panel1.add(p);
}
} catch (InvocationTargetException
| InterruptedException
| MatlabConnectionException
| MatlabInvocationException e) {
// TODO Auto-generated catch block
((Throwable) e).printStackTrace();
}

}
});

}
});
}

public static void main(String[] args) throws MatlabConnectionException,
MatlabInvocationException, IOException {

EventQueue.invokeLater(new Runnable() {

@Override
public void run() {
try {
System.out.println("hey");

new BackgroundImageJFrame1();
} catch (Exception e) {
e.printStackTrace();
}
}

});

}


}

最佳答案

你有一个方法中的一个方法,将 btnBrowseActionPerformed 方法放在 BackgroundImageJFrame1 之外

关于Java :Multiple markers at this line - Syntax error on token “)” , ;预期 - token “(” 上的语法错误,{ 预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29673111/

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