I need help on the complete coding of Java mug. This is an given to me by the university, I have just started my course on java. So, could please someone help me & provide me the complete coding on java mug.

This would help me to score good points in my assignment.


Recommended Answers

All 13 Replies

to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

Nobody here will do your homework for you, or help you get good points by cheating.
Do your own homework and, if you get stuck, show us what you have done and someone will probably help.

What is java mug ?

whatever it is, he has to do it himself. We're not doing it for him.

whatever it is, he has to do it himself. We're not doing it for him.

Aren't you a bit curious? :)

I am

that's from Harry Potter (two small childrens)

Aren't you a bit curious? :)

I've too much to be curious about to wonder about getting mugged about Java.

Let me know if the below program is right or wrong..??

import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class DrawJavaMugTest {

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable(){
			public void run(){
				DrawFrame frame = new DrawFrame();

class DrawFrame extends JFrame{
	public DrawFrame(){
	    //DrawJavaMugPanel panel = new DrawJavaMugPanel();
		DrawJavaMugComponent component = new DrawJavaMugComponent();
	public static final int DEFAULT_WIDTH = 400;
	public static final int DEFAULT_HEIGHT = 400;

class DrawJavaMugComponent extends JComponent{
	public void paintComponent(Graphics g){
	   Graphics2D g2 = (Graphics2D) g;
	    g2.draw(new Line2D.Double(100, 100, 100, 300));//Vertical line 1
	    g2.draw(new Line2D.Double(276, 100, 276, 300));//Vertical line 2
	    g2.draw(new Line2D.Double(276, 300, 100, 300));//Horizontal line
	    Ellipse2D ellipse1 = new Ellipse2D.Double();//the opening of the mug
	    ellipse1.setFrame(276, 125, 40, 150);
	    Ellipse2D ellipse2 = new Ellipse2D.Double();//the handle of the mug
	    ellipse2.setFrame(99.5, 91, 177, 15);//(leftX,topY,width, height)

Let me know of this is the right coding for the program..??

import javax.swing.*;
import <strong class="highlight">java</strong>.awt.*;

public class GUITest extends JFrame{
public GUITest(){
super("A basic GUI");
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2,2));
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

public static void main(String [] args){
new GUITest();

Let me know of this is the right coding for the program..??

Just compile and run it. If it's right you'll get the correct output. If not, you;ll probably get some kind of error message that will help.

Copied directly from here.

If the OP can't even determine if the code he blindly copies meets the requirements for his assignment, he deserves to fail the course.

Let me know if the below program is right or wrong..??

And you still haven't explained what mug is. And this is not a joke, seriously. Throwing random code without explaining what you want to do, or not compiling it and see for your self, is really bad.

At least if you explained your problem we could give you hints and advices on how to proceed.

Also in one of your posts, I loved the way you copy pasted code from some other site, without having a single clue of what you posted:
import <strong class="highlight">java</strong>.awt.*;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.