Results 1 to 5 of 5
Thread: Calender
- 10-20-2010, 04:49 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 67
- Rep Power
- 0
Calender
hello, I am following this tutorial on how to make a calander on a single month in java.
I can't get anything to appear in the grey box when I run it.
Can you tell me where I am going wrong?
thanks
here is my code:
Java Code:import java.awt.*; import javax.swing.*; class cal extends JFrame { JPanel months_1; JPanel title; Container everything; public String[] days; public cal() { title = new JPanel(); days = new String[] { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" }; title.add(new JLabel("month of hahaha")); everything = getContentPane(); everything.setLayout(new FlowLayout()); months_1 = new JPanel(); months_1.setLayout(new GridLayout(7, 111)); for (int i = 0; i < 7; i++) { months_1.add(new JLabel(days[i])); } for (int i = 0; i < 30; i++) { months_1.add(new JLabel(Integer.toString(i))); } everything.add(title); everything.add(months_1); setContentPane(everything); } }
- 10-20-2010, 05:00 PM #2
You'll probably want to provide an SSCCE and use standard naming conventions (for example, classes start with an upper-case letter, variables and methods with a lower-case letter).
- 10-20-2010, 05:58 PM #3
Member
- Join Date
- Sep 2010
- Location
- Oregon, usa
- Posts
- 69
- Rep Power
- 0
Unless you have another file, you are missing your "main" code :
public static void main(String[] args) { ...... }
otherwise, set your cal() object that you create in your main to visible.
Checkout the JComponent document:
JComponent (Java Platform SE 6))
Your code worked for me... there are just a couple of layout issues when I ran it. :)
- 10-20-2010, 06:09 PM #4
He said he's getting a gray box, so I doubt it's something as simple as a missing setVisible(). He might be setting the wrong JFrame to visible, but an SSCCE would clear it all up.
- 10-20-2010, 07:36 PM #5
Member
- Join Date
- Aug 2010
- Posts
- 67
- Rep Power
- 0
Similar Threads
-
Can't Get Gregorian Calender to Work
By bengregg in forum Java AppletsReplies: 1Last Post: 10-20-2010, 08:57 AM -
Small calender program
By Moustafa taha in forum New To JavaReplies: 1Last Post: 10-19-2010, 07:52 PM -
Calender Program Help Needed!!
By DavidEvans in forum New To JavaReplies: 1Last Post: 03-17-2010, 06:37 PM -
Calender
By tiger100plus in forum New To JavaReplies: 1Last Post: 12-26-2008, 07:20 PM -
date and calender not getting the right results
By valoyivd in forum New To JavaReplies: 4Last Post: 04-14-2008, 11:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks