You typed the statement at the wrong spot:
class X {
HERE - WHERE THE FIELD DECLARATIONS GO
X() {
STATEMENT SHOULD GO HERE
}
The compiler thinks to deal with a declaration, starting with a class, which may be x.y.z.C
.
Pregunta
It happened when I tried to use a ListSelectionModel.
Did I made some mistake?
Solución 2
You typed the statement at the wrong spot:
class X {
HERE - WHERE THE FIELD DECLARATIONS GO
X() {
STATEMENT SHOULD GO HERE
}
The compiler thinks to deal with a declaration, starting with a class, which may be x.y.z.C
.
Otros consejos
You need to invoke the statement in a code block such as a method or constructor rather than the class block.
class AdminConsole ... {
void initComponents() {
...
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
...
}
}
Side note: setSelectionMode
is undefined for ListSelectionModel
- instead it needs to be invoked on the JTable