I have two dialogues: one name "dialog" and another named "queryDialog". Each dialog has one button among other things and they are supposed to make their respective dialogues hide when clicked. But the second button doesn't work.Here is my code:
I tried to follow the example of How to add multiple ActionListeners for multiple buttons in Java Swing - Stack Overflow but there seems to be a problem.
My professor like us to make a salary, taxes and etc exercise. which we should type the name first then, input salary. then if we input the amount 8000 or higher. the system will ask another question about the marital status. and that is it.
My real problem is when we input 5000-7999 the system should ask a different question, stating do you want to pay for your premiums and a follow up of yes and no choices. if we input 0-4999 the system will just state that it is your current salary.... etc..
package exer5; import java.util.Scanner; public class Exer5 { public static void main(String[] args) { Scanner Kirk = new Scanner (System.in);
I'm trying to modify an existing code and I'm having trouble with it. I want to add two things to a java Sudoku menu. I added JMenu 5 and JMenu 6 but now I have to make them work. When the user clicks on "Aide" and then "Reglements", I need to have an image that pops and that disappear when the user clicks on it.
I have spent quite a few hours trying to follow an API on how to use Actions in a java program.
I have 3 JButtons and have just added a JMenu. What I want to do is to add an ACTION so that the JMenu performs the same function as the JButtons. (i.e. they both do the same thing).
I have tried to copy and follow the example from the API forum.
How to Use Actions (The Java > Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)
The first error I get in compiling is on the following line:
Action loadFile = new LOADFILE();
However, I get the following error message:
softeng2final2.java:49: cannot find symbol symbol : class LOADFILE location: class softeng2final2 Action loadFile = new LOADFILE();
How to get my program to display a piece of text (upside down) on the first button press, and then display it right-side up on the second button press. I've looked all over the internet and I can't seem to find a example that fits my situation.
Here is the code:
package org.CIS407.Lab10; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JUpsideDown extends JFrame implements ActionListener
I have read that when two threads have two steps (of execution) and each step involves many operations, then the operations of both the threads kind of overlap one-another. For example
I think I am not very clear about interleaving actions/operations? Especially when we say that atomic actions can not be interleaved. But
Java Code:
class Counter{ private int c=0; void increment () { c++; } void readIn () {
[Code] ....
And the following sequence of events occurs.
Thread A: Retrieve cThread A: Increment cThread A: Store the result in cThread B: Ask the user to enter a valueThread B: Read in the value, store it in c
Now the value of c obtained after increment will be lost (Thread Interference). Isn't this an example of interleaving operations?
I was tasked to do a 2-4 player network card game. Before I jumped into doing the card game. I decided to try out an a simple program which is the clients taking turns to type in their textfield.
I have a server that listens to 3 incoming client connections. once all 3 clients is being connected,
Steps
1) The first client will send the message first while the second and third client will wait for the first client to finish sending.
2) After the first client finished sending the message, it will be second client turn to send the message and the third client will wait for the second client to send finish.
3) After the third client finished sending the message, it will be third client turn to send the message and the first client will wait for the third client to send finish and (go back to step 1))
**The first client can only start typing once all 3 clients is being connected**
In my server class,I spawn a new Thread once a client is connected, I do a wait() on each time the client is being connected, I stored the thread in a arraylist as well. I have an id to keep track how many clients is currently connected. once the id reaches 3, I used notifyall() to notify all the threads and set the first position of my arraylist as my currentThread so that I can keep track which is the currentThread running.
I started 3 clients. and I typed the textfield of the first client but my server isn't receiving any messages.
class Server implements Runnable { private List<SpawnNewThread> sntList = new ArrayList<SpawnNewThread>(); private SpawnNewThread currentThread; private int id = 0;
- The Instance Text box and SAVE button should be disabled. When the pop up appears. - The Instance Text BOX gets enabled only when any selection happenes in COMBO Box - The SAVE button gets enabled only when COMBO BOX and INSTANCE TEXT BOX is filled. - Let the CANCEL button be enabled always.
I'd like to change the text on the two buttons which I have in my Dialog Box, how should I do this?
Also, when I click the X Button in the top right of the Dialog Box, nothing happens, and the program only stops when I end it in jGrasp. How do I make this button close the program when clicked on?
import javax.swing.*; import java.util.Random; public class SwingInputExample { public static void main(String args[]) {
I have i am trying to implement tooltip through javascript, like when we click on an image link tooltip should be displayed and it should have close button/ close image to close that tooltip.like the same way i will have multiple images on page, when ever i click on the images all tooltips should be displayed on the page when ever i want to close that then only it should close through close button on tooltip.can we do it through java script or will go for jquery.
I'm very new to Java, and I am creating a program that takes multiple user input to create one face. I have a class for the eyes, nose, lips, and headshape. For some reason, my program is not drawing the graphics. ***for question purposes, I have only included my head shape class and my test class****
my "test" class:
import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; public class FaceTest { public static void main(String[] args) { String head = JOptionPane.showInputDialog("Would you like a circle, square, rectangle shaped head?: ");
I have a package (JAR_A) for entity and controller definition, for example:
entity: Entity controller: EntityController
Then I use this jar in other projects/applications that use the entity.
I want to use the same JAR_A with different persistence unit and different database (in particular, mysql and postgresql) but when I define two persistence unit that include the same class, I have an exception.
So, I comment the other PU and compile the project.
there is a smarter way for use same package with different PU ?
I am trying to launch a GUI to my agent-based model (Repast and Eclipse) so that being able to run the model for many times. I am going to produce input parameters based on different distributions for different runs from GUI. Usually we should use batch file for different runs. However, I want to use GUI for this reason because I have GUI that can take care for one run but not for many runs.
Can you have multiple key events? by that I mean say you press the right arrow key, or a number on the numeric pad, then you press the letter c. does the second key event get fired? and i can catch both events?
Here's My code to create multiple JTextfields in a Single Option Pane.
My goal is simple.
Take some input from the user and then store it a TEXT File.
package printer; import java.awt.Toolkit; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import javax.swing.*; public class Database { JTextField name = new JTextField(); JTextField roll = new JTextField();
I have to make a retail item class that has description, price and quantity. I then have to make a CashRegister class that calculates subtotal, tax, total and displays it (toString). I also have to make a driver class to call the methods from main. I have no clue what I am doing and what I have done does not work. I am trying to make it sort of like a cart, in the CashRegister it should ask the user to enter the description, quantity purchased and the price. Then it would send that to the arraylist of retailitem. I am having trouble using those items in my other methods and then do not know how to call those in the driver class.. So here are my classes:
public class RetailItem { private String description; private int quantity; private double price; public RetailItem(){ description = ""; quantity = 0;
i am currently making a game in java and currently i am working on the basic mechanics. most of it is working fine but i cannot seem to make it so when the user presses and movment key and space to fire a bullet the bullet fires in the direction they are moving. here is the code i have for movement.
public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub int bulletx = Player.x + 100; int bullety = Player.y + 20; int key = e.getKeyCode(); if( key == e.VK_W){ p.moveUp(); } if(key == e.VK_S){ p.moveDown();
I was trying to play around a little bit after learning creating multiple classes and stuff.However,i encountered a strange problem with reading a value from the user and then storing it in a variable.The usual way i do it is
But when i trying to print the contents of the variable "variableName" the compiler throws a lot of errors .I am attaching how i have tried that out in my code
import java.util.Scanner; class laptop{ private String modelNumber; private boolean hasFan; private float ramSpeed; protected int numCores; //private String input;
[code]....
Without the setInfo() in the laptop class the program functions as desired but i intend to ask the user if he wants to modify something and then reflect the same.
how to insert multiple rows in a database..i want to insert multiple rows but this can happen when i hit the submit button once. i use j2ee and db is postgresql.
This program allows the user to select one of each different type of skateboard/accessories items. Then it allows the user to select as many misc items as he or she chooses. The program works fine for the single choices, but I cannot solve the latter part. I have a get method in the misc class that is trying to pull out any selection or selections that were made by the user, but it simply does nothing...
Here's my program, I have four panel classes for each skateboard type, and then I have one class that takes care of adding each panel to the content pane, and calculating the total cost of the item.
Decks Panel Class:
import java.awt.event.*; import javax.swing.*; // The DecksPanel class allows the user to selects a specific type of skateboard public class DecksPanel extends JPanel