Skip to main content

Posts

Extending an abstract class [closed]

The following code for RectangleNode extends an abstract class called GraphElement, this is needed for my program to draw rectangles where necessary. My question is regarding the abstract method in GraphElement. Rectangle Node: import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.awt.Color; public class RectangleNode extends GraphElement { private double width = 20; private double length = 40; private Rectangle2D.Double rect; public RectangleNode(int x, int y) { super(x,y); rect = new Rectangle2D.Double(getXPos(), getYPos(), length, width); } public RectangleNode() { super(); rect = null; } public boolean isSelected(double x, double y) { return super(x,y); } public void draw(Graphics2D g2) { if (rect != null) g2.draw(rect); } } Graph Element: import java.awt.Graphics2D; abstract public class GraphElement { private double xPos; private double yPos; protected String label; public GraphElement() {

Multithreading in Java Help Needed

Before I go any further, this IS apart of my homework.The part that I am having trouble with however, is not the main point of the assignment. For the assignment we are just storing numbers in an array, and am adding up the elements of the array via multithreading. The user enters how many threads that they would like to run, and what the upper bound should be. For example: Upper Bound: 12 Threads: 2 The application should add up elements 1-6, then 7-12. In this case the lower bound starts out at 1 and the upper bound starts out at 6. Then the second time the loop should itterate the upper bound should be 7 and the upper bound should be 12. I am having trouble trying to devide the upper bound by the number of threads to create the increments in wich the lower and upper bounds are based off of. It is fairly simple if the number of threads devides evenly into the starting upper bound. But when It doesn't is when I am having the problem. Thank You!

What can"t I do with a Java Applet?

Consider a Java applet running in browser such as Google Chrome. What am I unable to do in the applet? Can I use Robots? Can I use ff-mpeg or Xuggle? Can I run any of the Java EE API's? There is something in Java that cannot be done inside an HTML applet - but what is it?

Generics in Java, Standard Values

Ok, so I was reading the Java online tutorial for generics and I found this: E - Element (used extensively by the Java Collections Framework) K - Key N - Number T - Type V - Value S,U,V etc. - 2nd, 3rd, 4th types I have seen a lot of methods in Java use the "E" notation but I was looking for a method that uses the "K", key notation. Anyone can help please?

One Tomcat instance for two domains and two webapps

How can I configure Tomcat (in standalone mode, that is without Apache [*]) so that I can deploy it on one server and have it serve two different webapps, depending on the domain name requested? I found a blog entry describing such a setup, but it's for Tomcat 5.5: <Engine defaultHost="domain1.com" name="Catalina"> <Host name="domain1.com" appBase="/home/user1/domain1"> <Alias>www.domain1.com</Alias> <Context path="" docBase="."/> </Host> <Host name="domain2.com" appBase="/home/user1/domain2"> <Alias>www.domain2.com</Alias> <Context path="" docBase="."/> </Host> http://iam-rakesh.blogspot.com/2009/10/hosting-multiple-domains-in-tomcat.html Also, as of now I've got one webapp, ROOT.war, inside .../tomcat/webapps/ How would that work once I'd have two "roots&quo