Hello, I am a beginner of java.
I made a class to print out the calendar with jpanel. And I don't know how to create a jbutton to save the calendar as a jpg for the users.
Does anyone can tell me how to do that? Thanks in advance!!!
Printable View
Hello, I am a beginner of java.
I made a class to print out the calendar with jpanel. And I don't know how to create a jbutton to save the calendar as a jpg for the users.
Does anyone can tell me how to do that? Thanks in advance!!!
Button is easy.
You will need to add an action listener to the button to tell java what to do when the user clicks it. Here is a tutorial for buttons: tutorialCode:JButton button = new JButton("Click Me!");
Now as far as saving a jpeg... How are you displaying a calendar? Are you drawing on a JPanel with Java2D? You can draw to a BufferedImage and use ImageIO to write that in your desired format.
Work on one step at a time. Because when comes to a button (actually any control) there are a lot to learn, specially with actions listeners. So you better do some considerable amount of work on it.
Thank you for the help, I now have a clear direction to do that:(happy):
You are welcome. Give a try and let us know.