Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How can I debug it ?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
My swing design is composed with 3-ComboBox & JTable.
I want search specific Table record which correspond to JComboBox
value. After I compile Selection.java file,
I got the following error message.
Can anyone help me to solve this problem ?

My e-mail address is

xcom98@chollian.net

Thanks for reading !!
================================================================================
Selection.java
================================================================================
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;

/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
public class Selection extends JFrame implements ActionListener {

int to;

JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();

JTable jTable1;

Object[][] data1 = {
{"440", "GMC-3000", "300", "GTH-600", "400-600", "GMC-150", "GMC-300", "ABS803a", "800", "200"},
{"220", "GMC-150", "150", "GTH-220", "160-240", "GMC-100", "GMC-150", "ABS403a", "400", "100"},
{"165", "GMC-150", "140", "GTH-220", "120-180", "GMC-85", "GMC-150", "ABS403a", "300", "100"},
{"528", "GMC-400", "400", "GTH-600", "400-600", "GMC-220", "GMC-400", "ABS1003a", "1000", "325"},
{"264", "GMC-180", "180", "GTH-400", "200-300", "GMC-100", "GMC-180", "ABS603a", "500", "150"},
{"198", "GMC-150", "140", "GTH-220", "160-240", "GMC-100", "GMC-150", "ABS403a", "350", "100"},

};

Object[][] data2 = {
{"440", "GMC-600", "600", "GTH-600", "400-600", "", "", "ABS803a", "800", "250"},
{"200", "GMC-220", "220", "GTH-220", "160-240", "", "", "ABS403a", "400", "150"},
{"176", "GMC-180", "180", "GTH-220", "160-240", "", "", "ABS403a", "350", "150"},
{"528", "GMS-600", "600", "GTH-600", "400-600", "", "", "ABS1003", "1000", "325"},
{"264", "GMS-300", "300", "GTH-400", "200-300", "", "", "ABS603a", "500", "200"},
{"211", "GMS-300", "250", "GTH-400", "200-300", "", "", "ABS403a", "400", "200"},
};
String[] columnNames = {"모터부하",
"전자접촉기",
"정격사용전류",
"과부하계전기",
"TOR설정",
"시동용접촉기",
"운전용접촉기",
"배선용차단기",
"정격전류",
"전선단면적"};
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();

String[] start = { "Y-Delta 기동", "직입기동"};
String[] voltage = { "200V~240V 3상 60 Hz", "380V~440V 3상 60 Hz","500V~550V 3상 60 Hz"};
String[] mt = { "110kW, 150HP", "132kW, 180HP"};
JComboBox jComboBox1 = new JComboBox(mt);
JComboBox jComboBox2 = new JComboBox(start);
JComboBox jComboBox3 = new JComboBox(voltage);



/**Construct the frame*/
public Selection() {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(800, 500));
this.setTitle("기종선정 프로그램");
jLabel1.setText("기동 조건");
jLabel2.setText("정격전압");
jLabel3.setText("모터출력");
jPanel1.add(jLabel1, null);
jPanel1.add(jComboBox2, null);
jPanel1.add(jLabel2, null);
jPanel1.add(jComboBox3, null);
jPanel1.add(jLabel3, null);
jPanel1.add(jComboBox1, null);
jPanel1.add(jScrollPane1, null);

contentPane.add(jPanel1, BorderLayout.NORTH);

jComboBox1.setSelectedIndex(0);
jComboBox2.setSelectedIndex(0);
jComboBox3.setSelectedIndex(0);

jComboBox1.addActionListener(this);
jComboBox2.addActionListener(this);
jComboBox3.addActionListener(this);
public void actionPerformed(ActionEvent e) {

if(jComboBox2.getSelectedIndex() == 0){
to = 3* (jComboBox3.getSelectedIndex()) + jComboBox1.getSelectedIndex();

jTable1 = new JTable(data1[0][to], columnNames);
}
if(jComboBox2.getSelectedIndex() == 1){
to = 3* (jComboBox3.getSelectedIndex()) + jComboBox1.getSelectedIndex();
jTable1 = new JTable(data2[0][to], columnNames);
}
}
jScrollPane1.getViewport().add(jTable1, null);
jTable1.setPreferredScrollableViewportSize(new Dimension(790, 300));



}

/**Main method*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Selection frame = new Selection();
frame.setVisible(true);
}
catch(Exception e) {
e.printStackTrace();
}
}

}

================================================================================

C:\Selection>javac Selection.java
Selection.java:106: illegal start of expression
public void actionPerformed(ActionEvent e) {
^
Selection.java:18: Selection should be declared abstract; it does not define act
ionPerformed(java.awt.event.ActionEvent) in Selection
public class Selection extends JFrame implements ActionListener {
^
2 errors
================================================================================
Design Comment)
1. I've intentionally put actionPerformed method
inside Constructor, because I had seen many examples like this way.
Is it all right ?
2.

In the above method, I tried to read data1 or data2 by jComboBox2 and uesd getSelectedIndex()
method to count array (data[][])index.
I wonder if I successfully implemented.
Sincerely.
p.s ;
I feel sorry because I cross posted this message.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Cross posting is a no-no. See this post for responses to your question.
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic