• Post Reply 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I Seriously Need Helps.. Ugently

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm doin my semester project and need to be hand-in by the 22 April..
So i seriously need help ugently..
I'm doin a Calendaer Planner application whereby user have to enter the Year & select the Month from drop-down list and follows by clicking on the New Calendar button.. doin so, the no. of days would then appear in a JList.. ( As u know, different months, have different no. of days ) therefore i'm not too sure if what i did is correct becos it can't be compile..
The Errors is ~
D: AppointmentPage.java:121: cannot resolve symbol
symbol : constructor JList (int[])
location: class javax.swing.JList
Daylist = new JList(noOfDays);
^
I putting up my source code.. Please help me.. Thanks alot..

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.JList;

class AppointmentPage extends JFrame implements ActionListener {
private static final int FRAME_WIDTH = 420;
private static final int FRAME_HEIGHT = 470;
private static final int FRAME_X_ORIGIN = 280;
private static final int FRAME_Y_ORIGIN = 140;
private static final int BUTTON_WIDTH = 70;
private static final int BUTTON_HEIGHT = 30;

private static final int FEBRUARY = 1; // special month during leap year
private JButton addButton;
private JButton editButton;
private JButton printButton;
private JButton backButton;
private JButton mainButton;
private JButton CalButton;
private JLabel image ;
private JTextField dayInput ;
private JTextField timeInput ;
private JTextField yearInput;
private JTextArea appInput ;


// introduce list box
private JList Daylist;
private JScrollPane scrollPaneDaylist;


public static void main (String[] args){
AppointmentPage frame = new AppointmentPage();
frame.setVisible(true);

}

public AppointmentPage (){

Container contentPane = getContentPane ();
// set the frame properties
setSize (FRAME_WIDTH, FRAME_HEIGHT);
setResizable (false);
setTitle ("View Appointment");
setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
// set the content pane properties
contentPane.setLayout (null);
contentPane.setBackground (Color.pink);


String Months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};


int DaysInMonth[] = {31, 28, 31, 30, // January, February, March, April
31, 30, 31, 31, // May, June, July, August
30, 31, 30, 31}; // September, October, November, December


//Date object to get current month & year
Date now = new Date();


// Month & Year entered by user
int userMonth;
int userYear;
int numDays;

String dayStr; //number of days in month


// Month & Year to current values
userMonth = now.getMonth();
userYear = now.getYear() + 1900;



// Add images
image = new JLabel (new ImageIcon("viewApp.jpg"));
image.setBounds (10,20,390,50);
contentPane.add (image);



//Add Year textbox
yearInput = new JTextField ("1996",5);
yearInput.setBounds (70,100,50,20);
yearInput.setText(String.valueOf(userYear));
contentPane.add (yearInput);

// Add ComboBox to get month from user, add months, set default to now
Choice monthChoice = new Choice();
monthChoice.setBounds (147,100,90,20);
for(int i = 0; i < 12; i++)
monthChoice.addItem(Months[i]);
monthChoice.select(userMonth);
contentPane.add (monthChoice);
// Add Calbutton Button
CalButton = new JButton ("New Calendar");
CalButton.setBounds (260,100,120,BUTTON_HEIGHT);
contentPane.add (CalButton);

// Add Daylist
int[] noOfDays = {0,1,2,3};
Daylist = new JList(noOfDays);
Daylist.setBounds (70,150,80,100);
contentPane.add(Daylist);

// Add scroll bars to the list
scrollPaneDaylist = new JScrollPane (Daylist);
scrollPaneDaylist.setBounds (70,150,50,180);
contentPane.add (scrollPaneDaylist);


if (Months[userMonth] == "JANUARY" || Months[userMonth] == "MARCH" || Months[userMonth] == "MAY" || Months[userMonth] == "JULY" || Months[userMonth] == "AUGUST" || Months[userMonth] == "OCTOBER" || Months[userMonth] == "DECEMBER") {
noOfDays[0] = 31;

for (noOfDays[0] = 0; noOfDays[0] <= 31; noOfDays[0]++) {
System.out.println("1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" + "10" + "11" + "12" + "13" + "14" + "15" + "16" + "17" + "18" + "19" + "20" + "21" + "22" + "23" + "24" + "25" + "26" + "27" + "28" + "29" + "30" + "31");
}

/*else if (Months[userMonth] == "APRIL" || Months[userMonth] == "JUNE" || Months[userMonth] == "SEPTEMBER" || Months[userMonth] == "NOVEMBER") {

for (noOfDays[0] = 0; noOfDays[0] <= 30; noOfDays[0]++) {
System.out.println("1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" + "10" + "11" + "12" + "13" + "14" + "15" + "16" + "17" + "18" + "19" + "20" + "21" + "22" + "23" + "24" + "25" + "26" + "27" + "28" + "29" + "30");
}
}

else {
// Get number of days in months, adding 1 if Frebruary of leap year
noOfDays = DaysInMonth[userMonth] +
((IsLeapYear(userYear) && (userMonth == FEBRUARY))? 1:0);

for (noOfDays[0] = 0; noOfDays[0] <= 29; noOfDays[0]++) {
System.out.println("1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" + "10" + "11" + "12" + "13" + "14" + "15" + "16" + "17" + "18" + "19" + "20" + "21" + "22" + "23" + "24" + "25" + "26" + "27" + "28");
}
}
*/
}





// Add 3 textfield
dayInput = new JTextField (" ");
dayInput.setBounds (147,160,130,20);
contentPane.add (dayInput);

timeInput = new JTextField (" ");
timeInput.setBounds (147,195,80,20);
contentPane.add (timeInput);

appInput = new JTextArea (" ");
appInput.setBounds (147,235,200,80);
contentPane.add (appInput);


// create and place 5 buttons on the frame's content pane
addButton = new JButton ("Add New");
addButton.setBounds (47,360, 100, BUTTON_HEIGHT);
contentPane.add (addButton);
editButton = new JButton ("Edit");
editButton.setBounds (183,360, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (editButton);
printButton = new JButton ("Print");
printButton.setBounds (293,360, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (printButton);

backButton = new JButton ("Back");
backButton.setBounds (131,400, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (backButton);

mainButton = new JButton ("Main");
mainButton.setBounds (238,400, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (mainButton);

// register this frame as an action listener of the 5 buttons
addButton.addActionListener (this);
editButton.addActionListener (this);
printButton.addActionListener (this);
backButton.addActionListener (this);
mainButton.addActionListener (this);

}
public void setDayInput(String dayInput,boolean editable) {
this.dayInput.setText(dayInput);
this.dayInput.setEditable(editable);
}

public String getDayInput() {
return dayInput.getText();
}

public void setYearInput(String yearInput,boolean editable) {
this.yearInput.setText(yearInput);
this.yearInput.setEditable(editable);
}

public String getYearInput() {
return yearInput.getText();
}

public void setTimeInput(String timeInput,boolean editable) {
this.timeInput.setText(timeInput);
this.timeInput.setEditable(editable);
}

public String getTimeInput() {
return timeInput.getText();
}

public void setAppInput(String appInput,boolean editable) {
this.appInput.setText(appInput);
this.appInput.setEditable(editable);
}

public String getAppInput() {
return appInput.getText();
}



public boolean action(Event e, Object o) { // Update month & year globals, paint when user clicks button

int userMonth;
int userYear;
int userYearInt;
Choice monthChoice = new Choice();

if (e.target instanceof Button) {
if ("New Calendar".equals((String)o)) {

// Get month from combo box (Choice control).
userMonth = monthChoice.getSelectedIndex();
// Get year from TextField, update userYear only if year ok.
userYearInt = Integer.parseInt(yearInput.getText(), 10);
if (userYearInt > 1581)
userYear = userYearInt;

return true;

}
}
return false;
}
boolean IsLeapYear(int year) { // determine if given year is a leap year

// if multiple of 100, leap year if multiple of 400
if((year % 100)==0) return ((year % 400)==0);

// otherwise leap year if multiple of 4
return ((year % 4)==0);
}


int CalcLeapYears(int year) { // calculate numbers of leap years since 1582
int leapYears; // number of leap years to return
int hundreds; // number of years multiple of a hundred
int fourHundreds; // number of years multiple of four hundred

// Start at 1582, when modern calendar starts.
if (year < 1582) return (-1);

// Calculate number of years in interval that are a multiple of 4.
leapYears = (year - 1581) / 4;

//Calculate number of years in interval that are a multiple of 100;
//subtract, since they are not leap years.
hundreds = (year - 1501) / 100;
leapYears -= hundreds;

// Calculate number of years in interval that are a multiple of 400;
//add back in, since they are still leap years.
fourHundreds = (year - 1201) / 400;
leapYears += fourHundreds;

return (leapYears);
}



// actionPerformed is invoked when a Button is clicked
public void actionPerformed(ActionEvent e) {

// see which button was clicked
if(e.getSource() == addButton){
enter();
}
if(e.getSource() == editButton){
edit();
}
if(e.getSource() == backButton){
appointment();
}
/*if(e.getSource() == printButton){
print();
}
if(e.getSource() == mainButton){
main();
} */

}
private void enter(){

EnterNew enterFrame = new EnterNew();
enterFrame.setSize(420,470);
enterFrame.setTitle("Appointment Entry");
enterFrame.setVisible(true);
this.setVisible(false);
}

private void edit(){

EditAppointment editFrame = new EditAppointment();
editFrame.setSize(420,470);
editFrame.setTitle("Edit Appointment");
editFrame.setVisible(true);
this.setVisible(false);

}
/*private void print(){

Print printFrame = new Print();
printFrame.setSize(420,470);
printFrame.setTitle("Printing In Process");
printFrame.setVisible(true);
this.setVisible(false);

}*/
private void appointment(){

Appointment appointmentFrame = new Appointment();
appointmentFrame.setSize(420,470);
appointmentFrame.setTitle("Appointment");
appointmentFrame.setVisible(true);
this.setVisible(false);


/*private void main(){

Main mainFrame = new Main();
mainFrame.setSize(420,470);
mainFrame.setTitle("Appointment");
mainFrame.setVisible(true);
this.setVisible(false);
*/

// register 'Exit upon closing' as a default close operation
setDefaultCloseOperation (EXIT_ON_CLOSE);
}


public void actionPerform (ActionEvent event){
if (event.getSource () instanceof JButton){
JButton clickedButton = (JButton) event.getSource();
String buttonText = clickedButton.getText();
setTitle ("You clicked " + buttonText);
} else { // the event source is inputLine
//setTitle ("You entered '" + date.getText() + "'");
}
}
}
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JList constructor takes an Array of Objects, you try to give it an array of int. Variables of type int are _not_ Objects (this holds for all primitive data types in java), therefore this doesn't work. You can use an array of Strings instead, like here:

Good luck! BTW, please change your profile and use a real name.
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks very much..
I have some questions again.. the solution u have got me i did try before.. And i know i can't use that.. becos that one would display fixed values.. as what stated here.. it would appear to have 0 1 2 3..
String[] noOfDaysforList = {"0", "1", "2", "3"};
The thing is for this, i can't display fixed values, the application has to go into a IF statement & a FOR loop to display the no. of days according to the Month selected.. becos i have like eg. JANUARY are to display 1 2 3 ..... 31 then April to display 1 2 3 ...... 30 .. And i'm not too sure what to put in the brackets of the
Daylist = new JList(noOfDaysforList);
for it to be able to read whatever values from the IF statement to display..
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Freya,
Welcome to Javaranch! You'll find this place is great to learn Java and we don't have too many rules, but we do have a Naming Policy. You'll need to change your display name so that you are truly a part of our community.
You can change your display name here.
Thanks. Hope to see you around.
[ April 14, 2004: Message edited by: Gregg Bolinger ]
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks very much..
I have some questions again.. the solution u have got me i did try before.. And i know i can't use that.. becos that one would display fixed values.. as what stated here.. it would appear to have 0 1 2 3..
String[] noOfDaysforList = {"0", "1", "2", "3"};
The thing is for this, i can't display fixed values, the application has to go into a IF statement & a FOR loop to display the no. of days according to the Month selected.. becos i have like eg. JANUARY are to display 1 2 3 ..... 31 then April to display 1 2 3 ...... 30 .. And i'm not too sure what to put in the brackets of the
Daylist = new JList(noOfDaysforList);
for it to be able to read whatever values from the IF statement to display.. Or maybe u can give me a new effertive method to use on it..
Need help very ugently... Thanks
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's something that might make getting the days of the month displayed a
bit easier than the way you're trying to do it now - look for setDays().
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for the code.. it really help me alot.. i have enter it to my own application.. but has a problem of displaying it to the Frame width & Frame height that i want.. The window display now was very small.. guess it's something within the code that u have given me that i have overlook in changing it.. Could u kindly point out to me asap.. Thank u so much..
Btw, i didn't use a JPanel to arrange my stuffs..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
class MyAppCalendar extends JFrame implements ActionListener, ItemListener {
private static final int FRAME_WIDTH = 420;
private static final int FRAME_HEIGHT = 470;
private static final int FRAME_X_ORIGIN = 280;
private static final int FRAME_Y_ORIGIN = 140;
private static final int BUTTON_WIDTH = 70;
private static final int BUTTON_HEIGHT = 30;


private JButton addButton;
private JButton editButton;
private JButton printButton;
private JButton backButton;


private DefaultListModel listModel;
private JList daylist;
private JScrollPane scrollPane;
private JComboBox jcbMonth;
private JComboBox jcbYear;
private JButton showButton;


private JLabel image ;
private JTextField dayInput ;
private JTextField timeInput ;
private JTextArea appInput ;


public static void main (String[] args){
MyAppCalendar frame = new MyAppCalendar();
frame.setVisible(true);
}

public MyAppCalendar (){

Container contentPane = getContentPane ();

// set the frame properties
setSize (FRAME_WIDTH, FRAME_HEIGHT);
setResizable (true);
setTitle ("View Appointment");
setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);

// set the content pane properties
contentPane.setLayout (null);
contentPane.setBackground (Color.pink);


String months[] = {"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"};



// Add images
image = new JLabel (new ImageIcon("viewApp.jpg"));
image.setBounds (10,20,390,50);
contentPane.add (image);



showButton = new JButton("Show days");
showButton.setBounds (270, 100, 100, BUTTON_HEIGHT);
//contentPane.add (showButton);

listModel = new DefaultListModel();
daylist = new JList(listModel);
daylist.setBounds (70,150, 50, 180);
contentPane.add (daylist);

scrollPane = new JScrollPane(daylist);
scrollPane.setBounds (70,150, 50, 180);
contentPane.add (scrollPane);

jcbMonth = new JComboBox();
jcbMonth.setBounds (150,105, 90, 20);
//contentPane.add (jcbMonth);

jcbYear = new JComboBox();
jcbYear.setBounds (60,105, 65, 20);
//contentPane.add (jcbYear);



for(int x = 0; x < 20; x++) {
if(x < 12) jcbMonth.addItem(months[x]);
jcbYear.addItem(""+(x+2004));
}


contentPane.add(jcbMonth);
contentPane.add(jcbYear);
contentPane.add(showButton);
contentPane.add(scrollPane);
pack();
setDays();


// Add 3 textfield
dayInput = new JTextField ("");
dayInput.setBounds (147,160,130,20);
contentPane.add (dayInput);

timeInput = new JTextField ("");
timeInput.setBounds (147,195,80,20);
contentPane.add (timeInput);

appInput = new JTextArea ("");
appInput.setBounds (147,235,200,80);
contentPane.add (appInput);



// create and place 5 buttons on the frame's content pane
addButton = new JButton ("Add New");
addButton.setBounds (47,360, 100, BUTTON_HEIGHT);
contentPane.add (addButton);
editButton = new JButton ("Edit");
editButton.setBounds (183,360, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (editButton);
printButton = new JButton ("Print");
printButton.setBounds (293,360, BUTTON_WIDTH, BUTTON_HEIGHT);
contentPane.add (printButton);

// register this frame as an action listener of the 5 buttons
jcbMonth.addItemListener(this);
jcbYear.addItemListener(this);
showButton.addActionListener(this);

addButton.addActionListener (this);
editButton.addActionListener (this);
printButton.addActionListener (this);


}



// actionPerformed is invoked when a Button is clicked
public void actionPerformed (ActionEvent e) {

setDays();

// see which button was clicked
if(e.getSource() == addButton){
enter();
}
if(e.getSource() == editButton){
edit();
}
/*if(e.getSource() == printButton){
print();
} */
}



private void enter(){

EnterNew enterFrame = new EnterNew();
enterFrame.setSize(420,470);
enterFrame.setTitle("Appointment Entry");
enterFrame.setVisible(true);
this.setVisible(false);
}

private void edit(){

EditAppointment editFrame = new EditAppointment();
editFrame.setSize(420,470);
editFrame.setTitle("Edit Appointment");
editFrame.setVisible(true);
this.setVisible(false);



// register 'Exit upon closing' as a default close operation
setDefaultCloseOperation (EXIT_ON_CLOSE);
}


public void setDays() {
listModel.clear();
int month = jcbMonth.getSelectedIndex();
int year = Integer.parseInt(""+jcbYear.getSelectedItem());
Calendar cal = Calendar.getInstance();
cal.set(year,month,1);
while(month == cal.get(Calendar.MONTH))
{

listModel.addElement(""+cal.get(Calendar.DATE));
cal.add(Calendar.DATE,1);
}
}



public void itemStateChanged(ItemEvent ie){listModel.clear();
}



public void actionPerform (ActionEvent event){
if (event.getSource () instanceof JButton){
JButton clickedButton = (JButton) event.getSource();
String buttonText = clickedButton.getText();
setTitle ("You clicked " + buttonText);
} else { // the event source is inputLine
setTitle ("You entered '" + jcbMonth.getSelectedIndex() + "'");
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in your constructor
1)
...
contentPane.add(jcbMonth);
contentPane.add(jcbYear);
contentPane.add(showButton);
contentPane.add(scrollPane);
pack(); //<--------------------------remove this line
setDays();
...
2)
include this line
setDefaultCloseOperation (EXIT_ON_CLOSE);
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmm.. lastly, i need to find out if the year display is only up to "year 2023".. or it's infinite..??
Thanks once again..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the year values are set here - adjust the upper limit of x
for(int x = 0; x < 20; x++) {
if(x < 12) jcbMonth.addItem(months[x]);
jcbYear.addItem(""+(x+2004)); //<--------------
}
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to select the day from the JList & display my data from the text file into 3 different textfields.. Pls show me a way in doin it..?
Thanks alot.. need a reply ugently..
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to select the day from the JList & display my data from the text file into 3 different textfields.. Pls show me a way in doin it..?

Thanks alot.. need a reply ugently..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add these and the selected date will appear in a JOptionPane - adjust to
however you want this displayed
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry.. from what u have given me the coding for the "daylist".. the next thing i need to do is that i have to display a "appointment" (save in text file according to the "date;month;year;time;appoointment") that user key in.. like:
1) user select year (eg. 2004) & month (eg. January) then show days in JList..
2) user then can select a date (eg. 17)
3) then the appointment saved in the text file under (17;January;2004) would then display the Time & appointment in textbox.
From my logic, i know i have to check if the date, month & year is valid before displaying the appointment..

* the problem now is that i have try serveral time in how to display the appointment accordingly but i kept failing.. Can u help me on this..? Really appreciate ur help.. need a reply asap.. Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's an (almost) totally reworked way of doing what I *think* you're trying to do - modify to suit.
It shows one way of saving/retreiving appointment data.
(note: this will create directories and files)
I'll leave it to you to work out how it works. It is not complete - needs
additional error-handling, 'clean-up' code to delete old files etc.

 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u so so much in making the effor to reply me.. thank u once again..
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mr Michael Dunn,
actually after reading through the code u have given me, i don't quite understand most of it.. it's too difficult for me to understand (mayb it's becos i'm just a year 1 student).. i'm so sorry.. i have only :
1) 2 JComboBox (jcbMonth & jcbYear)
2) 1 JList(daylist)
3) 1 button (showappointment)
4) 3 textbox (dayInput(for dd/mm/yyyy), timeInput & appInput)
i need to display the appointment according to the "jcbMonth" selected, the "jcbYear" selected & the "daylist" selected.. when everything is ok, user click on button "showappointment", it would then display the appointment in the "appInput".. the time in "timeInput" & "the day,month,year" selected in the "dayInput..
*PS: i know u have put in effort to help.. pls continue to help me..
Thanks..
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh ya.. my text file name: "Appointment.txt"

which look like this:
1;January;2004;1.0;PM;break
2;February;2004;2.3;AM;wedding
26;March;2004;11.53;PM; break
28;August;2004;12.0;AM; Birthday
17;June;2004;12.0;PM; Birthday
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble trying to follow how you intend retrieving the appointment data
eg this line in your file
28;August;2004;12.0;AM; Birthday
are you just using a 'next' button, and showing each appointment?
are they saved in date/time order?
perhaps if you posted your current code, I might follow it a bit better.
In my previous code, select a year, a month, a day, and a time
add appointment data to the JTextArea, then click the save button.
If you want to see the appointments for a particular day, again, select
a year, a month, and a day, then click the list button and any appointments
for that day will be listed in the JTextArea.
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is correct :
"If you want to see the appointments for a particular day, again, select
a year, a month, and a day, then click the "Find App" button and any appointments for that day will be listed in the JTextArea. "
My codes:


My Enter new Appointment page (for ur reference):


Really need this ugently... Thanks alot.. appreciate ur help so much..

(Please limit your line length to 120 chars/line -- MdQ)
[ April 18, 2004: Message edited by: Marilyn de Queiroz ]
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mr Michael Dunn..
i finally understood the code u have given me earlier on..
Yes, u have got what i wanted.. Thank u so much.. the only thing is that i dun need to have a dropdown list for the Time.. (i will excluded that in my program)
I have few qns to ask:
1) As i'm goin to retrieve the data from TextFile named ("Appointment.txt"), therefore where should i insert the file name.. is it like this..?

