Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ProgramCalendar
- //
- import java.awt.*;
- import java.applet.*;
- import javax.swing.*;
- import java.util.GregorianCalendar;
- import java.util.Calendar;
- import java.util.Date;
- import java.awt.event.*;
- class GUI extends JFrame
- {
- public static void main(String[]args)
- {
- GUI f=new GUI();
- JColorChooser color= new JColorChooser ( );
- //color.setColor( Color.RED);
- f.add(color);
- f.setSize(350,80);
- f.setResizable(false);
- f.setVisible(true);
- f.setLocation(420,350);
- }
- GUI()
- {
- getContentPane().setBackground(new Color(54,54,54));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- getContentPane().setLayout(null);
- // Text Field
- Date date=new Date();
- java.text.SimpleDateFormat d=new java.text.SimpleDateFormat("dd/MM/yyyy");
- d.applyPattern("06/10/1995");
- JTextField txt = new JTextField(d.format(date));
- txt.setForeground(Color.blue);
- txt.setBounds(50,10,140,20);
- getContentPane().add(txt);
- // Button
- JButton btn1 = new JButton("Change");
- btn1.setForeground(Color.green);
- btn1.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- GregorianCalendar g=new GregorianCalendar();
- txt.setText(g.get(Calendar.DATE)+"/"+(g.get(Calendar.MONTH)+1)+"/"+g.get(Calendar.YEAR));
- }
- });
- btn1.setBounds(200,10, 80, 20);
- getContentPane().add(btn1);
- //lable
- final JLabel j = new JLabel("Date");
- j.setForeground(Color.red);
- j.setBounds(10, 10, 80, 20);
- getContentPane().add(j);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment