Trying To Create Clickable Applet But Won't Compile
Apr 18, 2014
On my code, I am getting errors to put ; after the public void's. I'm not sure where the problem is seeing as my textbook pretty much had the same code that I just transferred the different data to....
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class MoveIt extends Applet implements ActionListener {
private Image cup;
private Panel keypad;
I've been using a Java applet for sports tables.It has been very useful for me. However, the recent developments from the people at Oracle have made this program impossible to use. The point is that I need this program and I need it fast.I've been in touch with the person who once created this applet and he has no intentions at all to upgrade it or do anything to make it function. How to make the program works with their new updates.
What I have to do: Use Applet to create two instances of the Employee class. Display the data on the Graphics object. Display in the applet the names and values of all of the instance variables in each instance of the class. Also display the value of any static variables.
What I'm doing:
import java.applet.Applet; import java.awt.*; public class EmployeeApplet extends Applet { public static int topSalary = 195000; int hoursPerWeek; public static void setTopSalary (int s) { if (s > topSalary)
[Code]...
I'm not able to display hours per week for e1 and e2.
The assignment is to: Use arrays to create an applet that lists five of your favorite songs.
The applet should scroll the list of song titles, one at a timeeach song title should start at the top of the applet and scroll to the middle then, scroll off the right hand sideeach new song title should scroll in a different colourthe applet should loop, that is, when it gets to the end of the list, start over again at the beginning of the list
I already have it looping the text with different colors. It's just they all loop at the same time. How to loop them separately. How to switch the program to where the strings will change with content and color on each loop that would work too.
Here is the code I got so far:
import java.awt.*; import java.applet.Applet; public class FavouriteSongs extends Applet implements Runnable { String[] Songs = {"Travelling Man-Chameleon Circuit", "Sing-Ed Sheeran", "It's Time-Imagine Dragons", "I See Fire-Ed Sheeran", "Colder Weather- Zac Brown Band"}; int yPos = 0, xPos = 50; Thread runner;
I created an ImageView with an image with transparent portions. I also did some scaling and moving, which I though might cause this effect, but that is not the case. When I click on the transparent portion of the image the onMouseClick event is not fired. Other mouse events (mouse enter, mouse move, mouse exit, ...) get fired. Only when I click on the non transparent part the click event is fired.
Image img = new Image(getClass().getResourceAsStream("barrel_icon.png")); ImageView view = new ImageView(img); view.setScaleX(0.5); view.setScaleY(0.5); view.setOnMouseClicked(new EventHandler<MouseEvent>() {
[Code] ....
The area between the barrel and the shadow belongs clearly to the image, however is transparent. I am wondering if there is a reason for this behaviour and what is the best way to work around this issue, as my image has large transparent portions and the non transparent parts are hard to click on. By the way this is all based on JavaFX 2.2.
import javax.swing.*; import java.awt.event.*; public class BookStore extends JFrame{ private JPanel panel; private JLabel question; //This will be where the question is. private JTextField NumofBooks; //this is where the user will enter the number of books private JButton OKButton,ClearButton,ExitButton; //Will give the user the points, cancel the points, and exit private final int WINDOW_WIDTH = 310; //Need to make it visible private final int WINDOW_HEIGHT = 100;
i would like to ask what does exactly do the command mvn compile. What is happening with the code, when i write this command? And why is it necessary for running the code?
I created Myproject folder. Inside I have 3 folders:
/lib /src /bin
Inside src there is a .java file:
public class hello_world{ public static void main(String[] args){ System.out.println("Hi, from hello_world"); seba.st.hello_world_package test1 = new seba.st.hello_world_package(); test1.packFunc(); } }
inside lib is a packEx.jar file which I created from this .java file:
package seba.st; public class hello_world_package{ public void packFunc(){ System.out.println("hi from pack_func!"); } }
I am trying to run this program from terminal with this command
javac -d bin -sourcepath src -cp lib/packEx.jar src/hello_world.java
and I get this error:
src/hello_world.java:11: error: cannot find symbol test1.packFunc(); ^ symbol: method packFunc() location: variable test1 of type hello_world_package 1 error
What am I doing wrong ? How can I compile and run this program from terminal?
both will in theory never go in more interestingly this will compile
for(;false == false;){}
To me it seems like this is a parsing issue that could have been solved by the people who originally wrote the parser but they made a decision that there must be a relational operator in the condition declaration.
import java.util.Calendar; import java.util.GregorianCalendar; public class CalendarCalc { public CalendarCalc (){} private static void printCalendarMonthYear (int month, int year)
[Code] .....
IDE is telling me this:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method printCalendarMonthYear(int, int) is undefined for the type CalendarDisplay
at CalendarDisplay.main(CalendarDisplay.java:46)
Btw, I have a main class. This is just the class responsible for doing calculations.
i am trying to work through the Murach's Java Servlets and JSP book. I am stuck however. I keep getting a HTTP Status 500 - Unable to compile class for JSP.
I am using Eclipse Kepler, JDK 1.7, and Tomcat v7.0 server.
Its a fairly simple program that takes in user information, first name, last name, and an email and processes the information, saving the data to a text file.
------------------------------------------------ I have two Java classes: User and UserIO -------------------------------------------------
//User.java package business; public class User { private String firstName; private String lastName; private String emailAddress; public User(String firstName, String lastName, String emailAddress){
I am making a simple mod/hack for a game programmed in Java. I located the .class file I needed and deobfuscated it and then decompiled it. After that I went in and made a very simple adjustment that I wanted to make. Unfortunately I can across a problem when trying to compile the file! The file won't compile because there are errors. The reason there are errors is because this is just one file out of an entire game. I know this my seem weird, but is there some way I can compile the file with the errors.
QUESTION: A class called MyCircle, which models a circle with a center (x, y) and a radius, is designed as shown in the class diagram. The MyCircle class uses an instance of MyPoint class (created in the previous exercise) as its center. The class contains: -Two private instance variables: center (an instance of MyPoint) and radius (int). -A constructor that constructs a circle with the given center's (x, y) and radius. -An overloaded constructor that constructs a MyCircle given a MyPoint instance as center, and radius. -Various getters and setters. -A toString() method that returns a string description of this instance in the format "Circle @ (x, y) radius=r". -A getArea() method that returns the area of the circle in double.
Write the MyCircle class. Also write a test program (called TestMyCircle) to test all the methods defined in the class.
My code:
public class MyCircle{ private MyPoint center; private int radius=1;
public MyCircle(int x, int y, int radius){ this.x = x; this.y = y; this.radius = radius;
"Because X is a compile time constant, the compiler will Y"... But what exactly is a compile time constant? And how can we determine whether something is treated as such?Obviously, a compile time constant is a constant value that is known at compile time... ... Literals are, by definition, compile time constants -- as they are constants, known at compile time.
But the definition of a compile time constant is a bit more complex. To start, let's examine section 15.28 of the Java language specification.A compile-time constant expression is an expression denoting a value of primitive type or a String that is composed using only the following:
Literals of primitive type and literals of type String Casts to primitive types and casts to type StringThe unary operators +, -, ~, and ! (but not ++ or --)The multiplicative operators *, /, and %The additive operators + and - The shift operators <<, >>, and >>>The relational operators <, <=, >, and >= (but not instanceof)The equality operators == and !=The bitwise and logical operators &, ^, and |The conditional-and operator && and the conditional-or operator ||The ternary conditional operator ? : Simple names that refer to final variables whose initializers are constant expressions Qualified names of the form TypeName . Identifier that refer to final variables whose initializers are constant expressions
This is the full definition of a compile time constant. And as you can see, it contains more than just literals. In fact, literals are merely the first bullet point on the list. Also, note that a compile time constant can apply to any literal that is of primative or String type.The next few bullet points are the operations that can be applied to a constant at compile time. This list is actually pretty long, as it is possible to apply most of the operations at compile time. It may actually be easier to remember what can't be apply at compile time -- pre and post increment and decrement, instanceof operator, or any method calls, are not on the list.
The last few bullets are the most interesting. It is possible to use a variable in the expression -- provided that the variable is a compile time constant variable. So... what is a constant variable? Going back to the JLS (section 4.12.4 to be exact)..4.12.4 final Variables.A variable can be declared final. A final variable may only be assigned to once. It is a compile time error if a final variable is assigned to unless it is definitely unassigned (§16) immediately prior to the assignment.
We call a variable, of primitive type or type String, that is final and initialized with a compile-time constant expression (§15.28) a constant variable. Whether a variable is a constant variable or not may have implications with respect to class initialization (§12.4.1), binary compatibility (§13.1, §13.4.9) and definite assignment (§16).The last part of the definition is the relevant part (I still find it amazing that this is that well hidden in the specification). To be a variable that is a compile time constant, the variable needs to be...declared as finalhave a primative or String typeinitialized (on the same line as the declaration)assigned to a compile time constant expression.
I'v tried everything, i'v tried to create new path in enviornment variables i tried adding this path -->(C:Program FilesJavajdk1.8.0_20bin) to the end of the default path doesnt work i uninstalled and reinstalled and did the same thing over and it didnt work am i editing the files wrong ? what i do is write the hello world program in eclipse to make sure there arent any errors then copy and paste in note pad++ save it as a .java file and it doesnt work i tried save it in regular notepad as .java laso and it doesnt work iv done every thing i could possibly find on youtube is this stuff outdated ? is there a new way? this one one of the errors ill get
C:javat>javac helloworld.java helloworld.java:1: error: '{' exp public class helloworld.java { ^
And this is the code for that file im trying to compile
public class helloworld.java { public static void main (String args[]){ System.out.println("hello world"); } }
I made the XML file (web.xml) in C:Program FilesApache-Tomcat-7apache-tomcat-7.0.53webappsDEMOWEB-INF folder. In command prompt I went to the classes folder
I am totally new to programming in every way, shape or form, and I'm working my way through the Head First Java book (2nd ed). I have just finished copying the code for the initial BeatBox app, the one starting on page 420. When I try to compile it, I get these errors:
BeatBox.java:36: cannot find symbol symbol : constructor Box(int) location: class Box Box buttonBox = new Box(BoxLayout.Y_AXIS); ^ BeatBox.java:40: cannot find symbol symbol : method add(javax.swing.JButton) location: class Box buttonBox.add(start);
[code]....
I doubt that this is relevant, but I'm running Mac OS X, coding in TextWrangler and compiling with Terminal. Java version is 1.6.0_24.
programming altogether and after almost reaching half way in the 'Head first java' book I decided to try and apply some of what I've learnt so far and write my first 'Object orientated' program. As this is pretty much the first program I've ever written, I decided to write a program to ask for two integers and add them both together and then present them to the user (the goal eventually being a basic fully working command line calculator with +,-,* and /. I'm expecting many compile errors but not the following errors below.
I have three .java files contained within a folder and after trying to figure out how to compile all three files (as they use one another) all at once, I came across this ---> javac *.java
so I typed this in the command line whilst in the directory containing the three files assuming *.java is the best approach and then I receive the following errors:
inputOutput.java:10: error: cannot find symb c.addition() = intIn.nextInteger(); ^ symbol: variable c location: class inputOutput
I'm trying to use the javac -sourcepath option to compile superclasses without explicitly naming them. I've been looking at examples, other posts, and trying variations for a while without success.
I have:
package ActorBase0.classes; public class Bridge extends Place { ......
Place is also in package ActorBase0.classes and the source files are in the same directory .... ActorBase0sources
I'm writing basically my first program for school. I've written small ones, following instructions, but this is the most vague. I'm having issues. I can't figure out what the error means. I'm not done with the code, but I think the ArrayList is throwing me off. I'm trying to gather user input and sum the total. Here's the code:
package graduationplanner; import java.util.ArrayList; import java.util.Scanner; import java.lang.Double; public class GraduationPlanner { public static void main(String[] args) {