i was wondering if someone here in the forum knows a bit or knows a lot regarding coding in java, if so i would like to ask is there a chance someone can tell me good books to start learning from? note that i dont know nothing about jave except that the most common IDE used is (netbeans), i have found many tutorials on the net but i still prefeer a text book :P
Affichage des articles dont le libellé est Java. Afficher tous les articles
Affichage des articles dont le libellé est Java. Afficher tous les articles
mardi 25 mars 2014
lundi 24 mars 2014
[Q] Java 8: Upgrade or Not? topic
hey XDA Devs
so the new Java 8 is out and looks pretty nice. obviously android doesn't support the new features, bells and whistles, but can we say it is fine to upgrade to JDK 8 and not interfere at all with ADT? or should we hold off? ive seen folks on Stack Overflow say to stick to 1.6 and not use 1.7 for android application development, but those posts were dated and I have no clue as to their credibility this day in age.
so the new Java 8 is out and looks pretty nice. obviously android doesn't support the new features, bells and whistles, but can we say it is fine to upgrade to JDK 8 and not interfere at all with ADT? or should we hold off? ive seen folks on Stack Overflow say to stick to 1.6 and not use 1.7 for android application development, but those posts were dated and I have no clue as to their credibility this day in age.
dimanche 16 mars 2014
[Q] java and xml topic
something is wrong with my setup...
Eclipse Keplar
Windows 7 32bit
java 7u51
db = dbf.newDocumentBuilder(); throws ParserConfigurationError..
please help me. this file is as simple as i could make it.
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class XMLHELP {
public static void main(String[] args) {
File file = new File("foo.xml");
DocumentBuilderFactory dbf;
DocumentBuilder db = null;
dbf = DocumentBuilderFactory.newInstance();
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Document doc = db.parse(file);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Eclipse Keplar
Windows 7 32bit
java 7u51
db = dbf.newDocumentBuilder(); throws ParserConfigurationError..
please help me. this file is as simple as i could make it.
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class XMLHELP {
public static void main(String[] args) {
File file = new File("foo.xml");
DocumentBuilderFactory dbf;
DocumentBuilder db = null;
dbf = DocumentBuilderFactory.newInstance();
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Document doc = db.parse(file);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
vendredi 7 mars 2014
Java on galaxy note 8? topic
So recently ive been trying to visit Keepvid.com on my tablet, only get the following message:
" Java is not installed or has been disabled. Get Java here:*http://keepvid.com/java*and enable it in your browsers plugins if necessary."
I have adobe flash installed which I thought would cover these internet features, but apparently my understanding of java and flash are completely off.
My question is:
How can I view java content on my Galaxy Note 8.0?
I use "Internet", "Chrome", and "Firefox".
Sent from my GT-N5110 using xda app-developers app
" Java is not installed or has been disabled. Get Java here:*http://keepvid.com/java*and enable it in your browsers plugins if necessary."
I have adobe flash installed which I thought would cover these internet features, but apparently my understanding of java and flash are completely off.
My question is:
How can I view java content on my Galaxy Note 8.0?
I use "Internet", "Chrome", and "Firefox".
Sent from my GT-N5110 using xda app-developers app
mercredi 19 février 2014
Java Web Application Development topic
Cygnet has a wide experience of developing web applications in Java and J2EE frameworks such as Grails, Spring, Hibernate, Struts, etc. We also develop web components and APIs to develop web applications in Java which supportservice-oriented architecture (SOA).
Hi, I am Nitin Soni. I work as a java application developer with Cygnet Infotech, an offshore java development company. For any query or help regarding website development & java application development, mail me on (E-Mail Removed), if possible. And, I'd love to connect with you on Twitter @MkNitin
See more at: http://www.cygnet-infotech.com/java/...on-development
Hi, I am Nitin Soni. I work as a java application developer with Cygnet Infotech, an offshore java development company. For any query or help regarding website development & java application development, mail me on (E-Mail Removed), if possible. And, I'd love to connect with you on Twitter @MkNitin
See more at: http://www.cygnet-infotech.com/java/...on-development
mardi 28 janvier 2014
DIRECT CLIENT - IMMEDIATE NEEDED - JAVA UI Developer (User Interface Developer) topic
Please send resumes to : (E-Mail Removed)
Position: JAVA UI Developer (User Interface Developer)
Location: San Ramon, CA
Duration: 12+ Months
Here is the revised JD, please share more profiles at the earliest.
Mandatory Skills :
* Strong experience in Java Technologies
* Experience in working with container technologies/frameworks like Apache Karaf or OSGi containers
* Hands on experience in Spring
* Hands on JavaScript frameworks like JQuery, Underscore, etc.
* Experience working with Scrum methodology as part of an agile team
* Good communication - both oral and written
* JSON, REST experience
Desired Skills :
* Working with Play framework and Scala will be an advantage
* Knowledge of Predix (GE platform) will be an advantage
Job Responsibilities :
* Participating in Scrum process
* Create/understand design documents
* Writing software code
* Conducting developer testing using unit tests (JUnit)
* Participating in code reviews
* Demonstrating user stories to stakeholders
Best Regards
Shyam
11465 Johns Creek Pkway, Johns Creek, GA 30097
Phone # 678-824-7779
(E-Mail Removed) || http://www.svksystems.com
DIRECT CLIENT - IMMEDIATE NEEDED - JAVA UI Developer (User Interface Developer)
Position: JAVA UI Developer (User Interface Developer)
Location: San Ramon, CA
Duration: 12+ Months
Here is the revised JD, please share more profiles at the earliest.
Mandatory Skills :
* Strong experience in Java Technologies
* Experience in working with container technologies/frameworks like Apache Karaf or OSGi containers
* Hands on experience in Spring
* Hands on JavaScript frameworks like JQuery, Underscore, etc.
* Experience working with Scrum methodology as part of an agile team
* Good communication - both oral and written
* JSON, REST experience
Desired Skills :
* Working with Play framework and Scala will be an advantage
* Knowledge of Predix (GE platform) will be an advantage
Job Responsibilities :
* Participating in Scrum process
* Create/understand design documents
* Writing software code
* Conducting developer testing using unit tests (JUnit)
* Participating in code reviews
* Demonstrating user stories to stakeholders
Best Regards
Shyam
11465 Johns Creek Pkway, Johns Creek, GA 30097
Phone # 678-824-7779
(E-Mail Removed) || http://www.svksystems.com
DIRECT CLIENT - IMMEDIATE NEEDED - JAVA UI Developer (User Interface Developer)
Libellés :
client,
Develope 1,
Developer,
direct,
Immediate,
interface.,
Java,
needed,
topic,
user
DIRECT CLIENT - IMMEDIATE NEEDED - JAVA UI Developer (User Interface Developer) topic
Please send resumes to : (E-Mail Removed)
Position: JAVA UI Developer (User Interface Developer)
Location: San Ramon, CA
Duration: 12+ Months
Here is the revised JD, please share more profiles at the earliest.
Mandatory Skills :
* Strong experience in Java Technologies
* Experience in working with container technologies/frameworks like Apache Karaf or OSGi containers
* Hands on experience in Spring
* Hands on JavaScript frameworks like JQuery, Underscore, etc.
* Experience working with Scrum methodology as part of an agile team
* Good communication - both oral and written
* JSON, REST experience
Desired Skills :
* Working with Play framework and Scala will be an advantage
* Knowledge of Predix (GE platform) will be an advantage
Job Responsibilities :
* Participating in Scrum process
* Create/understand design documents
* Writing software code
* Conducting developer testing using unit tests (JUnit)
* Participating in code reviews
* Demonstrating user stories to stakeholders
Best Regards
Shyam
11465 Johns Creek Pkway, Johns Creek, GA 30097
Phone # 678-824-7779
(E-Mail Removed) || http://www.svksystems.com
Position: JAVA UI Developer (User Interface Developer)
Location: San Ramon, CA
Duration: 12+ Months
Here is the revised JD, please share more profiles at the earliest.
Mandatory Skills :
* Strong experience in Java Technologies
* Experience in working with container technologies/frameworks like Apache Karaf or OSGi containers
* Hands on experience in Spring
* Hands on JavaScript frameworks like JQuery, Underscore, etc.
* Experience working with Scrum methodology as part of an agile team
* Good communication - both oral and written
* JSON, REST experience
Desired Skills :
* Working with Play framework and Scala will be an advantage
* Knowledge of Predix (GE platform) will be an advantage
Job Responsibilities :
* Participating in Scrum process
* Create/understand design documents
* Writing software code
* Conducting developer testing using unit tests (JUnit)
* Participating in code reviews
* Demonstrating user stories to stakeholders
Best Regards
Shyam
11465 Johns Creek Pkway, Johns Creek, GA 30097
Phone # 678-824-7779
(E-Mail Removed) || http://www.svksystems.com
Libellés :
client,
Develope 1,
Developer,
direct,
Immediate,
interface.,
Java,
needed,
topic,
user
dimanche 26 janvier 2014
Java Problems (Really Need Help!) topic
I keep getting errors in java and I don't know what to do. Everything looks fine. Could someone please help? Here's the applet I'm working on and below it are the error messages.
/**
* File: PetRockApplet.java
* Author: Jacob Harris (regular bonus, trying for honors, and
1 honors bonus)
* Programming: 1st Hour
* Last Modified: January 26, 2014
* Description: This applet creates, draws, finds the area, flips, and
* changes the color of pet rocks (oval & 2 rectangles
* with names).
*/
import java.awt.*; // get the java "standard graphic" classes
import java.applet.Applet; // get the java "standard applet" classes
import java.awt.event.*; // get the java "standard event" classes
public class PetRockApplet extends Applet implements ActionListener
{
private int majorAxis; // length of oval rock
private int minorAxis; // width of oval rock
private int length1; // length of rectangular rock 1
private int width1; // width of rectangular rock 1
private int length2; // length of rectangular rock 2
private int width2; // width of rectangular rock 2
private String name1; // name of rock 1
private String name2; // name of rock 2
private String name3; // name of rock 3
private Button flipButton1; // declare flipButton1 (don't fill)
private Button flipButton2; // declare flipButton2 (don't fill)
private Button flipButton3; // declare flipButton3 (don't fill)
private Button colorButton1; // declare colorButton1 (don't fill)
private Button colorButton2; // declare colorButton2 (don't fill)
private Button colorButton3; // declare colorButton3 (don't fill)
private Color color1; // declare color 1 (red)
private Color color2; // declare color 2 (blue)
private Color color3; // declare color 3 (green)
private Color color4; // declare color 4 (yellow)
private Color color5; // declare color 5 (pink)
private Color color6; // declare color 6 (black)
/**
* The init() method initializes/starts/creates the rocks
*/
public void init()
{
// declare an empty PetRockApplet class called "myPetRock1"
PetRockApplet myPetRock1;
// make (instantiate) the new PetRock1
myPetRock1 = new petRockApplet1();
flipButton1 = new Button("Flip"); // make flipButton1
add(flipButton1); // draw flipButton1
flipButton1.addActionListener(this); // listen for mouse
colorButton1 = new Button("Change Color"); // make colorButton1
add(colorButton1); // draw colorButton1
colorButton1.addActionListener(this); // listen for mouse
// declare an empty PetRockApplet class called "myPetRock2"
PetRockApplet myPetRock2;
// make (instantiate) the new PetRock2
myPetRock2 = new petRockApplet2();
flipButton2 = new Button("Flip"); // make flipButton2
add(flipButton2); // draw flipButton2
flipButton2.addActionListener(this); // listen for mouse
colorButton2 = new Button("Change Color"); // make colorButton2
add(colorButton2); // draw colorButton2
colorButton2.addActionListener(this); // listen for mouse
// declare an empty PetRockApplet class called "myPetRock3"
PetRockApplet myPetRock3;
// make (instantiate) the new PetRock3
myPetRock3 = new petRockApplet3();
flipButton3 = new Button("Flip"); // make flipButton3
add(flipButton3); // draw flipButton3
flipButton3.addActionListener(this); // listen for mouse
colorButton3 = new Button("Change Color"); // make colorButton3
add(colorButton3); // draw colorButton3
colorButton3.addActionListener(this); // listen for mouse
paint1(); // draw rock 1
paint2(); // draw rock 2
paint3(); // draw rock 3
} // end of init() method
/**
* The petRockApplet1() method constructs pet rock 1 with a given
* major axis, minor axis, and name. It also defines colors 1 & 2.
*/
public void petRockApplet1()
{
name1 = "Jacob Harris' Pet Rock 1";
majorAxis = 30;
minorAxis = 70;
color1 = Color.red;
color2 = Color.blue;
} // end of petRockApplet1() method
/**
* The petRockApplet2() method constructs pet rock 2 with a given
* length, width, and name. It also defines colors 3 & 4.
*/
public void petRockApplet2()
{
name2 = "Jacob Harris' Pet Rock 2";
length1 = 30;
width1 = 70;
color3 = Color.green;
color4 = Color.yellow;
} // end of petRockApplet2() method
/**
* The petRockApplet3() method constructs pet rock 3 with a given
* length, width, and name. It also defines colors 5 & 6.
*/
public void petRockApplet3()
{
name3 = "Jacob Harris' Pet Rock 3";
length2 = 30;
width2 = 70;
color5 = Color.pink;
color6 = Color.black;
} // end of petRockApplet3() method
/**
* The calculateArea1() method calculates and returns the area of the
* (oval) rock.
*/
public double calculateArea1()
{
double area;
return area = (majorAxis/2) * (minorAxis/2) * 3.14;
} // end of calculateArea1() method
/**
* The calculateArea2() method calculates and returns the area of the
* (rectangular) rock.
*/
public double calculateArea2()
{
double area;
return area = length1 * width1;
} // end of calculateArea2() method
/**
* The calculateArea3() method calculates and returns the area of the
* (2nd rectangular) rock.
*/
public double calculateArea3()
{
double area;
return area = length2 * width2;
} // end of calculateArea3() method
/**
* The flip1() method switches the major axis and minor axis of rock 1
* then redraws the picture.
*/
public void flip1()
{
int temp1; // need int temp1 only in this method
temp1 = minorAxis;
minorAxis = majorAxis;
majorAxis = temp1;
} // end of flip1() method
/**
* The flip2() method switches the length and width of rock 2 then
* redraws the picture.
*/
public void flip2()
{
int temp2; // need int temp2 only in this method
temp2 = length1;
length1 = width1;
width1 = temp2;
} // end of flip2() method
/**
* The flip3() method switches the length and width of rock 3 then
* redraws the picture.
*/
public void flip3()
{
int temp3; // need int temp3 only in this method
temp3 = length2;
length2 = width2;
width2 = temp3;
} // end of flip3() method
/**
* The changeColor1() method switches the color of rock 1 then redraws
* the picture.
*/
public void changeColor1()
{
Color temp1; // need Color temp1 only in this method
temp1 = color1;
color1 = color2;
color2 = temp1;
} // end of changeColor1() method
/**
* The changeColor2() method switches the color of rock 2 then redraws
* the picture.
*/
public void changeColor2()
{
Color temp2; // need Color temp2 only in this method
temp2 = color3;
color3 = color4;
color4 = temp2;
} // end of changeColor2() method
/**
* The changeColor3() method switches the color of rock 3 then redraws
* the picture.
*/
public void changeColor3()
{
Color temp3; // need Color temp3 only in this method
temp3 = color5;
color5 = color6;
color6 = temp3;
} // end of changeColor3() method
/**
* The paint1() method draws rock 1 (oval) as well as the name of the
* rock then computes and prints the area of the rock using the
* calculateArea1() method.
*/
public void paint1(Graphics g) // create predefined graphics object
{
// draws name1 at 50 over and 70 down
g.drawString(name1,50,70);
// sets the rock's color to red
g.setColor(color1);
// draws the oval Rock
g.fillOval(100,160,minorAxis,majorAxis);
// draws the major axis
g.drawString("The major axis: "+majorAxis,50,85);
// draws the minor axis
g.drawString("The minor axis: "+minorAxis,50,100);
// draws the area
g.drawString("The area: "+calculateArea1(),50,115);
} // end of paint1() method
/**
* The paint2() method draws rock 2 (rectangle) as well as the name of
* the rock then computes and prints the area of the rock using the
* calculateArea2() method.
*/
public void paint2(Graphics g) // create predefined graphics object
{
// draws name2 at 70 over and 70 down
g.drawString(name2,70,70);
// sets the rock's color to green
g.setColor(color3);
// draws the rectangular rock
g.fillRect(120,160,length1,width1);
// draws the length
g.drawString("The length: "+length1,70,85);
// draws the width
g.drawString("The width: "+width1,70,100);
// draws the area
g.drawString("The area: "+calculateArea2(),70,115);
} // end of paint2() method
/**
* The paint3() method draws rock 3 (2nd rectangle) as well as the name
* of the rock then computes and prints the area of the rock using the
* calculateArea3() method.
*/
public void paint3(Graphics g) // create predefined graphics object
{
// draws name3 at 90 over and 70 down
g.drawString(name3,90,70);
// sets the rock's color to pink
g.setColor(color5);
// draws the rectangular rock
g.fillRect(140,160,length2,width2);
// draws the length
g.drawString("The length: "+length2,90,85);
// draws the width
g.drawString("The width: "+width2,90,100);
// draws the area
g.drawString("The area: "+calculateArea3(),90,115);
} // end of paint3() method
/**
* The actionPerformed() method is automatically called whenever a
* flip button or color button is clicked.
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == flipButton1) // see if flipButton1 clicked
{
flip1(); // flip major & minor axes
}
if (e.getSource() == colorButton1) // see if colorButton1 clicked
{
changeColor1(); // change the color
}
if (e.getSource() == flipButton2) // see if flipButton2 clicked
{
flip2(); // flip length1 and width1
}
if (e.getSource() == colorButton2) // see if colorButton2 clicked
{
changeColor2(); // change the color
}
if (e.getSource() == flipButton3) // see if flipButton3 clicked
{
flip3(); // flip length2 and width2
}
if (e.getSource() == colorButton3) // see if colorButton3 clicked
{
changeColor3(); // change the color
}
paint1(); // redraw rock 1
paint2(); // redraw rock 2
paint3(); // redraw rock 3
} // end of actionPerformed() method
} // end of petRockApplet
F:\PetRockApplet.java:50: error: cannot find symbol
myPetRock1 = new petRockApplet1();
^
symbol: class petRockApplet1
location: class PetRockApplet
F:\PetRockApplet.java:63: error: cannot find symbol
myPetRock2 = new petRockApplet2();
^
symbol: class petRockApplet2
location: class PetRockApplet
F:\PetRockApplet.java:76: error: cannot find symbol
myPetRock3 = new petRockApplet3();
^
symbol: class petRockApplet3
location: class PetRockApplet
F:\PetRockApplet.java:84: error: method paint1 in class PetRockApplet cannot be applied to given types;
paint1(); // draw rock 1
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:85: error: method paint2 in class PetRockApplet cannot be applied to given types;
paint2(); // draw rock 2
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:86: error: method paint3 in class PetRockApplet cannot be applied to given types;
paint3(); // draw rock 3
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:339: error: method paint1 in class PetRockApplet cannot be applied to given types;
paint1(); // redraw rock 1
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:340: error: method paint2 in class PetRockApplet cannot be applied to given types;
paint2(); // redraw rock 2
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:341: error: method paint3 in class PetRockApplet cannot be applied to given types;
paint3(); // redraw rock 3
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
9 errors
Tool completed with exit code 1
/**
* File: PetRockApplet.java
* Author: Jacob Harris (regular bonus, trying for honors, and
1 honors bonus)
* Programming: 1st Hour
* Last Modified: January 26, 2014
* Description: This applet creates, draws, finds the area, flips, and
* changes the color of pet rocks (oval & 2 rectangles
* with names).
*/
import java.awt.*; // get the java "standard graphic" classes
import java.applet.Applet; // get the java "standard applet" classes
import java.awt.event.*; // get the java "standard event" classes
public class PetRockApplet extends Applet implements ActionListener
{
private int majorAxis; // length of oval rock
private int minorAxis; // width of oval rock
private int length1; // length of rectangular rock 1
private int width1; // width of rectangular rock 1
private int length2; // length of rectangular rock 2
private int width2; // width of rectangular rock 2
private String name1; // name of rock 1
private String name2; // name of rock 2
private String name3; // name of rock 3
private Button flipButton1; // declare flipButton1 (don't fill)
private Button flipButton2; // declare flipButton2 (don't fill)
private Button flipButton3; // declare flipButton3 (don't fill)
private Button colorButton1; // declare colorButton1 (don't fill)
private Button colorButton2; // declare colorButton2 (don't fill)
private Button colorButton3; // declare colorButton3 (don't fill)
private Color color1; // declare color 1 (red)
private Color color2; // declare color 2 (blue)
private Color color3; // declare color 3 (green)
private Color color4; // declare color 4 (yellow)
private Color color5; // declare color 5 (pink)
private Color color6; // declare color 6 (black)
/**
* The init() method initializes/starts/creates the rocks
*/
public void init()
{
// declare an empty PetRockApplet class called "myPetRock1"
PetRockApplet myPetRock1;
// make (instantiate) the new PetRock1
myPetRock1 = new petRockApplet1();
flipButton1 = new Button("Flip"); // make flipButton1
add(flipButton1); // draw flipButton1
flipButton1.addActionListener(this); // listen for mouse
colorButton1 = new Button("Change Color"); // make colorButton1
add(colorButton1); // draw colorButton1
colorButton1.addActionListener(this); // listen for mouse
// declare an empty PetRockApplet class called "myPetRock2"
PetRockApplet myPetRock2;
// make (instantiate) the new PetRock2
myPetRock2 = new petRockApplet2();
flipButton2 = new Button("Flip"); // make flipButton2
add(flipButton2); // draw flipButton2
flipButton2.addActionListener(this); // listen for mouse
colorButton2 = new Button("Change Color"); // make colorButton2
add(colorButton2); // draw colorButton2
colorButton2.addActionListener(this); // listen for mouse
// declare an empty PetRockApplet class called "myPetRock3"
PetRockApplet myPetRock3;
// make (instantiate) the new PetRock3
myPetRock3 = new petRockApplet3();
flipButton3 = new Button("Flip"); // make flipButton3
add(flipButton3); // draw flipButton3
flipButton3.addActionListener(this); // listen for mouse
colorButton3 = new Button("Change Color"); // make colorButton3
add(colorButton3); // draw colorButton3
colorButton3.addActionListener(this); // listen for mouse
paint1(); // draw rock 1
paint2(); // draw rock 2
paint3(); // draw rock 3
} // end of init() method
/**
* The petRockApplet1() method constructs pet rock 1 with a given
* major axis, minor axis, and name. It also defines colors 1 & 2.
*/
public void petRockApplet1()
{
name1 = "Jacob Harris' Pet Rock 1";
majorAxis = 30;
minorAxis = 70;
color1 = Color.red;
color2 = Color.blue;
} // end of petRockApplet1() method
/**
* The petRockApplet2() method constructs pet rock 2 with a given
* length, width, and name. It also defines colors 3 & 4.
*/
public void petRockApplet2()
{
name2 = "Jacob Harris' Pet Rock 2";
length1 = 30;
width1 = 70;
color3 = Color.green;
color4 = Color.yellow;
} // end of petRockApplet2() method
/**
* The petRockApplet3() method constructs pet rock 3 with a given
* length, width, and name. It also defines colors 5 & 6.
*/
public void petRockApplet3()
{
name3 = "Jacob Harris' Pet Rock 3";
length2 = 30;
width2 = 70;
color5 = Color.pink;
color6 = Color.black;
} // end of petRockApplet3() method
/**
* The calculateArea1() method calculates and returns the area of the
* (oval) rock.
*/
public double calculateArea1()
{
double area;
return area = (majorAxis/2) * (minorAxis/2) * 3.14;
} // end of calculateArea1() method
/**
* The calculateArea2() method calculates and returns the area of the
* (rectangular) rock.
*/
public double calculateArea2()
{
double area;
return area = length1 * width1;
} // end of calculateArea2() method
/**
* The calculateArea3() method calculates and returns the area of the
* (2nd rectangular) rock.
*/
public double calculateArea3()
{
double area;
return area = length2 * width2;
} // end of calculateArea3() method
/**
* The flip1() method switches the major axis and minor axis of rock 1
* then redraws the picture.
*/
public void flip1()
{
int temp1; // need int temp1 only in this method
temp1 = minorAxis;
minorAxis = majorAxis;
majorAxis = temp1;
} // end of flip1() method
/**
* The flip2() method switches the length and width of rock 2 then
* redraws the picture.
*/
public void flip2()
{
int temp2; // need int temp2 only in this method
temp2 = length1;
length1 = width1;
width1 = temp2;
} // end of flip2() method
/**
* The flip3() method switches the length and width of rock 3 then
* redraws the picture.
*/
public void flip3()
{
int temp3; // need int temp3 only in this method
temp3 = length2;
length2 = width2;
width2 = temp3;
} // end of flip3() method
/**
* The changeColor1() method switches the color of rock 1 then redraws
* the picture.
*/
public void changeColor1()
{
Color temp1; // need Color temp1 only in this method
temp1 = color1;
color1 = color2;
color2 = temp1;
} // end of changeColor1() method
/**
* The changeColor2() method switches the color of rock 2 then redraws
* the picture.
*/
public void changeColor2()
{
Color temp2; // need Color temp2 only in this method
temp2 = color3;
color3 = color4;
color4 = temp2;
} // end of changeColor2() method
/**
* The changeColor3() method switches the color of rock 3 then redraws
* the picture.
*/
public void changeColor3()
{
Color temp3; // need Color temp3 only in this method
temp3 = color5;
color5 = color6;
color6 = temp3;
} // end of changeColor3() method
/**
* The paint1() method draws rock 1 (oval) as well as the name of the
* rock then computes and prints the area of the rock using the
* calculateArea1() method.
*/
public void paint1(Graphics g) // create predefined graphics object
{
// draws name1 at 50 over and 70 down
g.drawString(name1,50,70);
// sets the rock's color to red
g.setColor(color1);
// draws the oval Rock
g.fillOval(100,160,minorAxis,majorAxis);
// draws the major axis
g.drawString("The major axis: "+majorAxis,50,85);
// draws the minor axis
g.drawString("The minor axis: "+minorAxis,50,100);
// draws the area
g.drawString("The area: "+calculateArea1(),50,115);
} // end of paint1() method
/**
* The paint2() method draws rock 2 (rectangle) as well as the name of
* the rock then computes and prints the area of the rock using the
* calculateArea2() method.
*/
public void paint2(Graphics g) // create predefined graphics object
{
// draws name2 at 70 over and 70 down
g.drawString(name2,70,70);
// sets the rock's color to green
g.setColor(color3);
// draws the rectangular rock
g.fillRect(120,160,length1,width1);
// draws the length
g.drawString("The length: "+length1,70,85);
// draws the width
g.drawString("The width: "+width1,70,100);
// draws the area
g.drawString("The area: "+calculateArea2(),70,115);
} // end of paint2() method
/**
* The paint3() method draws rock 3 (2nd rectangle) as well as the name
* of the rock then computes and prints the area of the rock using the
* calculateArea3() method.
*/
public void paint3(Graphics g) // create predefined graphics object
{
// draws name3 at 90 over and 70 down
g.drawString(name3,90,70);
// sets the rock's color to pink
g.setColor(color5);
// draws the rectangular rock
g.fillRect(140,160,length2,width2);
// draws the length
g.drawString("The length: "+length2,90,85);
// draws the width
g.drawString("The width: "+width2,90,100);
// draws the area
g.drawString("The area: "+calculateArea3(),90,115);
} // end of paint3() method
/**
* The actionPerformed() method is automatically called whenever a
* flip button or color button is clicked.
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == flipButton1) // see if flipButton1 clicked
{
flip1(); // flip major & minor axes
}
if (e.getSource() == colorButton1) // see if colorButton1 clicked
{
changeColor1(); // change the color
}
if (e.getSource() == flipButton2) // see if flipButton2 clicked
{
flip2(); // flip length1 and width1
}
if (e.getSource() == colorButton2) // see if colorButton2 clicked
{
changeColor2(); // change the color
}
if (e.getSource() == flipButton3) // see if flipButton3 clicked
{
flip3(); // flip length2 and width2
}
if (e.getSource() == colorButton3) // see if colorButton3 clicked
{
changeColor3(); // change the color
}
paint1(); // redraw rock 1
paint2(); // redraw rock 2
paint3(); // redraw rock 3
} // end of actionPerformed() method
} // end of petRockApplet
F:\PetRockApplet.java:50: error: cannot find symbol
myPetRock1 = new petRockApplet1();
^
symbol: class petRockApplet1
location: class PetRockApplet
F:\PetRockApplet.java:63: error: cannot find symbol
myPetRock2 = new petRockApplet2();
^
symbol: class petRockApplet2
location: class PetRockApplet
F:\PetRockApplet.java:76: error: cannot find symbol
myPetRock3 = new petRockApplet3();
^
symbol: class petRockApplet3
location: class PetRockApplet
F:\PetRockApplet.java:84: error: method paint1 in class PetRockApplet cannot be applied to given types;
paint1(); // draw rock 1
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:85: error: method paint2 in class PetRockApplet cannot be applied to given types;
paint2(); // draw rock 2
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:86: error: method paint3 in class PetRockApplet cannot be applied to given types;
paint3(); // draw rock 3
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:339: error: method paint1 in class PetRockApplet cannot be applied to given types;
paint1(); // redraw rock 1
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:340: error: method paint2 in class PetRockApplet cannot be applied to given types;
paint2(); // redraw rock 2
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
F:\PetRockApplet.java:341: error: method paint3 in class PetRockApplet cannot be applied to given types;
paint3(); // redraw rock 3
^
required: Graphics
found: no arguments
reason: actual and formal argument lists differ in length
9 errors
Tool completed with exit code 1
Inscription à :
Articles (Atom)