answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Why does the parameter of the paintcomponent method have type graphics and not graphics2d?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is constructor overloading same as method overloading.yes or no. explain?

yes,because in constructor overloading constructor have same and different parameter list. In method overloading method have same name and different parameter list.


How can you display photos and images in Java Swings?

Java Swings has a lot of nice features and one of them is the ability to display images on its components. You can select any image that is available in the local system or somewhere on the internet and display it on Graphics objects. As of Java SE 1.4, reading an image is very simple. If the image is stored in a local file: String filename = "..."; Image image = ImageIO.read(new File(filename)); Otherwise, you can supply a URL: String urlname = "..."; Image image = ImageIO.read(new URL(urlname)); The read method throws an IOException if the image is not available. Now the variable image contains a reference to an object that encapsulates the image data. You can display the image with the drawImage method of the Graphics class. public void paintComponent(Graphics g) { . . . g.drawImage(image, x, y, null); } Sometimes, you may want to tile an image across a components canvas if it is much smaller than the component size. We can do the tiling in the paintComponent method. We first draw one copy of the image in the top-left corner and then use the copyArea call to copy it into the entire window using the code below: for (int i = 0; i * imageWidth <= getWidth(); i++) for (int j = 0; j * imageHeight <= getHeight(); j++) if (i + j > 0) g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);


What do parameters and return values have to do with methods?

Parameters and return values are a major part of methods. When defining a method, you must include information about the data types of the return value and the parameters. An example of a method definition is this: public int getSumOfNumbers( int number1, int number2, int number3 ) { return ( number1 + number2 + number3 ); } The word "int" right after the word "public" is the return type. It describes what data type will be returned by the method. In this case, it was int, or integer. The sequence of words in between the parantheses, "int number1, int number2, int number3", is the parameter list. Each of the phrases separated by a comma in the parameter list is a parameter. The first word - in this case "int" - is the data type of the parameter. It describes what type of variable the parameter will be. The second word - "number1", "number2", or "number3" - is the name of the parameter. Every parameter must have a data type and a name, and every method must have a return type: even a method that returns nothing. For example: public void evaluateNumber(int number) { if ( number > 0 ) { System.out.println( number + " is positive." ); } else if ( number < 0 ) { System.out.println( number + " is negative." ); } else { System.out.println( number + " is zero." ); } } When a method does not return data, its return type must be defined as void, as it is above.


What is an actual parameter?

A formal perimeter refers to an identifier that is used in a method to stand for the value that is passed into the method by a caller. An actual perimeter on the other hand refers to the actual value that is passed into the method by a caller.


What is direct FM generation?

direct fm generation is a method of generation of fm signal directly with the help of parameter variation method. in this method we use some of the devices which converts the variation in voltage to variation in frequency such as varactor diode.

Related questions

JScrollPane is to paintComponen as JLabel is to what?

Well since both JScrollPane and JLabel are direct subclasses of JComponent, they both have the paintComponent method. JScrollPane is to paintComponent as JLabel is to paintComponent.


Is constructor overloading same as method overloading.yes or no. explain?

yes,because in constructor overloading constructor have same and different parameter list. In method overloading method have same name and different parameter list.


How do you specify an optional parameter in a method?

You need to use the reserved word params.


What is the use of the parameter in java?

A parameter is a variable that is passed to a method. It is not specific to Java, and is used in almost all programming languages. The parameter is used by the method in whatever way that it wants. Example: public void add(int x, int y) { return x + y; } In this case, the parameters are two integers, x and y. They are passed to the method 'add' which returns the sum of the parameters.


What boot parameter would you use to begin an FTP installation?

You would want to use Askmethod or method.


What is the difference between ref and out parameters?

Output parameters are similar to reference parameters, except that they transfer data out of the method rather than into it. Reference parameter copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the argument.


How do you display images in java frame?

Java Swings has a lot of nice features and one of them is the ability to display images on its components. You can select any image that is available in the local system or somewhere on the internet and display it on Graphics objects. As of Java SE 1.4, reading an image is very simple. If the image is stored in a local file: String filename = "..."; Image image = ImageIO.read(new File(filename)); Otherwise, you can supply a URL: String urlname = "..."; Image image = ImageIO.read(new URL(urlname)); The read method throws an IOException if the image is not available. Now the variable image contains a reference to an object that encapsulates the image data. You can display the image with the drawImage method of the Graphics class. public void paintComponent(Graphics g) { . . . g.drawImage(image, x, y, null); } Sometimes, you may want to tile an image across a components canvas if it is much smaller than the component size. We can do the tiling in the paintComponent method. We first draw one copy of the image in the top-left corner and then use the copyArea call to copy it into the entire window using the code below: for (int i = 0; i * imageWidth <= getWidth(); i++) for (int j = 0; j * imageHeight <= getHeight(); j++) if (i + j > 0) g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);


How do you display images on the screen using java?

Java Swings has a lot of nice features and one of them is the ability to display images on its components. You can select any image that is available in the local system or somewhere on the internet and display it on Graphics objects. As of Java SE 1.4, reading an image is very simple. If the image is stored in a local file: String filename = "..."; Image image = ImageIO.read(new File(filename)); Otherwise, you can supply a URL: String urlname = "..."; Image image = ImageIO.read(new URL(urlname)); The read method throws an IOException if the image is not available. Now the variable image contains a reference to an object that encapsulates the image data. You can display the image with the drawImage method of the Graphics class. public void paintComponent(Graphics g) { . . . g.drawImage(image, x, y, null); } Sometimes, you may want to tile an image across a components canvas if it is much smaller than the component size. We can do the tiling in the paintComponent method. We first draw one copy of the image in the top-left corner and then use the copyArea call to copy it into the entire window using the code below: for (int i = 0; i * imageWidth <= getWidth(); i++) for (int j = 0; j * imageHeight <= getHeight(); j++) if (i + j > 0) g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);


What is an area of document window that displays the photo or image?

Java Swings has a lot of nice features and one of them is the ability to display images on its components. You can select any image that is available in the local system or somewhere on the internet and display it on Graphics objects. As of Java SE 1.4, reading an image is very simple. If the image is stored in a local file: String filename = "..."; Image image = ImageIO.read(new File(filename)); Otherwise, you can supply a URL: String urlname = "..."; Image image = ImageIO.read(new URL(urlname)); The read method throws an IOException if the image is not available. Now the variable image contains a reference to an object that encapsulates the image data. You can display the image with the drawImage method of the Graphics class. public void paintComponent(Graphics g) { . . . g.drawImage(image, x, y, null); } Sometimes, you may want to tile an image across a components canvas if it is much smaller than the component size. We can do the tiling in the paintComponent method. We first draw one copy of the image in the top-left corner and then use the copyArea call to copy it into the entire window using the code below: for (int i = 0; i * imageWidth <= getWidth(); i++) for (int j = 0; j * imageHeight <= getHeight(); j++) if (i + j > 0) g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);


How can you display photos and images in Java Swings?

Java Swings has a lot of nice features and one of them is the ability to display images on its components. You can select any image that is available in the local system or somewhere on the internet and display it on Graphics objects. As of Java SE 1.4, reading an image is very simple. If the image is stored in a local file: String filename = "..."; Image image = ImageIO.read(new File(filename)); Otherwise, you can supply a URL: String urlname = "..."; Image image = ImageIO.read(new URL(urlname)); The read method throws an IOException if the image is not available. Now the variable image contains a reference to an object that encapsulates the image data. You can display the image with the drawImage method of the Graphics class. public void paintComponent(Graphics g) { . . . g.drawImage(image, x, y, null); } Sometimes, you may want to tile an image across a components canvas if it is much smaller than the component size. We can do the tiling in the paintComponent method. We first draw one copy of the image in the top-left corner and then use the copyArea call to copy it into the entire window using the code below: for (int i = 0; i * imageWidth <= getWidth(); i++) for (int j = 0; j * imageHeight <= getHeight(); j++) if (i + j > 0) g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);


What do parameters and return values have to do with methods?

Parameters and return values are a major part of methods. When defining a method, you must include information about the data types of the return value and the parameters. An example of a method definition is this: public int getSumOfNumbers( int number1, int number2, int number3 ) { return ( number1 + number2 + number3 ); } The word "int" right after the word "public" is the return type. It describes what data type will be returned by the method. In this case, it was int, or integer. The sequence of words in between the parantheses, "int number1, int number2, int number3", is the parameter list. Each of the phrases separated by a comma in the parameter list is a parameter. The first word - in this case "int" - is the data type of the parameter. It describes what type of variable the parameter will be. The second word - "number1", "number2", or "number3" - is the name of the parameter. Every parameter must have a data type and a name, and every method must have a return type: even a method that returns nothing. For example: public void evaluateNumber(int number) { if ( number > 0 ) { System.out.println( number + " is positive." ); } else if ( number < 0 ) { System.out.println( number + " is negative." ); } else { System.out.println( number + " is zero." ); } } When a method does not return data, its return type must be defined as void, as it is above.


What exactly is println?

It is a method in System.out that prints the parameter to the screen. i.e. System.out.println("Hello World"); // prints Hello World.