Dinner Menu Program - Some Text Is Not Showing On Applet

Dec 23, 2014

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");

[code]....

View Replies


ADVERTISEMENT

Java GUI Program Not Showing All Text Fields And Labels

May 19, 2014

When i run the program it doesn't show all the text fields and labels and stuff but when i click btnTest_1 and go back to btnTest everything appears...

Java Code:

import javax.swing.*;
public class Frame extends JFrame{
private JTextField textField;
private JTextField textField_1;
public Frame(){
setTitle("Multifunctual Calculator");

[Code] ....

View Replies View Related

Calling Applet From Another Class Main Menu

Aug 20, 2014

I have a frame which I want to load an applet inside it. Here is the code i have in my main method:

MyApplet myApplet = new MyApplet();
myApplet.init();
myApplet.start();
javax.swing.JFrame window = new javax.swing.JFrame("myApplet");
window.setContentPane(myApplet);
window.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);

But I get an exception:

Quote
Exception in thread "main" java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Applet.java:169)
at MyApplet.init(MyApplet.java:78)
at Intro.main(Intro.java:68)
Java Result: 1

View Replies View Related

Why Images In Applet Not Showing

Aug 30, 2014

So I am trying to make this java applet that will display a random image of three that is a sub folder of my src folder within my project.

When you run the project currently all you get is a white applet. Here is the code:

import java.applet.Applet;
import java. awt.*;
 public class myPictures extends Applet {
Image action;
public void paint(Graphics g){
int rint = (int)(Math.random() * 3);
if(rint == 0){
action = getImage(getDocumentBase(), "../../images/bee3.jpg");
} else if(rint == 1){
action = getImage(getDocumentBase(), "../../images/bee1.jpg");
} else {
action = getImage(getDocumentBase(), "../../images/bee2.jpg");
} } }

View Replies View Related

Text Adventure - Cannot Use Menu Selection

Apr 30, 2015

I cannot use menu selection 4 5 6 7 8 9 10 ... Why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition

I don't understand map[][], objectName[] and objectLocation[]

package Assignment;
import java.util.Scanner;
public class GameWorld
{
// the map array holds details on which paths lead to which other rooms. NO_EXIT indicates no valid exit.
// each element holds the details of all paths leading out from a single-room in the order n ,e, s, w, ne, se, sw, nw
private final int NO_EXIT = 99999; // indicates that there is no exit in that direction
private int map[][] ={{NO_EXIT,NO_EXIT,NO_EXIT,1},{2,0,NO_EXIT,NO_EXIT},{NO_EXIT,3,1,NO_EXIT},{NO_EXIT,NO_EXIT,NO_EXIT,2}};

[Code] .....

View Replies View Related

How To Hide Text From Showing In Console

Feb 6, 2015

I am trying to do a rock, paper, scissors game, but when i choose for example, it shows what i have typed. So how do i hide text form showing in the console?

View Replies View Related

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.

View Replies View Related

Reading Json Of Nested Menu Without Giving Menu Names In Java

Aug 14, 2014

I want to read json file as follow;
 
{
  "M": {
  "row": [
  {
  "col1": "c00"
  },
  {
  "col1": "c10",
  "col2": "c11"
  },
  {
  "col1": "c20",
  "col2": "c21",
  "col3": "c22"
  }
  ]
  }
}
 
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot. 

The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};

View Replies View Related

How To Go Back To Main Menu And Terminate A Program

Oct 15, 2014

How to go back to main menu and terminate a program?

I just want a Simple code.

View Replies View Related

Java Applet - Displaying Output With Text?

Feb 24, 2014

my java applet - displaying output with text

View Replies View Related

Boggle Board Is Not Showing Up When Run The Program?

Jan 18, 2015

I'm making a Boggle game, but the issue here is that the boggle board is not showing up when i run the program.

