Program That Links Several GUI As Menu Based Program
Dec 17, 2014
In a project for school. I have a program that links several GUI's as a menu based program. What I am trying to accomplish is when one of the previous GUI's is closed that it doesn't terminate the entire program. There is a lot of classes in the entire project so I'd prefer not to paste all the code here, but if it is necessary I will do so.
I have been writing the below Dinner Menu Applet; however some text is not showing on the applet and it is not adding the 'desserts" section correctly especially the one that says "rice Pudding". I've tried it in so many different ways and it's sill not working correctly.
import java.applet.*; import java.awt.*; import java.awt.event.*; public class DinnerMenuApplet extends Applet implements ItemListener { Label dinnerMenu = new Label("Dinner Menu");
I am new to OOP, i am not sure if this is the correct approach or not. Write a class named CreditCard that has (at least) the following member variables:
- name. A String that holds the card holder's name. - cardNumber. A field that holds the credit card number. - balance. A double that stores the current credit card balance. - spendingLimit. A double that stores the spending limit of the card holder. - Bonus: additional fields that you can think of.
In addition, the class should have the following member functions:
- Constructor. The constructor should accept the card holder's name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0. - Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's member variables. - purchase. This function should add the amount specified as a parameter to the balance member variable each time it is called. - increaseSpendingLimit. This function should add 500 to the spendingLimit member variable each time it is called. - payBill. This function should reset the balance to 0. - Input validation: Whenever a credit card number is modified, verify that it is of reasonable length.
Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.
View Card Information.
- Purchase an Item: ask the user the purchase amount and increase the card balance accordingly. - Pay Bill: call payBill method to set the balance to 0. - Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit function the appropriate number of times.
[CODE]
import java.io.*; import java.util.Scanner; public class CreditCard { Scanner input = new Scanner(System.in); //data members private String holderName; private int cardNumber; private int accountBalance; private double spendingLimit;
This is what the gui looks like at run time. The question is how do I compact it so there is not so much space between the labels and the textArea. I've tried using different numbers on my GridLayout, but not a lot of success.
I'm supposed to write a computer based testing program using files. I have started writing however, I am stuck. I am to prompt the user to enter the file name 'test.dat" and if something different is entered then a error message should be displayed. Also the file will create an input stream for the data using the file. I am to have the user enter other information about an employee and then write the record to the file.
The program should be created so when the user enters "quit" the loop is terminated and the file is closed. I'm not asking for code. I was just giving a brief synopsis of the project. Where I am stuck is I wrote the first part of the program that creates the file; however when I enter a wrong file name the exception error message does not display. The code is below:
import java.io.*; import java.lang.*; import java.util.*; public class Project5Write { private Formatter x; public void openFile(){
I am trying to create a program that will estimate a child height based on the height of the parents. It should ask the user to enter a String representing the gender, so m or M for a male and f or F for a female. The program must handle both upper or lower case gender entries. I need it to ask the user for the height of both parents in two parts:
1. for Feet and store in an int variable. 2. for inches and store and int variable.
So for example if the father is 6' 2'', the user would enter 6 when asked for feet and 2 when asked for inches. Convert the height of the each parent to inches. hint 12" in one foot.
Apply the following formulas based on gender (must use an if statement(s)):
Have written a program to open Excel sheet from java program.Below line works fine.
Process p = Runtime.getRuntime().exec(new String[]{""C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE"","C:UsersRASHPA~ 1.ORAAppDataLocalTempExport_xl420314062726 9379706.xls"});
But below code gives error i.e. Executable name has embedded quote, split the arguments
I'm creating a program that will compile and run another java program:Lets say I have a program in directory
D:HelloWorldsrc and compiled program will be in D:HelloWorldin inside src and bin is a folder hello (that's a package)
package hello; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); System.out.println("Hello World"); } }
This program will be run by another program (that's the program that I am creating).Here is the code of my program:
package runnercompiler; import java.io.IOException; import java.io.InputStream; import java.util.logging.Level; import java.util.logging.Logger; public final class RunnerCompiler {
I'm working in a GUI program, but I'm not going to put the code because there is a lot of code and files. Instead, I will try to put it an example.
Let say:
I'm working in a GUI program that ask form the user to enter two number's. When the user press at the calculate button. It will show up the output. However, the program won't exit unless the user press at red (X).
int x = user_Input1; int y = user_Input2; int total = x + y; // JOptionPane.showMessageDialog(null, total);
I know that there will be a (total) now, so my question is here how can I reset all the calculation and have a new total that will show up when the user enter two number's again.
I am making a WebCrawler, and I am trying to work out a way to stop duplicate links from getting put in however ArrayList.contains() doesnt seem to be working for me can someone look at my code and see if I am doing something wrong? I have also tried variations of it such as
!link.contains(newLink) and !link.contains(newLink.getLinkUrl())
I try to use ‘rewrite’ [URL] .... in my JSF application. So, I want to show user friendly links. For example, I have /viewpage.xhtml?id=5 page, but I want to show /page/5 or, more better /page/{page-title} . How can I reach this functionality?
I have a random list of links whose title I am getting from the database. I'd like to catch one of these links when the user clicks one of them and process it from a single jsp file. Possible?
E.g.: when user clicks one of these links, can I dynamically call a web page that fetches information from the click and gets values from a database and insert it on JSP page....
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 have searched the internet for about 2 days and now i'm posting this. I'm trying to make a program that will let me enter "1" to show how many movies I have watched and press "2" for a new one. The problem I ran into is I enter 2 then when I enter 1 it said "you have watched 0 movies". I know what the problem is I just don't know how to retype it. here is the code.
package stuff; import java.util.*; public class thing {
I want to create a dropdown menu with contents from a database. You can see my Code in the attachment. It does not work, but why? I have a dropdown-symbol, but no contents.
I have a GUI with a menu to do various options. However I want to change that menu to use buttons instead. I'm working with JSwing components and I'm a little familiar with the JButton function, but I don't know how to convert the menu to a button. I think I'll have to remove the menu completely..anyway I tried to start with the file menu but the compiler says no suitable method found for setForeground(javax.swing.JMenu). Why is it giving me an error related to JMenu when I'm using Jbutton objects? Can I not use JButton objects inside a menubar scope? I'll bold the area it highlighted:
ok so I am trying to create a movie rental database. I want to show a list of movies, customers, and rentals. my problem is that I cant run everything but I keep getting the following error :
ERROR: Table/View 'MOVIES' does not exist.
Here is my code
import java.sql.*; import java.util.Scanner; public class MovieRentalDB { public static void main(String[] args)
[code]....
the program runs but I keep getting that error. I know my code is also not complete but I will do the rest once I figure out why my tables are not creating
I am working on implementing a stack using a linked list. Programming the stack operations (push, pop, isEmpty, etc.) was easy but my directions were to provide the user with a menu to choose the operation that he/she wishes to perform. I am new to JFrames/Menus so how to make the stack operations available in a menu.
I am making an edit page and I want to populate my drop down menu with things that were already selected. For example, if i want i click to edit my favorite food it will be populated with the one the user previously selected. How do i go about doing this? [URL] ....