I am thinking of creating a quiz application and facing one problem.
On first question I don`t have to show previous button and on last question I don`t have to show next button.And for in between question I have to show both the buttons.
.
How can I do that in a JSP page.
In my if statement on line 46 & 47 im trying to add the buttons to the screen if the player has lost and the "game over" screen have popped up. But the buttons aren't showing... what am i doing wrong?
This is right from a book I'm reading but it doesn't work. The problem is to write an application that lets you determine the integer value returned by the InputEvent method getModifiers() when you click your left, right, or middle mouse button on a JFrame.
This is the code copied directly from the book. What is missing:
import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JFrame; public class JLeftOrRight {
I'm creating a game called Mouse Trap and I'm having an issue with a graphic drawn using AWT. Basically, when the mouse collides with the cheese, I want the cheese to disappear, or call (cheese[i].hide()). However, the cheese does not appear. hide() works for all other objects that inherit from PFigure, but the cheese will not. It's created a major issue in my game, and basically the only task left to accomplish.I believe my problem lies within Cheese.java, method draw(). For example, if I replace it with an example drawing, this problem goes away!:
public void draw() { Graphics g = panel.getGraphics(); g.setColor(Color.blue); g.drawOval(x + width / 4 , y + 1, width / 2, height / 2);
[Code] ....
I have three classes below that most likely involve the problem, feel free to ask if you need the others.PFigure.java (This class cannot be changed as a requirement to my project)
import java.awt.*; public abstract class PFigure implements Comparable { protected int x, y; // Current position of the figure protected int width, height; // Drawn (displayed) this size protected int priority; // Can use to determine "winner" protected Panel panel; // Panel the figure lives on
Recently I have been thinking of using additional interfaces in one of my libraries to hide certain "unsafe" methods of my classes from the user. I would like to get the opinion of other, more advanced java programmers on this issue. What I do is something like the following (heavily simplified):
public interface ReadOnly { public int getValue(); } public interface ReadWrite extends ReadOnly { public void setValue(int value);
[Code] ....
The user would have access to the ExternalInterface. The ExternalInterface is controlling the values of the InternalComponent. The user can get the InternalComponent, but typecasted to a ReadOnly which does not expose the setters.
Now the thing is the user can still access the setValue method by typecasting the ReadOnly to an InternalComponent or to a ReadWrite, and that is not bad. If the user knows exactly what he/she is doing this will give him/her more flexibility and more power. But this way it *should* become obvious that this is not the intended use and perhaps the extra work of typecasting will discourage the user from doing this.
I have my code in 3 different files using encapsulation (Data hiding) and i have 1 problem at the very end of my code in my if and else statement (very bottom) when trying to call the classes from the other 2 documents. I will put the code in 1st document to 3rd document.
// FIRST DOCUMENT public class CollegeCourse { //class name //variables String deptName; int courseNum; int credits = 3; double fee;
[Code] ....
UPDATE: error message is
UseCourse.java:24: error: cannot find symbol LabCourse lc = new LabCourse(department, course, Credits); ^ symbol: variable department location: class UseCourse UseCourse.java:24: error: cannot find symbol LabCourse lc = new LabCourse(department, course, Credits);
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class C1 extends JFrame { public C1() { JMenuBar b = new JMenuBar(); b.setBackground(Color.green); setJMenuBar(b); setVisible(true); } public static void main(String[] args) { C1 c = new C1(); } }
I'm trying to show mysql data in JSF using this example [URL] .... . I figured out what <h:dataTable value="#{userBean.getUserList()}" var="u" border="1"> must be <h:dataTable value="#{userBean.userList}" var="u" border="1"> but getting error:
09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)
09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)
MyGraphics worked before I added a background but, even now when I take the background away it isn't showing up.
package com.snow.game; import javax.swing.*; import java.awt.*; class MyGraphics extends JComponent { //creating a class for graphics public void draw(Graphics g){ //calling Graphics making a new graphics (g) now you can use it to make objects g.drawRect(10, 10, 50, 50); //Draws a rectangle
I have one code [taking from on line SCJP exam preparation site]. I have 2 question in my mind:
1) addValue() is non static method then why it is running without object inside constructor. By this rule it should show compilation error. 2) With ref variable of parent always non overridden methods of parent run then it must value of 10 [If i forgot 1st point ]
But it is giving 40. Code is as below:
class Base{ int value = 0; Base(){ addValue(); } void addValue(){ value += 10;
How do I write a program that shows the max and the min value of a float integer? like for example in order to get the max value of a long integer we type System.out.println(Integer.MAX_VALUE); How would I do that for a float integer?
I'm attempting to add a Jpanel in a JFrame but it isn't working out.
import javax.swing.JFrame; import javax.swing.JPanel; public class stepone { public static void main (String[]args){ JFrame frame = new JFrame("CSC LAB 12"); JPanel colorJPanel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
I have three classes.. 1. panel class 2. frame class and 3. tester class...I am creating the objects like so but when I add button to panel then panel to frame I am not seeing the button. here is my code
import javax.swing.JButton; import javax.swing.JPanel; public class Panel extends JPanel{ private JPanel p; private JButton b;
But apparently i was wrong and all i get is an empty JFrame and no Dialog. I even added my own subclass of SwingWorker in case a SwingWorker had to be created in order for a progress monitor to exist. How can I make it show?
I am watching BrandonioProductions on youtube. His videos are pretty good, but he doesn't seem to get errors where I get them. Here is an example.
public class compareUnequal { public static void main(String[] args){ compareTwo(); } public static void compareTwo(){ String x = "david"; String y = "Notdavid"; if (!x.equals(y)){ System.out.println("Not equal"); } } }
It runs ok, but asked me to proceed when there is an error, but I can`t figure out where the error is!
We are asked to create a JDialog showing our database. I am able to show the database but i can't seem to position the heading panel, table and back button. My back button is also not showing up. Here is part of my code...
Why is it not showing those months updated balance? I feel like I'm pretty close. I guess I should specify that this is supposed to calculate monthly interest for one account and quarterly interest for the other. This is what the output should look like.
I had to make a table showing different values for converting kg to lbs and I'm confused because when it compiles, some of the decimals show correctly and some of them show with several 0's added on with another number on the end. I've tried to do math.random, but I'm not sure how to tie it in with my program.
//1 kg = 2.2 lbs public class kg_to_lbs { public static void main(String[] args) { //not sure if values are needed.. int kg = 1; double lbs = 2.20; //Table title
Is it possible for a rectangle with dotted side be shown when dragging the mouse on a component?Just something like the one in the attachments, usually occurs in some graphics/pictures software.
So I make a HashMap which is pretty simple. My book showed me how I would print all the values in a format showing their key a ": " and the the actual value. What I don't understand is why the type element for the for each loop is the interface, Map.Entry.