Here is the code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Boggle {
public static void main(String[] args) {

[code]....

View Replies View Related

Swing/AWT/SWT :: DeckPanel Are Not Showing Up When Run Program

Mar 25, 2014

My deckPanel's etc. are not showing up when I run my program. What am I missing in my orderCalc class or maybe from my deckPanel class?

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class OrderCalc extends JFrame

[code]...

View Replies View Related

Writing A Program Using Switch Statement - Allow Users To Choose Item Of A Menu

Oct 5, 2014

Write a program using switch statement to allow users to choose an item of a menu. For example, the menu looks like the following.

File menu
1. Open
2. Close
3. Save
4. Exit
Enter your choice:

If you type 1, then your program should print out "Open is selected" (double quotes not included).

Notice:
(1) Using Scanner to get user choice;
(2) If the number user input is not in {1,2,3,4}, your program should let user know that.

Here's what I have:

public static void main (String[] args) {
int user = 1
switch (1) {
case value: 1
System.out.println ("Open is selected");

[Code] .....

View Replies View Related

Allow User To Change And View State Of Credit Card With Menu Driven Program

Apr 20, 2015

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;

[Code] ....

View Replies View Related

Adding And Subtracting In Budget Program - Display Table Showing Transactions

Mar 15, 2014

Budget program. Here is my situation, I have 2 tabs in a GUI, one tab adds a transactions when the add button is clicked, and in the other tab displays a table showing all the transactions. In my code, I want it so that when the user chooses a deposit(combo box variable name = cbType, indexnumber for deposit is 0) it will add to the total and when the user chooses withdraw(index number is 1) then it will subtract it from the total. Here is the code.... (note as well, the code also adds a new row to the table)

//add button clicked
private class BtnAddActionListener implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
((DefaultTableModel)table.getModel()).addRow(new Object[]{
cbMonth.getSelectedItem() + "/" + txtDay.getText() + "/" + cbYear.getSelectedItem(),
cbCategory.getSelectedItem(),

[Code] .....

So when I tested the program with 2 transactions, the first transaction was a deposit and the 2nd transaction was a withdraw. The end product was that both amounts were subtracted from the total. When I did a withdraw first and a deposit second, the amounts were both added together.

View Replies View Related

Program To Read / Compare Time Intervals - Showing Wrong Output

Feb 24, 2015

the below program is to read the time intervals (HH:MM) and to compare system time if the system time between your time intervals print correct time and exit else try again to repeat the same thing. By using StringToknizer class. and i have written like this

import java.io.*;
import java.util.*;
public class Main
{
static int k1,k2,v1,v2;
public static void main(String args[]) throws IOException
{
DataInputStream o=new DataInputStream(System.in);

[Code] ....

but is showing correct for some inputs and wrong for some inputs ....

View Replies View Related

Converting A Program Into Applet?

Sep 30, 2014

how to make an applet out of this program but can't seem to do it.

Java Code: import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JLabel;
import javax.swing.JFrame;
import java.io.*;
import java.util.Scanner;

[code]....

Technically, when you run the program, a gif page appears (that I put as a placeholder) and when you press the letter 'n' JCreator runs the program, displaying a character P on a .txt field made using the Notepad on Windows. You can move it left, right, down, and up andf it will move accordinly. However, each time I make such action, the compiler has to rewrite to whole .txt field with the new position.

My former tutor said that in order for it to be "real-time", we have to use an applet.

View Replies View Related

How To Run Applet Program In Web Browser

May 10, 2014

import java.applet.*;
import java.awt.*;
import java .awt.event.*;

[Code]....

View Replies View Related

Get Background Image Showing Other Two Are Not Showing On Screen

Jan 20, 2015

public void paint(Graphics g) {
g.drawImage(Background, bg1.getbX(), bg1.getbY(), this);
for(int i=0;i==400;i+=10){
g.drawImage(block1,fg1.getBlockX(),fg1.getBlockY(),this);
g.drawImage(block2,fg1.getBlockX(),fg1.getBlockY()+10,this);
}
}

This is what im dealing with right now. When i click run i only get the background image showing the other two are not showing on the screen.

View Replies View Related

Converting JFrame Program To Applet?

Jan 15, 2015

I have two programs written out which open up in a JFrame when run but now I need to make it an applet.

My sample code:

import java.applet.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

[Code] .......

View Replies View Related

Program Like Applet - Creating Multithreading Or Drawing Objects

Aug 20, 2014

What is the best choice to program like an applet i mean easy with creating multithreading or drawing objects etc.

View Replies View Related

Program Prompts For A Line Of Text

Jun 2, 2014

Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.

INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter the text: " and then reads in an entire line of text as a String .

OUTPUT . There are four lines of output . The first line is "The text in all upper case is: ". The second line is the line that was read in, displayed in all uppercase. The third line is "The text in all lower case is: " and the fourth line is the original line that was read in, displayed in all lowercase.

CLASS NAMES. Your program class should be called ShoutAndWhisper.

[import java.util.Scanner;
public class ShoutAndWhisper
{
public static void main(String[] args)
{
Scanner scannerObject = new Scanner(System.in);

[code]....

View Replies View Related

Program Won't Scan Properly The Text

Nov 19, 2014

I was trying to do a short program that scans a text for a given word and then tells you how many times that word was repeated in the text. The result was this:

var text = prompt("Write the text to be searched through");
var word = prompt("Write the word to be looked for. Beware of capitals!");
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === word[0]) {

[Code] ....

However, this doesn't scan the text properly. I think the problem lies in one of the lines from 4 to 8, but, even after thinking quite a lot, I couldn't understand what was it. I thought that by saying that the letter of the text in position [i + k] shuold be equal to the letter of the word in position [k] I could make it work, but it doesn't.

View Replies View Related

Changing JLabel Text From Anywhere In Program

Feb 18, 2014

I'm using NetBeans.

I have a JFrame with four JPanels, SensorLL, SensorLC, SensorCR and SensorRR. They are instances of the class SensorUI. Each has a JLabel called Sensor.

The class SensorUI has a method writeSensor that writes to the JLabel "Sensor". I will have four temperature sensors. I have not started the code to read the temperature sensors yet. I will have a timer that will run once a second. When it fires I will read the sensors and display the result in the

JLabel "Sensor" in each jPanel.

I use MyMain to call FrameDemo and create the JFrame and a method

in FrameDemo to add the JPanels using addObject.

I can use SensorLL.writeSensor will write text to JLabel Sensor while in Mymain.

Then I start the timer ReadSensor.

When it times out it calls SampleSensors

For an experiment, while in SampleSensors I try to write to the JLabel in the instance SensorLL with

SensorLL.writeSensor("xx_");

I can't because it says it can't find the symbol variable SensorLL in SampleSensors class.

How can I "get to" that JLabel text when ever I need to?

Java Code:

public class MyMain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//SensorUI SensorLL = null;
System.out.println("Start of main");
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
FrameDemo.createAndShowGUI();

[Code] .......

View Replies View Related

Program Is Not Reading The Text File

Apr 29, 2014

I'm working on a project for my Java class and I've got the code compiled and running, I just don't think that the program is reading the text file the way I want it to.

The text file looks like this:

1168,4.25,10
1305,1.80,42
1345,12.56,16
1388,7.42,30
1480,6.54,80
1495,8.36,48
1560,15.27,65
...

The first number being product number, second being price, and 3rd being quantity. I want to be able to enter the product number and have the Textfields for price and quantity be filled accordingly.

But when I enter a product number (e.g., '1168') no match for the item is being found, regardless of what I enter. Really stumped on this. Here's my code so far --

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Scanner;
public class Project3
{
private static Frame myframe;
private static TextField productCode;
private static TextField invNumberField;

[Code]...

View Replies View Related

Find Language Of Given Text In A Program

Jan 18, 2014

I want a java program to find the language of a given text in a program

For Example: If user enters Hello World it should say its english language

And if he enters a spanish language as a input it should say its spanish language and so on....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved