Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

View Poll Results: Do you think spoonfeeding is more beneficial or harmful to posters?

Voters
3. You may not vote on this poll
  • Of course it's ok always.

    0 0%
  • Usually you probably shouldn't post entire code for them

    1 33.33%
  • Posting a section for them is as far as it should go.

    0 0%
  • It's ok to tell them what to do for every line as long as you don't write all the code for them

    1 33.33%
  • It's ok to help but not to help too much. They'll learn the best if you don't tell them everything.

    1 33.33%
Results 1 to 6 of 6

Thread: Making a clock

  1. #1
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Angry Making a clock

    Ok, I'm still testing out something and I'd like the actual program, that I'm doing demo runs on various parts to see how to get them to work.

    However, I'd like the clock to work.
    package McWoo;
     
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.event.AdjustmentEvent;
    import java.awt.event.AdjustmentListener;
    import java.awt.print.PrinterException;
    import java.io.File;
    import java.sql.Date;
    import java.sql.Time;
    import java.util.Calendar;
    import java.util.Locale;
    import java.util.TimeZone;
     
    import javax.swing.ButtonGroup;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.JScrollBar;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Highlighter;
    import javax.swing.text.Highlighter.HighlightPainter;
    import javax.xml.stream.Location;
     
    import org.xml.sax.Locator;
     
     
     
    public class Testing extends JFrame {
    private JMenu menu,menu2,menu3, menu4;
    private JMenu file, edit, options, help, about;
    private JMenuItem save, saveAs, load, print, exit;
    private JTextArea j;
    private File savedFile;
    private JWindowAdjuster jwa;
    private JMenuBar mBar;
    private JPanel panel;
    private Testing t2;
     
    private class JWindowAdjuster extends JFrame
    {
    	private JScrollBar length, width;
    	private JPanel panel;
    	private JLabel lengthLabel, widthLabel;
    	private ButtonGroup group;
    	private JRadioButtonMenuItem fifteen, thirty, five, forty, hundred;
    	private JMenuBar aBar;
    	private JMenu adjustment;
     
     
     
    	public JWindowAdjuster() throws PrinterException, BadLocationException
    	{
    		setTitle("Adjust Size of Window");
    		Dimension d = new Dimension(200,200);
    		 setFinalSize(d);
     
    	//	final Testing wenguin = new Testing();
    		setVisible(true);
    		length = new JScrollBar(JScrollBar.HORIZONTAL, 300, 0, 30, 2300);
    		width = new JScrollBar(JScrollBar.HORIZONTAL, 300, 0, 30, 2300);
    		mBar = new JMenuBar();
    		panel = new JPanel();
    		panel.setBackground(Color.BLUE);
    	 	group = new ButtonGroup();
    		mBar.setBackground(Color.ORANGE);
    		setJMenuBar(mBar);
    		length.setUnitIncrement(1);
    		lengthLabel = new JLabel("Length:");
    		adjustment = new JMenu("Adjustment Options");
    		mBar.add(adjustment);
    		fifteen = new JRadioButtonMenuItem("By 15");
    		adjustment.add(fifteen);
    		thirty = new JRadioButtonMenuItem("By 30");
    		adjustment.add(thirty);
    		five = new JRadioButtonMenuItem("By 5");
    		adjustment.add(five);
    		group.add(fifteen);
    		group.add(thirty);
    		group.add(five);
    		panel.add(lengthLabel);
    		panel.add(length);
    		widthLabel = new JLabel("Width");
    		panel.add(widthLabel);
    		panel.add(width);
     
    		length.addAdjustmentListener(new AdjustmentListener() {
     
    			@Override
    			public void adjustmentValueChanged(AdjustmentEvent arg0) {
    				// TODO Auto-generated method stub
    				lengthLabel.setText("Length: " + arg0.getValue());
    				Testing t5 = Testing.this;
    				t5.setSize(t5.getWidth(), arg0.getValue());
     
    			}
     
    		});
     
    		width.addAdjustmentListener(new AdjustmentListener() {
     
    			@Override
    			public void adjustmentValueChanged(AdjustmentEvent arg0) {
    				// TODO Auto-generated method stub
    				widthLabel.setText("Width: " + arg0.getValue());
    				Testing t5 = Testing.this;
    				t5.setSize( arg0.getValue(), t5.getHeight());
     
    			}
     
    		});
    		setContentPane(panel);
    	}
     
    	public void setFinalSize(Dimension d)
    	{
    		this.setMaximumSize(d);
    		this.setMinimumSize(d);
     
     
    	}
    }
     
    public Testing() throws PrinterException, BadLocationException
    {
    	setTitle("Testing");
    	setTesting(this);
    jwa = new JWindowAdjuster();
     
    	panel = new JPanel();
     
     
    	mBar = new JMenuBar();
    	setJMenuBar(mBar);
    	mBar.setVisible(true);
    	menu = new JMenu("");
    	mBar.add(menu);
    	menu2 = new JMenu("");
    	mBar.add(menu2);
    menu3 = new JMenu("");
    mBar.add(menu3);
    menu4 = new JMenu("");
    mBar.add(menu4);
     
     
    	Calendar c = Calendar.getInstance();
    Locale[] loc = c.getAvailableLocales() ;
     
    System.out.println(loc[0].getDisplayName());
    System.out.println(Locale.getDefault().getDisplayName());
     
    menu4.setText("Language(Country): " + Locale.getDefault().getDisplayName());
    System.out.println("Is Visible:" + this.isVisible());
    if(panel.isVisible())
    {
     
     
     
     
     
    	int hour = c.get(Calendar.HOUR);
    	int meridan = c.get(Calendar.AM_PM);
    	int minute = c.get(Calendar.MINUTE);
    	int second = c.get(Calendar.SECOND);
    	if (meridan == Calendar.AM)
    	{
    		if (minute < 10 && second < 10)
     
    		menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
    		else if (minute < 10 && second >=10)
     
    			menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " A.M.");
    		else if (second < 10 && minute >=10)
    			menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " A.M.");
    		else
    			menu2.setText(hour + ":" +    minute+ ":"  + second + " A.M.");
    	}
     
    	else
    	{
    		if (minute < 10 && second < 10)
     
    			menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
    			else if (minute < 10 && second >=10)
     
    				menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " P.M.");
    			else if (second < 10 && minute >=10)
    				menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " P.M.");
    			else
    				menu2.setText(hour + ":" +    minute+ ":"  + second + " P.M.");
    	}
    }
    System.out.println(Calendar.SATURDAY);
     
    String str = "Time Zone is: " + c.getTimeZone().getID();
     
    menu3.setText(str);
    	c.setFirstDayOfWeek(Calendar.SUNDAY);
    	System.out.println(c.getFirstDayOfWeek());
    	int weekday = c.get(Calendar.DAY_OF_WEEK);
    	System.out.println("Weekday " +weekday);
     
    	int monthDay = c.get(Calendar.DAY_OF_MONTH);
    	int month = c.get(Calendar.MONTH);
    	int year = c.get(Calendar.YEAR);
    	System.out.println(weekday);
    	TimeZone t2 = c.getTimeZone();
    	System.out.println(t2.toString());
    	menu.setToolTipText("This is the menu when the program was opened, which usually will be the same day as today.");
    	Font aFont= menu.getFont();
     
    	Font anotherFont = aFont.deriveFont(Font.BOLD);
    	menu.setFont(anotherFont);
    	if (month == Calendar.JANUARY)
    	{
    		if (weekday ==1 )
    		{
    	     menu.setText("Sunday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2 )
    		{
    			menu.setText("Monday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 3)
    		{
    			menu.setText("Tuesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4 )
    		{
    			menu.setText("Wednesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday January " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday January " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.FEBRUARY)
    	{
    		if (weekday == 1)
    		{
    	     menu.setText("Sunday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday February " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday February " + monthDay + "," + year);
    	}
     
     
    	else if (month == Calendar.MARCH)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday March " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday March " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.APRIL)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday April " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday April " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.MAY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday May " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday May " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.JUNE)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday June " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday June " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.JULY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday July " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday July " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.AUGUST)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday August " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday August " + monthDay + "," + year);
    	}
     
    	else if (month ==Calendar.SEPTEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday September " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday September " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.OCTOBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday October " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday October " + monthDay + "," + year);
    	}
     
    	else if (month==Calendar.NOVEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday November " + monthDay + "," + year);
     
    		}
     
    		else
    			menu.setText("Saturday November " + monthDay + "," + year);
    	}
     
    	else
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday December " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday December " + monthDay + "," + year);
    	}
     
     
    	setContentPane(panel);
     
    }
     
    public void update(JMenu menu2, JMenu menu3)
    {
    	Calendar c2 = Calendar.getInstance();
    	int hour = c2.get(Calendar.HOUR);
    	int meridan = c2.get(Calendar.AM_PM);
    	int minute = c2.get(Calendar.MINUTE);
    	int second = c2.get(Calendar.SECOND);
    	if (meridan == Calendar.AM)
    	{
    		if (minute < 10 && second < 10)
     
    		menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
    		else if (minute < 10 && second >=10)
     
    			menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " A.M.");
    		else if (second < 10 && minute >=10)
    			menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " A.M.");
    		else
    			menu2.setText(hour + ":" +    minute+ ":"  + second + " A.M.");
    	}
     
    	else
    	{
    		if (minute < 10 && second < 10)
     
    			menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
    			else if (minute < 10 && second >=10)
     
    				menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " P.M.");
    			else if (second < 10 && minute >=10)
    				menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " P.M.");
    			else
    				menu2.setText(hour + ":" +    minute+ ":"  + second + " P.M.");
    	}
     
    	int monthDay = c2.get(Calendar.DAY_OF_MONTH);
    	int month = c2.get(Calendar.MONTH);
    	int year = c2.get(Calendar.YEAR);
    	int weekday = c2.get(Calendar.DAY_OF_WEEK);
    // 	System.out.println(weekday);
    	TimeZone t2 = c2.getTimeZone();
    // 	System.out.println(t2.toString());
    	menu.setToolTipText("This is the menu when the program was opened, which usually will be the same day as today.");
    	Font aFont= menu.getFont();
     
    	//Font anotherFont = aFont.deriveFont(Font.BOLD);
    	//menu.setFont(anotherFont);
    	if (month == Calendar.JANUARY)
    	{
    		if (weekday ==1 )
    		{
    	     menu.setText("Sunday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2 )
    		{
    			menu.setText("Monday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 3)
    		{
    			menu.setText("Tuesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4 )
    		{
    			menu.setText("Wednesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday January " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday January " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.FEBRUARY)
    	{
    		if (weekday == 1)
    		{
    	     menu.setText("Sunday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday February " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday February " + monthDay + "," + year);
    	}
     
     
    	else if (month == Calendar.MARCH)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday March " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday March " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.APRIL)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday April " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday April " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.MAY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday May " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday May " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.JUNE)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday June " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday June " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.JULY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday July " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday July " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.AUGUST)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday August " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday August " + monthDay + "," + year);
    	}
     
    	else if (month ==Calendar.SEPTEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday September " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday September " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.OCTOBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday October " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday October " + monthDay + "," + year);
    	}
     
    	else if (month==Calendar.NOVEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday November " + monthDay + "," + year);
     
    		}
     
    		else
    			menu.setText("Saturday November " + monthDay + "," + year);
    	}
     
    	else
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday December " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday December " + monthDay + "," + year);
    	}
    }
     
     
    public static void main(String[] args) throws PrinterException, BadLocationException
    {
    	Testing t = new Testing();
    /*	while (t.isShowing())
    	{
    		t.update(t.menu2, t.menu3);
    	}
    	*/
    	t.setVisible(true);
    	}
     
    public void setTesting(Testing t2)
    {
    	this.t2 = t2;
    }
     
    public Testing getTesting()
    {
    	return t2;
    }
     
    public int getHeight2()
    {
    	return getTesting().getHeight();
    }
     
    public int getWidth2()
    {
    	return getTesting().getWidth();
    }
     
    public JPanel getPanel()
    {
    	return panel;
    }
    }

    That's my first concern. My second is this:
    package ProjectOfDoom;
     
    public interface MyCollection<T>
    {
     
    public void add(int index, T data);
    public void remove(int index);
    public void addFirst(T data);
    public void addLast(T data);
    public void removeFirst();
    public void removeLast();
    public T get(int index);
    public void removeRange(int from, int to);
    public void removeAll();
    public int Size();
     
    }
    and
    package ProjectOfDoom;
     
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;
    //Paul Adcock
    // Assignment 4
    // Lasted Worked On: 12/31/2010
     
    /*
     this class is the Doubly Linked list class.  It has a Node that holds a reference to some date of type T and has a reference
     
     to the next Node and to the previous Node. It is a generic class than can hold date types.  
     */
     
     
    public class DoublyLinkedList<T> implements MyCollection<T>
    {
     
    	/* This is the generic class Node, a private innner class of DoublyLnkedList.  
    	 */
    	private class Node<T>
    	{
    		/*
    		 * variables
    		 * T data - a variable of generic type
    		 * a Node next, which refers to the Node after the current Node
    		 * a Node previous, which refers to the Node before the current Node
    		 */
    		private T data;
    		private Node<T> next;
    		private Node<T> previous;
     
    		/*
    		 * Constructor Node(T data, Node<T> next, Node<T> previous)
    		 * parameters T data
    		 * a Node next
    		 * a Node previous
    		 */
    		public Node(T data,Node<T> next, Node<T> previous)
    		{
    			this.data = data;
    			this.next = next;
    			this.previous=previous;
    		}
     
    		/*
    		 * returns the data of that Node
    		 */
    		public T getData()
    		{
    			return data;
    		}
     
    		/*
    		 * returns the Node after the current Node
    		 */
    		public Node<T> getNext()
    		{
    			return next;
    		}
     
    		/*
    		 * returns the Node before the current Node
    		 */
    		public Node<T> getPrevious()
    		{
    			return previous;
    		}
     
    		/*
    		 * sets the Node after the current Node to next
    		 */
    		public void setNext(Node<T> next)
    		{
    			this.next = next;
    		}      
     
    		/*
    		 * sets the Node before the current Node to previous
    		 */
    		public void setPrevious(Node<T> previous)
    		{
    			this.previous = previous;
    		}
     
    		/*
    		 * creates a copy of the Node and returns that copy
    		 * @see java.lang.Object#clone()
    		 */
    		public Node<T> clone()
    		{
    			Node<T> copy = new Node<T>(this.getData(), this.getNext(), this.getPrevious());
    			return copy;
    		}
    	}
     
    	/*
    	 * data for class DoublyLinkedList
    	 * Node head - beginning of DoublyLinkedList
    	 * Node tail - end of DoublyLinkedList
    	 * int side - size of DoublyLinkedList
    	 * 
    	 */
    	private Node<T> head;//head of the linked list
    	private Node<T> tail; // tail of linked list
    	private int size;
                        private DoublyLinkedList<T> subDLL;
    private DoublyLinkedList<T> anotherOne, anotherOne2;
    	private ImageIcon icon;
                        private DoublyLinkedList<T> copiedDLL;
    	private Icon icon2;
    	/*
    	 * constructor DoublyLinkedList()
    	 * no parameters
    	 */
    	public DoublyLinkedList()
    	{
    		/*
    		 * sets head and tail to null
    		 * sets size to 0
    		 */
    		head = null;
    		tail = null;
    		size = 0;
    		icon = new ImageIcon("doh3.jpg");
    	}
     
     
     
    	/*
    	 * returns a String of all the elements in the DoublyLinkedList
    	 * @see java.lang.Object#toString()
    	 */
    	public String toString()
    	{
    		String str = "[";
     
    		Node<T> curr;
     
    		for (curr=head;curr!=null;curr = curr.getNext())
    		{
    			str = str + curr.getData().toString();
    			if (curr.getNext()!=null)
    				str = str + " ";
    		}
    		str = str + "]";
    		return str;
     
     
    	}
     
    public T middle()
    {
     
    int middle = (int) (Size() -1 ) /2;
    return (get(middle));
     
    }
     
    	/*
    	 * removeRange(int from, int to)
    	 * from - the starting index to remove
    	 * to - the last index to remove
    	 * removes all values between from and to
    	 */
    	public void removeRange(int from, int to)
    	{
    		if (from < 0 || from >= Size() || to < 0 || to >=Size())
    		{
    			return;
    		}
     
    if (from >=to)
    {
    for (int j = from; j >= to; j--)
    {
    remove(j);
    }
    return;
    }
     
    		for (int i = from; i <=to; i++)
    		{
    			remove(i);
    		}
    	}
     
    	// adds the data as the first element.  If the list size is 0, makes first element tail.  If head is not null, it puts the old
    	// tail as the second element and the new element as the new head.  
    	/*
    	 * addFirst(T data)
    	 * data - the type of data
    	 * adds the data to the beginning of the DoublyLinkedList
    	 */
    	public void addFirst(T data)
    	{  
    		/*  Since this is the first Object,  previous should be null
    		 */
    		Node<T> newNode = new Node<T>(data,head,null);
    		//We know that if head is null, the list is empty
    		if (head==null)
    		{
    			//If the list is empty,  tail will be newNode
    			tail = newNode;
    		}
     
    		if(head!=null)
    			head.setPrevious(newNode);
     
    		//We want to set head to be newNode
    		// if the list was empty before, both head and tail will be set to newNode;
    		head = newNode;
    		//Increment Size
    		size++;
    	}
     
    	/*
    	 * removes the data the begining of the DoublyLinkedList
    	 */
    	public void removeFirst()
    	{
    		if (size == 0)
    		{
    			JOptionPane pane = new JOptionPane();
    			pane.setIcon(icon);
    			pane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			pane.setMessageType(JOptionPane.ERROR_MESSAGE);
     
    			return;
    		}
    		Node<T> current = head; // creates a Node called current and sets it to head.
     
    		head = head.getNext(); //move head to the next element
     
    		current.setNext(null);
    		size--;
    	}
     
    	/*
    	 * addLast(T data)
    	 * parameters data
    	 * data- the data to be added
    	 * adds data to end of DoublyLinkedList
    	 */
    	public void addLast(T data)
    	{
    		//If there are no elements, use the addFirst method
    		if (tail == null)
    		{
    			addFirst(data);
    			return;
    		}
    		/* Create the new Node from the data. Set next to null
    		 * because this will be the last element and will not
    		 * have a next. Set previous to tail because tail has
    		 * not been changed yet and is currently referencing
    		 * that element that will be directly before this element
    		 */
    		Node<T> newNode = new Node(data,null,tail);
    		/* Since the tail variable still references the element
    		 * directly before the new element, we can set that node's
    		 * next to our new element.
    		 */
    		tail.setNext(newNode);
    		//Set tail to our new Node
    		tail = newNode;
    		//Increment size
    		size++;
    	}
     
    	/*
    	 * returns the size of the DoublyLinkedList
    	 */
    	public int Size()
    	{
    		return(size);
    	}
     
    	/*
    	 * add(int index, T data)
    	 * parameters index, data
    	 * index - the index to add the data
    	 * data- the data to add
    	 * adds the data at the specified index
    	 */
    	public void add(int index,T data)
    	{
    		int i;
    		if (index == 0)
    		{
    			addFirst(data);
    			return;
     
    		}
    		if (index>size)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
    		if (index < 0)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
    		if (head==null)
    		{
    			addFirst(data);
    			return;
    		}
     
    		if (index == size)
    		{
    			addLast(data);
    			return;
    		}
     
    		//step 1
    		Node<T> current;
     
    		current = head;
     
    		for (i=0;i<index-1;i++)
    		{
    			current = current.getNext();
    		}
     
    		//current now refers to object immediately before new node
     
    		//step 2
    		Node<T> newnode = new Node<T>(data,current.getNext(), current.getPrevious());
     
    		//step 3
     
    		current.setNext(newnode);
     
     
    		size++;
    	}  
     
    	/*
    	 * remove(int index)
    	 * parameters index
    	 * index- the index of the data to remove
    	 * removes the data at the specified index
    	 */
    	public void remove(int index)
    	{
    		if ((index<0) || (index>=size))
    		{
    			JOptionPane.showMessageDialog(null, "You cannot remove an out-of-bounds value!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
     
    		Node <T> next2, previous3;
    		Node<T> NodeToRemove = head; // sets Node to remove originally to head
     
     
    		for (int v = 0; v < index; v++)
    		{
    			NodeToRemove = NodeToRemove.getNext(); // traverse to Node we want to remove
    		}
     
    		previous3 = NodeToRemove.getPrevious(); // sets previous3 to value before Node to remove
    		next2 = NodeToRemove.getNext(); // sets next2 to value after Node to remove
     
    		if (previous3 == null)
    		{
    			if (next2 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				head = next2;
    			}
    		}
     
    		else
    		{
    			previous3.setNext(next2);
    		}
     
    		if (next2 == null)
    		{
    			if (previous3 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				tail = previous3;
    			}
    		}
    		else
    		{
    			next2.setPrevious(previous3);
    		}
     
     
    		size--;
    	}
     
    	/*
    	 * get(int i)
    	 * parametsrs i
    	 * i - the index
    	 * returns the data at index i
    	 */
    	public T get(int i)
    	{
    		if (i < 0 || i >= size)
    			return null;
     
    		if (i ==0)
    		{
    			Node<T> thisNode = head;
    			return(head.getData());
    		}
     
    		if (i == size - 1)
    		{
    			Node<T> thisNode = tail;
    			return(tail.getData());
    		}
    		Node<T> specialNode = head;
    		for (int x = 1; x < i + 1; x++)
    		{
    			specialNode = specialNode.getNext();
    		}
    		return(specialNode.getData());
     
    		// How do I get it to return the data at i?
     
     
    	}
    	/*
    	 * getSubList(int from, int to)
    	 * parameters from, to
    	 * from - the starting index
    	 * to - the ending index
    	 * gets the data from index from to index to and copies it into another DoublyLinkedList
    	 * and returns that DoublyLinkedList
    	 */
    	public DoublyLinkedList<T> getSubList(int from, int to)
    	{
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, this.get(value));
    			count++;
    		}
    		return sub;
    	}
     
    	/*
    	 * swap(int first, int second)
    	 * parameters first, second
    	 * first - the index of the first value to be swapped
    	 * second - the index of the second value to be swapped
    	 * swaps the data at index first and index second
    	 * Not yet written
    	 */
    	public void swap(int first, int second)
    	{
    if (first < 0 || first >=Size() || second < 0 || second >=Size())
    return;
     
    // no use bothering to swap an index with itself
    if (first == second)
    return;
    		Node prevTemp, prevTemp2, nextTemp, nextTemp2;
    		prevTemp = head;
    		for (int something =0; something < from; something++)
    		{
    			prevTemp = prevTemp.getNext();
    		}
                          prevTemp = get(first).getPrevious();
                         prevTemp2 = get(second).getPrevious();
                        nextTemp = get(first).getNext();
                      nextTemp2 = get(second).getNext();
    get(first).setPrevious(prevTemp2);
    get(first).setNext(nextTemp2);
    get(second).setPrevious(prevTemp);
    get(second).setNext(nextTemp);
     
    	}
     
    	/*
    	 * getIndex(T data)
    	 * parameters data
    	 * data - the data to look for
    	 * if it finds the data, it returns the index where it finds it
    	 * otherwise it returns -1 if it cannot find it
    	 */
    	public int getIndex(T data)
    	{
    		for (int x =0; x < Size(); x++)
    		{
    			if (this.get(x).equals(data))
    				return x;
    		}
    		return -1;
    	}
    	// calls get method of first index
     
    	/*
    	 * returns the data at the beginning of the DoublyLinkedList
    	 */
    	public T front()
    	{
    		if (head == null)
    			return null;
     
    		return(get(0));
    	}
     
    	// calls get Method of last index
    	/*
    	 * returns the data at the end of the DoublyLinkedList
    	 */
    	public T back()
    	{
    		if (tail == null)
    			return null;
     
    		return(get(size - 1));
    	}
     
    	/*
    	 * removes the data at the end of the DoublyLinkedList
    	 */
    	public void removeLast()
    	{
     
    		if (head == null)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
    		remove(Size() -1 );
    	}
     
    	// gets a String for the first bracket.  Then stores each set of first and last, 2nd and 2nd to last, etc, in a String array;
    	// it then sets the third string to the concatination of all of the Strings in the array.  It thens puts these together and adds
    	// the last set of brackets and returns the final string.  
    	public String printAlternate()
    	{
    		/*
    This method returns a string that has
    the data in the following fashion (assume for this example that the list stores String objects)
    If the list is currently [amit is now here], it will return a string �[amit here is now]�
    If the list is currently [amit is now currently here], it will return a string �[amit here is currently now]�
    		 */
    		String str = "[";
    		String [] str2 = new String[size];
    		for (int v = 0; v < size; v++)
    		{
    			str2[v] = this.get(v) + " " + this.get(size - (v+1) );
    		}
    		String str3 = "";
    		for (int x = 0; x < size - 2; x++)
    		{
    			str3 = str2[x].concat(str2[x+1]);
    		}
    		String str4 = str + " " + str3 + " " + "]";
    		return(str4);
    	}
     
    	// removes all data
    	/*
    	 * removes all data in the DoublyLinkedList
    	 */
    	public void removeAll()
    	{
    		int x = 0;
    		int y = this.Size() - 1;
     
    		removeRange(x,y);
    	}
    	/*
    	 * copies the data from this DoublyLinkedList into another one and returns that
    	 * DoublyLinkedList
    	 * @see java.lang.Object#clone()
    	 */
    public DoublyLinkedList<T> clone()
    {
    	DoublyLinkedList<T> copy = new DoublyLinkedList<T>();
    	for (int x = 0; x < this.Size(); x++)
    	{
    		copy.add(x, this.get(x));
    	}
    	return copy;
    }
     
    public void addMyCollection(MyCollection<T> aCollection)
    {
    for (int i =0; i < aList.Size(); i++)
    {
    addLast(aCollection.get(i));
    }
     
    }
     
    public DoublyLinkedList<T> getSubList2(MyCollection<T> collection, int from, int to)
    	{
     
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, collection.get(value));
    			count++;
    		}
    		return sub;
    	}
     
     
     
     
     
     
    public DoublyLinkedList<T> getSubList4(Vector<T> aVector, int from, int to)
    {
    DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    int count = 0;
     
    for (int i = from; i <= to; i++)
    {
    sub.add(count, aVector.get(i));
    count++;
    }
    return sub;
    }
    public DoublyLinkedList<T> ( DoublyLinkedList<T>original)
    {
    copiedDLL = original.clone();
    this.copiedDLL = copiedDLL;
    }
     
     
     
     
    public DoublyLinkedList<T> ( MyCollection<T> collection, int from, int to)
    {
    anotherOne = getSubList2(collection, from, to);
    this.anotherOne = anotherOne;
    }
     
     
     
    public Object[] toArray()
    {
    Object[] obj = new Object[this.Size()];
    for (int i =0 ; i < this.Size(); i++)
    {
    obj[i]  = this.get(i);
    }
    return obj;
    }
     
     
    }

    Am I missing a bracket or somethign somewhere? I thought I could use an interface to refer to all classes that implement it, but when I call one of the methods, it ssys that the method for that interface is undefined. Among other things.



  2. #2
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Red face Re: Making a clock

    What are the exact error messages?

    Would you please post them?

    Goldest
    Java Is A Funny Language... Really!

    Sun: Java Coding Conventions

    Click on THANKS if you like the solution provided.
    Click on Star if you are really impressed with the solution.

  3. The Following User Says Thank You to goldest For This Useful Post:

    javapenguin (January 5th, 2011)

  4. #3
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Making a clock

    Well, apprently it doesn't like some generic parameters in constructors.

    Now it's just ticked because I'm using polymorphism to add a MyCollection to the DoublyLinkedList. I have an, undefined of course, method get(int i), but it's mad because I didn't define it, but I was told that I didn't need to.
    Also, it says that some of my assignments in other constructors are doing nothing. How can I fix it so that it makes a valid DoublyLinkedList for those?

    Hmmmmmm....can you call you constructor inside another constructor? I don't mean a call to super either.

    I mean one DoublyLinkedList constructor calling another DoublyLinkedList constructor.

    Also, on my Node class, it says that my Node<T> is hiding the T variable or something, but I need ti to be parametrized.


    package ProjectOfDoom;
     
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;
    //Paul Adcock
    // Assignment 4
    // Lasted Worked On: 12/31/2010
     
    /*
     this class is the Doubly Linked list class.  It has a Node that holds a reference to some date of type T and has a reference
     
     to the next Node and to the previous Node. It is a generic class than can hold date types.  
     */
     
     
    public class DoublyLinkedList<T> implements MyCollection<T>
    {
     
    	/* This is the generic class Node, a private innner class of DoublyLnkedList.  
    	 */
    	private class Node<T>
    	{
    		/*
    		 * variables
    		 * T data - a variable of generic type
    		 * a Node next, which refers to the Node after the current Node
    		 * a Node previous, which refers to the Node before the current Node
    		 */
    		private T data;
    		private Node<T> next;
    		private Node<T> previous;
     
    		/*
    		 * Constructor Node(T data, Node<T> next, Node<T> previous)
    		 * parameters T data
    		 * a Node next
    		 * a Node previous
    		 */
    		public Node(T data,Node<T> next, Node<T> previous)
    		{
    			this.data = data;
    			this.next = next;
    			this.previous=previous;
    		}
     
    		/*
    		 * returns the data of that Node
    		 */
    		public T getData()
    		{
    			return data;
    		}
     
    		/*
    		 * returns the Node after the current Node
    		 */
    		public Node<T> getNext()
    		{
    			return next;
    		}
     
    		/*
    		 * returns the Node before the current Node
    		 */
    		public Node<T> getPrevious()
    		{
    			return previous;
    		}
     
    		/*
    		 * sets the Node after the current Node to next
    		 */
    		public void setNext(Node<T> next)
    		{
    			this.next = next;
    		}      
     
    		/*
    		 * sets the Node before the current Node to previous
    		 */
    		public void setPrevious(Node<T> previous)
    		{
    			this.previous = previous;
    		}
     
    		/*
    		 * creates a copy of the Node and returns that copy
    		 * @see java.lang.Object#clone()
    		 */
    		public Node<T> clone()
    		{
    			Node<T> copy = new Node<T>(this.getData(), this.getNext(), this.getPrevious());
    			return copy;
    		}
    	}
     
    	/*
    	 * data for class DoublyLinkedList
    	 * Node head - beginning of DoublyLinkedList
    	 * Node tail - end of DoublyLinkedList
    	 * int side - size of DoublyLinkedList
    	 * 
    	 */
    	private Node<T> head;//head of the linked list
    	private Node<T> tail; // tail of linked list
    	private int size;
                        private DoublyLinkedList<T> subDLL;
    private DoublyLinkedList<T> anotherOne, anotherOne2;
    	private ImageIcon icon;
                        private DoublyLinkedList<T> copiedDLL;
    	private Icon icon2;
    	/*
    	 * constructor DoublyLinkedList()
    	 * no parameters
    	 */
    	public DoublyLinkedList()
    	{
    		/*
    		 * sets head and tail to null
    		 * sets size to 0
    		 */
    		head = null;
    		tail = null;
    		size = 0;
    		icon = new ImageIcon("doh3.jpg");
    	}
     
     
     
    	/*
    	 * returns a String of all the elements in the DoublyLinkedList
    	 * @see java.lang.Object#toString()
    	 */
    	public String toString()
    	{
    		String str = "[";
     
    		Node<T> curr;
     
    		for (curr=head;curr!=null;curr = curr.getNext())
    		{
    			str = str + curr.getData().toString();
    			if (curr.getNext()!=null)
    				str = str + " ";
    		}
    		str = str + "]";
    		return str;
     
     
    	}
     
    public T middle()
    {
     
    int middle = (int) (Size() -1 ) /2;
    return (get(middle));
     
    }
     
    	/*
    	 * removeRange(int from, int to)
    	 * from - the starting index to remove
    	 * to - the last index to remove
    	 * removes all values between from and to
    	 */
    	public void removeRange(int from, int to)
    	{
    		if (from < 0 || from >= Size() || to < 0 || to >=Size())
    		{
    			return;
    		}
     
    if (from >=to)
    {
    for (int j = from; j >= to; j--)
    {
    remove(j);
    }
    return;
    }
     
    		for (int i = from; i <=to; i++)
    		{
    			remove(i);
    		}
    	}
     
    	// adds the data as the first element.  If the list size is 0, makes first element tail.  If head is not null, it puts the old
    	// tail as the second element and the new element as the new head.  
    	/*
    	 * addFirst(T data)
    	 * data - the type of data
    	 * adds the data to the beginning of the DoublyLinkedList
    	 */
    	public void addFirst(T data)
    	{  
    		/*  Since this is the first Object,  previous should be null
    		 */
    		Node<T> newNode = new Node<T>(data,head,null);
    		//We know that if head is null, the list is empty
    		if (head==null)
    		{
    			//If the list is empty,  tail will be newNode
    			tail = newNode;
    		}
     
    		if(head!=null)
    			head.setPrevious(newNode);
     
    		//We want to set head to be newNode
    		// if the list was empty before, both head and tail will be set to newNode;
    		head = newNode;
    		//Increment Size
    		size++;
    	}
     
    	/*
    	 * removes the data the begining of the DoublyLinkedList
    	 */
    	public void removeFirst()
    	{
    		if (size == 0)
    		{
    			JOptionPane pane = new JOptionPane();
    			pane.setIcon(icon);
    			pane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			pane.setMessageType(JOptionPane.ERROR_MESSAGE);
     
    			return;
    		}
    		Node<T> current = head; // creates a Node called current and sets it to head.
     
    		head = head.getNext(); //move head to the next element
     
    		current.setNext(null);
    		size--;
    	}
     
    	/*
    	 * addLast(T data)
    	 * parameters data
    	 * data- the data to be added
    	 * adds data to end of DoublyLinkedList
    	 */
    	public void addLast(T data)
    	{
    		//If there are no elements, use the addFirst method
    		if (tail == null)
    		{
    			addFirst(data);
    			return;
    		}
    		/* Create the new Node from the data. Set next to null
    		 * because this will be the last element and will not
    		 * have a next. Set previous to tail because tail has
    		 * not been changed yet and is currently referencing
    		 * that element that will be directly before this element
    		 */
    		Node<T> newNode = new Node<T>(data,null,tail);
    		/* Since the tail variable still references the element
    		 * directly before the new element, we can set that node's
    		 * next to our new element.
    		 */
    		tail.setNext(newNode);
    		//Set tail to our new Node
    		tail = newNode;
    		//Increment size
    		size++;
    	}
     
    	/*
    	 * returns the size of the DoublyLinkedList
    	 */
    	public int Size()
    	{
    		return(size);
    	}
     
    	/*
    	 * add(int index, T data)
    	 * parameters index, data
    	 * index - the index to add the data
    	 * data- the data to add
    	 * adds the data at the specified index
    	 */
    	public void add(int index,T data)
    	{
    		int i;
    		if (index == 0)
    		{
    			addFirst(data);
    			return;
     
    		}
    		if (index>size)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
    		if (index < 0)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
    		if (head==null)
    		{
    			addFirst(data);
    			return;
    		}
     
    		if (index == size)
    		{
    			addLast(data);
    			return;
    		}
     
    		//step 1
    		Node<T> current;
     
    		current = head;
     
    		for (i=0;i<index-1;i++)
    		{
    			current = current.getNext();
    		}
     
    		//current now refers to object immediately before new node
     
    		//step 2
    		Node<T> newnode = new Node<T>(data,current.getNext(), current.getPrevious());
     
    		//step 3
     
    		current.setNext(newnode);
     
     
    		size++;
    	}  
     
    	/*
    	 * remove(int index)
    	 * parameters index
    	 * index- the index of the data to remove
    	 * removes the data at the specified index
    	 */
    	public void remove(int index)
    	{
    		if ((index<0) || (index>=size))
    		{
    			JOptionPane.showMessageDialog(null, "You cannot remove an out-of-bounds value!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
     
    		Node <T> next2, previous3;
    		Node<T> NodeToRemove = head; // sets Node to remove originally to head
     
     
    		for (int v = 0; v < index; v++)
    		{
    			NodeToRemove = NodeToRemove.getNext(); // traverse to Node we want to remove
    		}
     
    		previous3 = NodeToRemove.getPrevious(); // sets previous3 to value before Node to remove
    		next2 = NodeToRemove.getNext(); // sets next2 to value after Node to remove
     
    		if (previous3 == null)
    		{
    			if (next2 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				head = next2;
    			}
    		}
     
    		else
    		{
    			previous3.setNext(next2);
    		}
     
    		if (next2 == null)
    		{
    			if (previous3 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				tail = previous3;
    			}
    		}
    		else
    		{
    			next2.setPrevious(previous3);
    		}
     
     
    		size--;
    	}
     
    	/*
    	 * get(int i)
    	 * parametsrs i
    	 * i - the index
    	 * returns the data at index i
    	 */
    	public T get(int i)
    	{
    		if (i < 0 || i >= size)
    			return null;
     
    		if (i ==0)
    		{
    			Node<T> thisNode = head;
    			return(head.getData());
    		}
     
    		if (i == size - 1)
    		{
    			Node<T> thisNode = tail;
    			return(tail.getData());
    		}
    		Node<T> specialNode = head;
    		for (int x = 1; x < i + 1; x++)
    		{
    			specialNode = specialNode.getNext();
    		}
    		return(specialNode.getData());
     
    		// How do I get it to return the data at i?
     
     
    	}
     
    	public Node<T> getNodeAt(int index)
    	{
    		Node<T> temp5 = head;
    		for (int i =0; i < index; i++)
    		{
    			temp5 = temp5.getNext();
    		}
    		return temp5;
    	}
    	/*
    	 * getSubList(int from, int to)
    	 * parameters from, to
    	 * from - the starting index
    	 * to - the ending index
    	 * gets the data from index from to index to and copies it into another DoublyLinkedList
    	 * and returns that DoublyLinkedList
    	 */
    	public DoublyLinkedList<T> getSubList(int from, int to)
    	{
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, this.get(value));
    			count++;
    		}
    		return sub;
    	}
     
    	/*
    	 * swap(int first, int second)
    	 * parameters first, second
    	 * first - the index of the first value to be swapped
    	 * second - the index of the second value to be swapped
    	 * swaps the data at index first and index second
    	 * Not yet written
    	 */
    	public void swap(int first, int second)
    	{
    if (first < 0 || first >=Size() || second < 0 || second >=Size())
    return;
     
    // no use bothering to swap an index with itself
    if (first == second)
    return;
    		Node<T> prevTemp;
    		Node<T> prevTemp2;
    		Node<T> nextTemp;
    		Node<T> nextTemp2;
     
     
                          prevTemp = getNodeAt(first).getPrevious();
                         prevTemp2 = getNodeAt(second).getPrevious();
                        nextTemp = getNodeAt(first).getNext();
                      nextTemp2 = getNodeAt(second).getNext();
    getNodeAt(first).setPrevious(prevTemp2);
    getNodeAt(first).setNext(nextTemp2);
    getNodeAt(second).setPrevious(prevTemp);
    getNodeAt(second).setNext(nextTemp);
     
    	}
     
    	/*
    	 * getIndex(T data)
    	 * parameters data
    	 * data - the data to look for
    	 * if it finds the data, it returns the index where it finds it
    	 * otherwise it returns -1 if it cannot find it
    	 */
    	public int getIndex(T data)
    	{
    		for (int x =0; x < Size(); x++)
    		{
    			if (this.get(x).equals(data))
    				return x;
    		}
    		return -1;
    	}
    	// calls get method of first index
     
    	/*
    	 * returns the data at the beginning of the DoublyLinkedList
    	 */
    	public T front()
    	{
    		if (head == null)
    			return null;
     
    		return(get(0));
    	}
     
    	// calls get Method of last index
    	/*
    	 * returns the data at the end of the DoublyLinkedList
    	 */
    	public T back()
    	{
    		if (tail == null)
    			return null;
     
    		return(get(size - 1));
    	}
     
    	/*
    	 * removes the data at the end of the DoublyLinkedList
    	 */
    	public void removeLast()
    	{
     
    		if (head == null)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
    		remove(Size() -1 );
    	}
     
    	// gets a String for the first bracket.  Then stores each set of first and last, 2nd and 2nd to last, etc, in a String array;
    	// it then sets the third string to the concatination of all of the Strings in the array.  It thens puts these together and adds
    	// the last set of brackets and returns the final string.  
    	public String printAlternate()
    	{
    		/*
    This method returns a string that has
    the data in the following fashion (assume for this example that the list stores String objects)
    If the list is currently [amit is now here], it will return a string �[amit here is now]�
    If the list is currently [amit is now currently here], it will return a string �[amit here is currently now]�
    		 */
    		String str = "[";
    		String [] str2 = new String[size];
    		for (int v = 0; v < size; v++)
    		{
    			str2[v] = this.get(v) + " " + this.get(size - (v+1) );
    		}
    		String str3 = "";
    		for (int x = 0; x < size - 2; x++)
    		{
    			str3 = str2[x].concat(str2[x+1]);
    		}
    		String str4 = str + " " + str3 + " " + "]";
    		return(str4);
    	}
     
    	// removes all data
    	/*
    	 * removes all data in the DoublyLinkedList
    	 */
    	public void removeAll()
    	{
    		int x = 0;
    		int y = this.Size() - 1;
     
    		removeRange(x,y);
    	}
    	/*
    	 * copies the data from this DoublyLinkedList into another one and returns that
    	 * DoublyLinkedList
    	 * @see java.lang.Object#clone()
    	 */
    public DoublyLinkedList<T> clone()
    {
    	DoublyLinkedList<T> copy = new DoublyLinkedList<T>();
    	for (int x = 0; x < this.Size(); x++)
    	{
    		copy.add(x, this.get(x));
    	}
    	return copy;
    }
     
    public void addMyCollection(MyCollection<T> aCollection)
    {
    for (int i =0; i < aCollection.Size(); i++)
    {
    addLast(aCollection.get(i));
    }
     
    }
     
    public DoublyLinkedList<T> getSubList2(MyCollection<T> collection, int from, int to)
    	{
     
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, collection.get(value));
    			count++;
    		}
    		return sub;
    	}
     
     
     
     
     
     
    public DoublyLinkedList<T> getSubList4(Vector<T> aVector, int from, int to)
    {
    DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    int count = 0;
     
    for (int i = from; i <= to; i++)
    {
    sub.add(count, aVector.get(i));
    count++;
    }
    return sub;
    }
    public DoublyLinkedList ( DoublyLinkedList<T>original)
    {
    copiedDLL = original.clone();
    this.copiedDLL = copiedDLL;
    }
     
     
     
     
    public DoublyLinkedList ( MyCollection<T> collection, int from, int to)
    {
    anotherOne = getSubList2(collection, from, to);
    this.anotherOne = anotherOne;
    }
     
     
     
    public Object[] toArray()
    {
    Object[] obj = new Object[this.Size()];
    for (int i =0 ; i < this.Size(); i++)
    {
    obj[i]  = this.get(i);
    }
    return obj;
    }
     
     
    }
    Last edited by javapenguin; January 5th, 2011 at 10:18 PM.

  5. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Making a clock

    Can you please provide the full project for us to compile? I'd like to see these errors in my IDE
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  6. The Following User Says Thank You to JavaPF For This Useful Post:

    javapenguin (January 6th, 2011)

  7. #5
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Making a clock

    Ok. Now all the red errors are gone. Perhaps it's because I had more than one project with this class.

    However, it's telling me small yellow errors.

    package ProjectOfDoom;
     
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;
    //Paul Adcock
    // Assignment 4
    // Lasted Worked On: 12/31/2010
     
    /*
     this class is the Doubly Linked list class.  It has a Node that holds a reference to some date of type T and has a reference
     
     to the next Node and to the previous Node. It is a generic class than can hold date types.  
     */
     
     
    public class DoublyLinkedList<T> implements MyCollection<T>
    {
     
    	/* This is the generic class Node, a private innner class of DoublyLnkedList.  
    	 */
    	private class Node<T>
    	{
    		/*
    		 * variables
    		 * T data - a variable of generic type
    		 * a Node next, which refers to the Node after the current Node
    		 * a Node previous, which refers to the Node before the current Node
    		 */
    		private T data;
    		private Node<T> next;
    		private Node<T> previous;
     
    		/*
    		 * Constructor Node(T data, Node<T> next, Node<T> previous)
    		 * parameters T data
    		 * a Node next
    		 * a Node previous
    		 */
    		public Node(T data,Node<T> next, Node<T> previous)
    		{
    			this.data = data;
    			this.next = next;
    			this.previous=previous;
    		}
     
    		/*
    		 * returns the data of that Node
    		 */
    		public T getData()
    		{
    			return data;
    		}
     
    		/*
    		 * returns the Node after the current Node
    		 */
    		public Node<T> getNext()
    		{
    			return next;
    		}
     
    		/*
    		 * returns the Node before the current Node
    		 */
    		public Node<T> getPrevious()
    		{
    			return previous;
    		}
     
    		/*
    		 * sets the Node after the current Node to next
    		 */
    		public void setNext(Node<T> next)
    		{
    			this.next = next;
    		}      
     
    		/*
    		 * sets the Node before the current Node to previous
    		 */
    		public void setPrevious(Node<T> previous)
    		{
    			this.previous = previous;
    		}
     
    		/*
    		 * creates a copy of the Node and returns that copy
    		 * @see java.lang.Object#clone()
    		 */
    		public Node<T> clone()
    		{
    			Node<T> copy = new Node<T>(this.getData(), this.getNext(), this.getPrevious());
    			return copy;
    		}
    	}
     
    	/*
    	 * data for class DoublyLinkedList
    	 * Node head - beginning of DoublyLinkedList
    	 * Node tail - end of DoublyLinkedList
    	 * int side - size of DoublyLinkedList
    	 * 
    	 */
    	private Node<T> head;//head of the linked list
    	private Node<T> tail; // tail of linked list
    	private int size;
                        private DoublyLinkedList<T> subDLL;
    private DoublyLinkedList<T> anotherOne, anotherOne2;
    	private ImageIcon icon;
                        private DoublyLinkedList<T> copiedDLL;
    	private Icon icon2;
    	/*
    	 * constructor DoublyLinkedList()
    	 * no parameters
    	 */
    	public DoublyLinkedList()
    	{
    		/*
    		 * sets head and tail to null
    		 * sets size to 0
    		 */
    		head = null;
    		tail = null;
    		size = 0;
    		icon = new ImageIcon("doh3.jpg");
    	}
     
     
     
    	/*
    	 * returns a String of all the elements in the DoublyLinkedList
    	 * @see java.lang.Object#toString()
    	 */
    	public String toString()
    	{
    		String str = "[";
     
    		Node<T> curr;
     
    		for (curr=head;curr!=null;curr = curr.getNext())
    		{
    			str = str + curr.getData().toString();
    			if (curr.getNext()!=null)
    				str = str + " ";
    		}
    		str = str + "]";
    		return str;
     
     
    	}
     
    public T middle()
    {
     
    int middle = (int) (Size() -1 ) /2;
    return (get(middle));
     
    }
     
    	/*
    	 * removeRange(int from, int to)
    	 * from - the starting index to remove
    	 * to - the last index to remove
    	 * removes all values between from and to
    	 */
    	public void removeRange(int from, int to)
    	{
    		if (from < 0 || from >= Size() || to < 0 || to >=Size())
    		{
    			return;
    		}
     
    if (from >=to)
    {
    for (int j = from; j >= to; j--)
    {
    remove(j);
    }
    return;
    }
     
    		for (int i = from; i <=to; i++)
    		{
    			remove(i);
    		}
    	}
     
    	// adds the data as the first element.  If the list size is 0, makes first element tail.  If head is not null, it puts the old
    	// tail as the second element and the new element as the new head.  
    	/*
    	 * addFirst(T data)
    	 * data - the type of data
    	 * adds the data to the beginning of the DoublyLinkedList
    	 */
    	public void addFirst(T data)
    	{  
    		/*  Since this is the first Object,  previous should be null
    		 */
    		Node<T> newNode = new Node<T>(data,head,null);
    		//We know that if head is null, the list is empty
    		if (head==null)
    		{
    			//If the list is empty,  tail will be newNode
    			tail = newNode;
    		}
     
    		if(head!=null)
    			head.setPrevious(newNode);
     
    		//We want to set head to be newNode
    		// if the list was empty before, both head and tail will be set to newNode;
    		head = newNode;
    		//Increment Size
    		size++;
    	}
     
    	/*
    	 * removes the data the begining of the DoublyLinkedList
    	 */
    	public void removeFirst()
    	{
    		if (size == 0)
    		{
    			JOptionPane pane = new JOptionPane();
    			pane.setIcon(icon);
    			pane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			pane.setMessageType(JOptionPane.ERROR_MESSAGE);
     
    			return;
    		}
    		Node<T> current = head; // creates a Node called current and sets it to head.
     
    		head = head.getNext(); //move head to the next element
     
    		current.setNext(null);
    		size--;
    	}
     
    	/*
    	 * addLast(T data)
    	 * parameters data
    	 * data- the data to be added
    	 * adds data to end of DoublyLinkedList
    	 */
    	public void addLast(T data)
    	{
    		//If there are no elements, use the addFirst method
    		if (tail == null)
    		{
    			addFirst(data);
    			return;
    		}
    		/* Create the new Node from the data. Set next to null
    		 * because this will be the last element and will not
    		 * have a next. Set previous to tail because tail has
    		 * not been changed yet and is currently referencing
    		 * that element that will be directly before this element
    		 */
    		Node<T> newNode = new Node<T>(data,null,tail);
    		/* Since the tail variable still references the element
    		 * directly before the new element, we can set that node's
    		 * next to our new element.
    		 */
    		tail.setNext(newNode);
    		//Set tail to our new Node
    		tail = newNode;
    		//Increment size
    		size++;
    	}
     
    	/*
    	 * returns the size of the DoublyLinkedList
    	 */
    	public int Size()
    	{
    		return(size);
    	}
     
    	/*
    	 * add(int index, T data)
    	 * parameters index, data
    	 * index - the index to add the data
    	 * data- the data to add
    	 * adds the data at the specified index
    	 */
    	public void add(int index,T data)
    	{
    		int i;
    		if (index == 0)
    		{
    			addFirst(data);
    			return;
     
    		}
    		if (index>size)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
    		if (index < 0)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot add out of bounds!", "Invalid command", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
    		if (head==null)
    		{
    			addFirst(data);
    			return;
    		}
     
    		if (index == size)
    		{
    			addLast(data);
    			return;
    		}
     
    		//step 1
    		Node<T> current;
     
    		current = head;
     
    		for (i=0;i<index-1;i++)
    		{
    			current = current.getNext();
    		}
     
    		//current now refers to object immediately before new node
     
    		//step 2
    		Node<T> newnode = new Node<T>(data,current.getNext(), current.getPrevious());
     
    		//step 3
     
    		current.setNext(newnode);
     
     
    		size++;
    	}  
     
    	/*
    	 * remove(int index)
    	 * parameters index
    	 * index- the index of the data to remove
    	 * removes the data at the specified index
    	 */
    	public void remove(int index)
    	{
    		if ((index<0) || (index>=size))
    		{
    			JOptionPane.showMessageDialog(null, "You cannot remove an out-of-bounds value!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
     
     
     
    		Node <T> next2, previous3;
    		Node<T> NodeToRemove = head; // sets Node to remove originally to head
     
     
    		for (int v = 0; v < index; v++)
    		{
    			NodeToRemove = NodeToRemove.getNext(); // traverse to Node we want to remove
    		}
     
    		previous3 = NodeToRemove.getPrevious(); // sets previous3 to value before Node to remove
    		next2 = NodeToRemove.getNext(); // sets next2 to value after Node to remove
     
    		if (previous3 == null)
    		{
    			if (next2 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				head = next2;
    			}
    		}
     
    		else
    		{
    			previous3.setNext(next2);
    		}
     
    		if (next2 == null)
    		{
    			if (previous3 == null)
    			{
    				head = null;
    				tail = null;
    			}
     
    			else
    			{
    				tail = previous3;
    			}
    		}
    		else
    		{
    			next2.setPrevious(previous3);
    		}
     
     
    		size--;
    	}
     
    	/*
    	 * get(int i)
    	 * parametsrs i
    	 * i - the index
    	 * returns the data at index i
    	 */
    	public T get(int i)
    	{
    		if (i < 0 || i >= size)
    			return null;
     
    		if (i ==0)
    		{
    			Node<T> thisNode = head;
    			return(head.getData());
    		}
     
    		if (i == size - 1)
    		{
    			Node<T> thisNode = tail;
    			return(tail.getData());
    		}
    		Node<T> specialNode = head;
    		for (int x = 1; x < i + 1; x++)
    		{
    			specialNode = specialNode.getNext();
    		}
    		return(specialNode.getData());
     
    		// How do I get it to return the data at i?
     
     
    	}
     
    	public Node<T> getNodeAt(int index)
    	{
    		Node<T> temp5 = head;
    		for (int i =0; i < index; i++)
    		{
    			temp5 = temp5.getNext();
    		}
    		return temp5;
    	}
    	/*
    	 * getSubList(int from, int to)
    	 * parameters from, to
    	 * from - the starting index
    	 * to - the ending index
    	 * gets the data from index from to index to and copies it into another DoublyLinkedList
    	 * and returns that DoublyLinkedList
    	 */
    	public DoublyLinkedList<T> getSubList(int from, int to)
    	{
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, this.get(value));
    			count++;
    		}
    		return sub;
    	}
     
    	/*
    	 * swap(int first, int second)
    	 * parameters first, second
    	 * first - the index of the first value to be swapped
    	 * second - the index of the second value to be swapped
    	 * swaps the data at index first and index second
    	 * Not yet written
    	 */
    	public void swap(int first, int second)
    	{
    if (first < 0 || first >=Size() || second < 0 || second >=Size())
    return;
     
    // no use bothering to swap an index with itself
    if (first == second)
    return;
    		Node<T> prevTemp;
    		Node<T> prevTemp2;
    		Node<T> nextTemp;
    		Node<T> nextTemp2;
     
     
                          prevTemp = getNodeAt(first).getPrevious();
                         prevTemp2 = getNodeAt(second).getPrevious();
                        nextTemp = getNodeAt(first).getNext();
                      nextTemp2 = getNodeAt(second).getNext();
    getNodeAt(first).setPrevious(prevTemp2);
    getNodeAt(first).setNext(nextTemp2);
    getNodeAt(second).setPrevious(prevTemp);
    getNodeAt(second).setNext(nextTemp);
     
    	}
     
    	/*
    	 * getIndex(T data)
    	 * parameters data
    	 * data - the data to look for
    	 * if it finds the data, it returns the index where it finds it
    	 * otherwise it returns -1 if it cannot find it
    	 */
    	public int getIndex(T data)
    	{
    		for (int x =0; x < Size(); x++)
    		{
    			if (this.get(x).equals(data))
    				return x;
    		}
    		return -1;
    	}
    	// calls get method of first index
     
    	/*
    	 * returns the data at the beginning of the DoublyLinkedList
    	 */
    	public T front()
    	{
    		if (head == null)
    			return null;
     
    		return(get(0));
    	}
     
    	// calls get Method of last index
    	/*
    	 * returns the data at the end of the DoublyLinkedList
    	 */
    	public T back()
    	{
    		if (tail == null)
    			return null;
     
    		return(get(size - 1));
    	}
     
    	/*
    	 * removes the data at the end of the DoublyLinkedList
    	 */
    	public void removeLast()
    	{
     
    		if (head == null)
    		{
    			JOptionPane.showMessageDialog(null, "Cannot remove from an empty list!", "Invalid removal", JOptionPane.ERROR_MESSAGE);
    			return;
    		}
    		remove(Size() -1 );
    	}
     
    	// gets a String for the first bracket.  Then stores each set of first and last, 2nd and 2nd to last, etc, in a String array;
    	// it then sets the third string to the concatination of all of the Strings in the array.  It thens puts these together and adds
    	// the last set of brackets and returns the final string.  
    	public String printAlternate()
    	{
    		/*
    This method returns a string that has
    the data in the following fashion (assume for this example that the list stores String objects)
    If the list is currently [amit is now here], it will return a string �[amit here is now]�
    If the list is currently [amit is now currently here], it will return a string �[amit here is currently now]�
    		 */
    		String str = "[";
    		String [] str2 = new String[size];
    		for (int v = 0; v < size; v++)
    		{
    			str2[v] = this.get(v) + " " + this.get(size - (v+1) );
    		}
    		String str3 = "";
    		for (int x = 0; x < size - 2; x++)
    		{
    			str3 = str2[x].concat(str2[x+1]);
    		}
    		String str4 = str + " " + str3 + " " + "]";
    		return(str4);
    	}
     
    	// removes all data
    	/*
    	 * removes all data in the DoublyLinkedList
    	 */
    	public void removeAll()
    	{
    		int x = 0;
    		int y = this.Size() - 1;
     
    		removeRange(x,y);
    	}
    	/*
    	 * copies the data from this DoublyLinkedList into another one and returns that
    	 * DoublyLinkedList
    	 * @see java.lang.Object#clone()
    	 */
    public DoublyLinkedList<T> clone()
    {
    	DoublyLinkedList<T> copy = new DoublyLinkedList<T>();
    	for (int x = 0; x < this.Size(); x++)
    	{
    		copy.add(x, this.get(x));
    	}
    	return copy;
    }
     
    public void addMyCollection(MyCollection<T> aCollection)
    {
    for (int i =0; i < aCollection.Size(); i++)
    {
    addLast(aCollection.get(i));
    }
     
    }
     
    public DoublyLinkedList<T> getSubList2(MyCollection<T> collection, int from, int to)
    	{
     
    		DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    		int count = 0;
    		for (int value = from; value <=to; value++)
    		{
    			sub.add(count, collection.get(value));
    			count++;
    		}
    		return sub;
    	}
     
     
     
     
     
     
    public DoublyLinkedList<T> getSubList4(Vector<T> aVector, int from, int to)
    {
    DoublyLinkedList<T> sub = new DoublyLinkedList<T>();
    int count = 0;
     
    for (int i = from; i <= to; i++)
    {
    sub.add(count, aVector.get(i));
    count++;
    }
    return sub;
    }
    public DoublyLinkedList ( DoublyLinkedList<T>original)
    {
    copiedDLL = original.clone();
    this.copiedDLL = copiedDLL;
     
    }
     
     
     
     
    public DoublyLinkedList ( MyCollection<T> collection, int from, int to)
    {
    anotherOne = getSubList2(collection, from, to);
    this.anotherOne = anotherOne;
    }
     
     
     
    public Object[] toArray()
    {
    Object[] obj = new Object[this.Size()];
    for (int i =0 ; i < this.Size(); i++)
    {
    obj[i]  = this.get(i);
    }
    return obj;
    }
     
     
    }

    package ProjectOfDoom;
     
    public interface MyCollection<T>
    {
     
    public void add(int index, T data);
    public void remove(int index);
    public void addFirst(T data);
    public void addLast(T data);
    public void removeFirst();
    public void removeLast();
     
    public void removeRange(int from, int to);
    public void removeAll();
    public int Size();
    public T get(int value);
     
     
    }

    Also, I understand that I need a method to call, but how do I do it so that it gets to all the others first and doesn't never reach them because I set it to work till the window is not visible? Or I once did but I changed it to stop running very low on memory. That's all for the class below that is.

    ackage McWoo;
     
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.event.AdjustmentEvent;
    import java.awt.event.AdjustmentListener;
    import java.awt.print.PrinterException;
    import java.io.File;
    import java.sql.Date;
    import java.sql.Time;
    import java.util.Calendar;
    import java.util.Locale;
    import java.util.TimeZone;
     
    import javax.swing.ButtonGroup;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.JScrollBar;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Highlighter;
    import javax.swing.text.Highlighter.HighlightPainter;
    import javax.xml.stream.Location;
     
    import org.xml.sax.Locator;
     
     
     
    public class Testing extends JFrame {
    private JMenu menu,menu2,menu3, menu4;
    private JMenu file, edit, options, help, about;
    private JMenuItem save, saveAs, load, print, exit;
    private JTextArea j;
    private File savedFile;
    private JWindowAdjuster jwa;
    private JMenuBar mBar;
    private JPanel panel;
    private Testing t2;
     
    private class JWindowAdjuster extends JFrame
    {
    	private JScrollBar length, width;
    	private JPanel panel;
    	private JLabel lengthLabel, widthLabel;
    	private ButtonGroup group;
    	private JRadioButtonMenuItem fifteen, thirty, five, forty, hundred;
    	private JMenuBar aBar;
    	private JMenu adjustment;
     
     
     
    	public JWindowAdjuster() throws PrinterException, BadLocationException
    	{
    		setTitle("Adjust Size of Window");
    		Dimension d = new Dimension(200,200);
    		 setFinalSize(d);
     
    	//	final Testing wenguin = new Testing();
    		setVisible(true);
    		length = new JScrollBar(JScrollBar.HORIZONTAL, 300, 0, 30, 2300);
    		width = new JScrollBar(JScrollBar.HORIZONTAL, 300, 0, 30, 2300);
    		mBar = new JMenuBar();
    		panel = new JPanel();
    		panel.setBackground(Color.BLUE);
    	 	group = new ButtonGroup();
    		mBar.setBackground(Color.ORANGE);
    		setJMenuBar(mBar);
    		length.setUnitIncrement(1);
    		lengthLabel = new JLabel("Length:");
    		adjustment = new JMenu("Adjustment Options");
    		mBar.add(adjustment);
    		fifteen = new JRadioButtonMenuItem("By 15");
    		adjustment.add(fifteen);
    		thirty = new JRadioButtonMenuItem("By 30");
    		adjustment.add(thirty);
    		five = new JRadioButtonMenuItem("By 5");
    		adjustment.add(five);
    		group.add(fifteen);
    		group.add(thirty);
    		group.add(five);
    		panel.add(lengthLabel);
    		panel.add(length);
    		widthLabel = new JLabel("Width");
    		panel.add(widthLabel);
    		panel.add(width);
     
    		length.addAdjustmentListener(new AdjustmentListener() {
     
    			@Override
    			public void adjustmentValueChanged(AdjustmentEvent arg0) {
    				// TODO Auto-generated method stub
    				lengthLabel.setText("Length: " + arg0.getValue());
    				Testing t5 = Testing.this;
    				t5.setSize(t5.getWidth(), arg0.getValue());
     
    			}
     
    		});
     
    		width.addAdjustmentListener(new AdjustmentListener() {
     
    			@Override
    			public void adjustmentValueChanged(AdjustmentEvent arg0) {
    				// TODO Auto-generated method stub
    				widthLabel.setText("Width: " + arg0.getValue());
    				Testing t5 = Testing.this;
    				t5.setSize( arg0.getValue(), t5.getHeight());
     
    			}
     
    		});
    		setContentPane(panel);
    	}
     
    	public void setFinalSize(Dimension d)
    	{
    		this.setMaximumSize(d);
    		this.setMinimumSize(d);
     
     
    	}
    }
     
    public Testing() throws PrinterException, BadLocationException
    {
    	setTitle("Testing");
    	setTesting(this);
    jwa = new JWindowAdjuster();
     
    	panel = new JPanel();
     
     
    	mBar = new JMenuBar();
    	setJMenuBar(mBar);
    	mBar.setVisible(true);
    	menu = new JMenu("");
    	mBar.add(menu);
    	menu2 = new JMenu("");
    	mBar.add(menu2);
    menu3 = new JMenu("");
    mBar.add(menu3);
    menu4 = new JMenu("");
    mBar.add(menu4);
     
     
    	Calendar c = Calendar.getInstance();
    Locale[] loc = c.getAvailableLocales() ;
     
    System.out.println(loc[0].getDisplayName());
    System.out.println(Locale.getDefault().getDisplayName());
     
    menu4.setText("Language(Country): " + Locale.getDefault().getDisplayName());
    System.out.println("Is Visible:" + this.isVisible());
    if(panel.isVisible())
    {
     
     
     
     
     
    	int hour = c.get(Calendar.HOUR);
    	int meridan = c.get(Calendar.AM_PM);
    	int minute = c.get(Calendar.MINUTE);
    	int second = c.get(Calendar.SECOND);
    	if (meridan == Calendar.AM)
    	{
    		if (minute < 10 && second < 10)
     
    		menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
    		else if (minute < 10 && second >=10)
     
    			menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " A.M.");
    		else if (second < 10 && minute >=10)
    			menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " A.M.");
    		else
    			menu2.setText(hour + ":" +    minute+ ":"  + second + " A.M.");
    	}
     
    	else
    	{
    		if (minute < 10 && second < 10)
     
    			menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
    			else if (minute < 10 && second >=10)
     
    				menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " P.M.");
    			else if (second < 10 && minute >=10)
    				menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " P.M.");
    			else
    				menu2.setText(hour + ":" +    minute+ ":"  + second + " P.M.");
    	}
    }
    System.out.println(Calendar.SATURDAY);
     
    String str = "Time Zone is: " + c.getTimeZone().getID();
     
    menu3.setText(str);
    	c.setFirstDayOfWeek(Calendar.SUNDAY);
    	System.out.println(c.getFirstDayOfWeek());
    	int weekday = c.get(Calendar.DAY_OF_WEEK);
    	System.out.println("Weekday " +weekday);
     
    	int monthDay = c.get(Calendar.DAY_OF_MONTH);
    	int month = c.get(Calendar.MONTH);
    	int year = c.get(Calendar.YEAR);
    	System.out.println(weekday);
    	TimeZone t2 = c.getTimeZone();
    	System.out.println(t2.toString());
    	menu.setToolTipText("This is the menu when the program was opened, which usually will be the same day as today.");
    	Font aFont= menu.getFont();
     
    	Font anotherFont = aFont.deriveFont(Font.BOLD);
    	menu.setFont(anotherFont);
    	if (month == Calendar.JANUARY)
    	{
    		if (weekday ==1 )
    		{
    	     menu.setText("Sunday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2 )
    		{
    			menu.setText("Monday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 3)
    		{
    			menu.setText("Tuesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4 )
    		{
    			menu.setText("Wednesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday January " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday January " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.FEBRUARY)
    	{
    		if (weekday == 1)
    		{
    	     menu.setText("Sunday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday February " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday February " + monthDay + "," + year);
    	}
     
     
    	else if (month == Calendar.MARCH)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday March " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday March " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.APRIL)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday April " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday April " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.MAY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday May " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday May " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.JUNE)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday June " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday June " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.JULY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday July " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday July " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.AUGUST)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday August " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday August " + monthDay + "," + year);
    	}
     
    	else if (month ==Calendar.SEPTEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday September " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday September " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.OCTOBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday October " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday October " + monthDay + "," + year);
    	}
     
    	else if (month==Calendar.NOVEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday November " + monthDay + "," + year);
     
    		}
     
    		else
    			menu.setText("Saturday November " + monthDay + "," + year);
    	}
     
    	else
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday December " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday December " + monthDay + "," + year);
    	}
     
     
    	setContentPane(panel);
     
    }
     
    public void update(JMenu menu2, JMenu menu3)
    {
    	Calendar c2 = Calendar.getInstance();
    	int hour = c2.get(Calendar.HOUR);
    	int meridan = c2.get(Calendar.AM_PM);
    	int minute = c2.get(Calendar.MINUTE);
    	int second = c2.get(Calendar.SECOND);
    	if (meridan == Calendar.AM)
    	{
    		if (minute < 10 && second < 10)
     
    		menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
    		else if (minute < 10 && second >=10)
     
    			menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " A.M.");
    		else if (second < 10 && minute >=10)
    			menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " A.M.");
    		else
    			menu2.setText(hour + ":" +    minute+ ":"  + second + " A.M.");
    	}
     
    	else
    	{
    		if (minute < 10 && second < 10)
     
    			menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
    			else if (minute < 10 && second >=10)
     
    				menu2.setText(hour + ":" +  "0" +  minute+ ":" + second + " P.M.");
    			else if (second < 10 && minute >=10)
    				menu2.setText(hour + ":" +    minute+ ":" + "0" + second + " P.M.");
    			else
    				menu2.setText(hour + ":" +    minute+ ":"  + second + " P.M.");
    	}
     
    	int monthDay = c2.get(Calendar.DAY_OF_MONTH);
    	int month = c2.get(Calendar.MONTH);
    	int year = c2.get(Calendar.YEAR);
    	int weekday = c2.get(Calendar.DAY_OF_WEEK);
    // 	System.out.println(weekday);
    	TimeZone t2 = c2.getTimeZone();
    // 	System.out.println(t2.toString());
    	menu.setToolTipText("This is the menu when the program was opened, which usually will be the same day as today.");
    	Font aFont= menu.getFont();
     
    	//Font anotherFont = aFont.deriveFont(Font.BOLD);
    	//menu.setFont(anotherFont);
    	if (month == Calendar.JANUARY)
    	{
    		if (weekday ==1 )
    		{
    	     menu.setText("Sunday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2 )
    		{
    			menu.setText("Monday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 3)
    		{
    			menu.setText("Tuesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4 )
    		{
    			menu.setText("Wednesday January " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday January " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday January " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday January " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.FEBRUARY)
    	{
    		if (weekday == 1)
    		{
    	     menu.setText("Sunday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday February " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday February " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday February " + monthDay + "," + year);
    	}
     
     
    	else if (month == Calendar.MARCH)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday March " + monthDay + "," + year);
    		}
     
    		else if (weekday == 5)
    		{
    			menu.setText("Thursday March " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday March " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday March " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.APRIL)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday April " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday April " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday April " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.MAY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday May " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday May " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday May " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.JUNE)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday June " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday June " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday June " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.JULY)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday July " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday July " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday July " + monthDay + "," + year);
    	}
     
    	else if (month == Calendar.AUGUST)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday August " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday August " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday August " + monthDay + "," + year);
    	}
     
    	else if (month ==Calendar.SEPTEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday September " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday September " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday September " + monthDay + "," + year);
    	}
     
    	else if (month== Calendar.OCTOBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday October " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday October " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday October " + monthDay + "," + year);
    	}
     
    	else if (month==Calendar.NOVEMBER)
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday November " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday November " + monthDay + "," + year);
     
    		}
     
    		else
    			menu.setText("Saturday November " + monthDay + "," + year);
    	}
     
    	else
    	{
    		if (weekday ==1)
    		{
    	     menu.setText("Sunday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==2)
    		{
    			menu.setText("Monday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==3)
    		{
    			menu.setText("Tuesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==4)
    		{
    			menu.setText("Wednesday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==5)
    		{
    			menu.setText("Thursday December " + monthDay + "," + year);
    		}
     
    		else if (weekday ==6)
    		{
    			menu.setText("Friday December " + monthDay + "," + year);
    		}
     
    		else
    			menu.setText("Saturday December " + monthDay + "," + year);
    	}
    }
     
     
    public static void main(String[] args) throws PrinterException, BadLocationException
    {
    	Testing t = new Testing();
    /*	while (t.isShowing())
    	{
    		t.update(t.menu2, t.menu3);
    	}
    	*/
    	t.setVisible(true);
    	}
     
    public void setTesting(Testing t2)
    {
    	this.t2 = t2;
    }
     
    public Testing getTesting()
    {
    	return t2;
    }
     
    public int getHeight2()
    {
    	return getTesting().getHeight();
    }
     
    public int getWidth2()
    {
    	return getTesting().getWidth();
    }
     
    public JPanel getPanel()
    {
    	return panel;
    }
    }

  8. #6
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Making a clock

    Hmmmmm....should I change my constructors that take Collections or Vectors as parameters into static methods that return DoublyLinkedList type? I'm starting to think that.

    Also, can you always use

    Class.this for a class instead of instantiating it with new, or does that only work for like inner classes?

    I'm thinking only for inner classes, though Calendar has a getInstance() method that helps make a Calendar object even though Calendar cannot be instantiated with new.

Similar Threads

  1. about making .class into .jar
    By sibbe in forum Java Theory & Questions
    Replies: 7
    Last Post: November 13th, 2010, 01:50 PM
  2. Need help in developing a clock application
    By sb.shiv in forum AWT / Java Swing
    Replies: 2
    Last Post: August 24th, 2010, 03:00 AM
  3. help with clock class
    By collinsislee in forum Object Oriented Programming
    Replies: 1
    Last Post: February 24th, 2010, 02:53 PM
  4. Need help making program
    By ixjaybeexi in forum Collections and Generics
    Replies: 5
    Last Post: December 6th, 2009, 11:36 PM
  5. Digital map application with Java GUI
    By donjuan in forum AWT / Java Swing
    Replies: 3
    Last Post: May 15th, 2009, 04:32 AM