To start with, SwingIsAProperNoun !
Secondly, swing is a front end technology framework. It has nothing which will let you interact with the DB directly. You will need to write JDBC code to do that.
Thank you for the reply. Ya i know how to link database but my problem is to create a form with cambobox, pressing on which a calender should be displayed and after selecting date month year it should be set to textfield so that i can insert it into the database. is their any code to do that
Narendra kodli wrote:Thank you for the reply. Ya i know how to link database but my problem is to create a form with cambobox, pressing on which a calender should be displayed and after selecting date month year it should be set to textfield so that i can insert it into the database. is their any code to do that
No. You will have to code it yourself.
All these components will provide you with appropriate getterXXX methods which you can use to retrieve user selected/input values. Once you have these values you can put them in your DB.
For a nice calendar component, check out JCalendar
Narendra kodli
Greenhorn
Joined: Dec 24, 2011
Posts: 19
posted
0
Ok... Now i am able to get date values and my new task is to calculate to date from from date. That is if i give todays date it should calculate and display next year date. I am using spinnerdatemodel and jspinner. How to do that
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 4041
posted
0
> That is if i give todays date it should calculate and display next year date. I am using spinnerdatemodel and jspinner. How to do that
post the code you've tried.
Narendra kodli
Greenhorn
Joined: Dec 24, 2011
Posts: 19
posted
0
Here is my code
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.text.*;
import java.util.*;
import javax.swing.text.*;
import javax.swing.event.*;
public class calender extends JFrame {
Michael Dunn wrote:I'd suggest you fix the GUI part before attempting to add functionality to it.
Narendra kodli
Greenhorn
Joined: Dec 24, 2011
Posts: 19
posted
0
I don't know why you guys stick d with gui... any ways as you said i have replaced JLables and Choice with JCombobox. now can you tell me how to find next date from given date??
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 4041
posted
0
if I'm reading the code right, spinner1's value is to be set by a combination of spinner's date + the combobox time period.
if so:
1) create a method to set spinner1's date via java.util.Calendar class (let's call it 'cal')
set cal's time to that of spinner
create an int[] representing the periods in months 1,3,6,12 (monthly, quarterly etc)
add to cal (Calendar.MONTH field), int[comb1.getSelectedIndex()], which will add 1,3,6 or 12 months to cal.
now set spinner1's value to cal.
2) add listeners to spinner (not spinner1) and to comb1, so that whenever spinner or comb1 change,
the change will reset spinner1's value
Aromal ayyappan
Greenhorn
Joined: Jan 03, 2012
Posts: 3
posted
0
By overriding the getNextValue() method , I think you can achieve the incremening the year by one.
Calendar cal = Calendar.getInstance();
cal.setTime((Date)getValue());
cal.add(Calendar.YEAR,1);
//cal.add(getCalendarField(), 1);
Date next = cal.getTime();
return next;
}
};
Narendra kodli
Greenhorn
Joined: Dec 24, 2011
Posts: 19
posted
0
By above method i am able to change only day or only month or only year for only one time. But i want all three fields to be changed based on spinner change listener for each change made.