or

2) And i'm afraid i dun quite understand this statement, can u explain to me what is this used for..?

3) The "Save" Button, i intendted to change it to "Update" Button (for user to edit the info straight from the textbox and update it).. From what i know i dun have to change much things to make it update right ? if i'm wrong, pls correct me.. Thanks..

Thanks alot...
[ April 18, 2004: Message edited by: Marilyn de Queiroz ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that when you put code in [code] tags, no line breaks will be insterted. So if you make a really long line, it will force the whole page to be really wide to contain it, which makes the page harder to read for all the other text. That's what's happened to this page. You can edit your previous posts to break up the long lines inside [code] tags, that should help. But you hav eto fix all of them. If just one really long line remains, it will still force the whole page to be really wide.
As for the content of this thread... this is a semester project for school, right? Generally that means you're expected to do most of the work yourself. The other posters here should probably avoid giving too much code, and instead just give suggestions that will help. I know it seems like a lot of work to sort through all these issues in the time you have, but that's what a programming assignment is about - learning these things by doing them yourself.
Good luck...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this is a bit closer to what you want. I combined the time and AM/PM
e.g.
1;January;2004;1.0;PM;break
becomes
1;January;2004;1.0 PM;break //space between 1.0 and PM
To edit or delete an appointment, it must be selected in the JList
Homework solution removed by Gregg Bolinger
[ April 19, 2004: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
See if this is a bit closer to what you want. I combined the time and AM/PM
e.g.
1;January;2004;1.0;PM;break
becomes
1;January;2004;1.0 PM;break //space between 1.0 and PM
To edit or delete an appointment, it must be selected in the JList
Homework solution removed by Gregg Bolinger
[ April 19, 2004: Message edited by: Gregg Bolinger ]


Michael, you have been a great help to Freya and I'm sure that he really appreciates it. But we need to let students complete their own homework. Guiding him is good and teaching, but giving a solution, well, that we just cannot have. Remember, Freya is getting the grade and credit here, not you. I let the first one slide because I felt it was less complete than this one.
Thanks again for helping out.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic