I having a serious problem here. This is the code i wrote and i have yet run it because too many errors. I tried minimize the errors. Anyone can help me? As for now even the simple looping also shows error. If you found any other mistake, feel free to correct this java newbie.
PS:i trying to create a gui to let user key in event name and time, then they can check it back. Below is just the gui part, the array part ...i think not neccessary here =)

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class eventgui {
     JTextField jtfname = new JTextField();

     JLabel jlname = new JLabel("Event:");
     JLabel jlstart = new JLabel("Time:");
     JLabel jlduration = new JLabel("Duration:");

     JButton jbok = new JButton("OK");
     JButton jbclear = new JButton("Reset");
     String[] time = new String[]{"0800","0900","1000","1100","1200","1300","1400","1500","1600","1700","1800","1900","2000","2100","2200"};
     JComboBox jcbtime = new JComboBox(time);
     int x=0;
     int[] duration = new int[x];
     String[] y;

public eventgui(){
     for(int a = 1;a<x;a++){
      y[a] = (String)duration[a];
     }

     JComboBox jcbduration = new JComboBox(y); 

 jcbtime.addActionListener(new ActionListener(){
     public void actionPerformed(ActionEvent e){
         x= (Integer)jcbtime.getSelectedItem();
         x-=2300;
         x/=100;
     }
 });

  for (int i =1;i<x;i++){
      duration[i]=0+x;
  }

 jbok.addActionListener(new ActionListener(){
     public void actionPerformed(ActionEvent e){
         Event x = new Event(jtfname.getText(),(Integer)jcbtime.getSelectedItem(),(Integer)jcbduration.getSelectedItem());
     }});

}
}

Recommended Answers

All 4 Replies

what errors do you get? when do you get them? is the error that occur an actual error, or unexpected behaviour.

I found the error but can't solve it =(
it is the string in combobox can't be null value. but i don't know how to solve it.
my concept is this: the duration is depend on the time(starting time)

Line 17, did you initiate duration again somewhere in your code? It is initially instantiated as 0 length int array? Also, why there are x variables which give no meaning? Then you use it again as Event class object in action listener... Then Lines 29-31, you rely on auto-boxing between Integer and integer; whereas, you initially declare x as integer (line 16)...

I found the error but can't solve it =(

yes, but that doesn't help us very much, does it? understand that most of us are working with very limited time to spend on the forum, and, if you use a DB or input files, or just manual input for that matter, we don't have the same application as you, since we don't know what input you provide.

if you get an error message, copy paste it here, it'll help us a lot more.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.