Passing Variable From Class A To B To Do Calculation But Getting Error?

Mar 23, 2015

I'm getting this error, I definitely know that is my error trying to pass method/variable because when I commented received part of my code it ran and worked.

I get this error

at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Here are my 2 classes

Java Code:

import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code] .....

View Replies


ADVERTISEMENT

Error Passing Value Of A Variable From One Class To Main Method Of Another Class

Jan 8, 2014

I've 3 classes.

1. Circle
2. GetInputFromUser
3. testCircle

package ABC;
public class Circle {
private double radius;
public double getRadius() {
return radius;

[Code] .....

In the testCircle class, in the line: getRadius = ui1.GetInput();

It's showing the error: The method GetInput(float) in the type GetInputFromUser is not applicable for the arguments ()

And when I do: getRadius = ui1.GetInput(rad);

It's showing the error: rad cannot be resolved

View Replies View Related

Passing In Variable From One Class To Another?

Aug 16, 2014

It just wont work... Everytime I try to pass a variable into a class it sets it to 0. What to do.

The variable should be '2', but it prints out as 0!?

Java Code: package Zoo;
import java.util.Random;
public class Animal {
Random random = new Random();
public void Eat(){
System.out.println("The animal starts to eat.");

[Code]...

The method bash, needs the variable 'playerTwo' to be 2, to carry on. But it prints out 0.

Int the animal constructor, I passed in the variable from another class, and it prints out 2 in the constructor like it should. But outside of the constructor it is equal to 0.

View Replies View Related

Servlets :: Java Class - Session Variable Error

Dec 14, 2014

My dynamic web project has a java class that captures a session variable with the following code.

HttpSession LoginSession = request.getSession();
String VAR = LoginSession.getAttribute("myVar").toString(); //This is the row 127

If i test the app in local (Mac + Java 1.8 + Tomcat 8) all works. In my remote cloud server (Ubuntu 14.10 + Java 1.8 + Tomcat 8) all works, except this class, that has this code. I copy the complete error here. Note that the row 127 of the error message is the second row of the previous code; and, if i comment this row with // and assign a fix variable all works. So, the problem is that 127^ row.

14-Dec-2014 08:15:23.923 SEVERE [http-nio-8080-exec-14] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [srvNavigation.SrvPT] in context with path [/myapp] threw exception
java.lang.NullPointerException
at srvNavigation.SrvPT.doGet(SrvPT.java:127)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)

[Code] ....

How can i solve the problem?

View Replies View Related

Swing/AWT/SWT :: Passing Data Through Globally Created Table Variable?

Jun 14, 2014

I have created a DefaultTableModel tablel as a Global variable. The table is then created and attached to a Grid bag layout. Then I want to call the table again in another method to add rows of data into it. Hopefully that makes sense.

So the addrow for the table is located in the final method private class CalcButtonListener implements ActionListener

When I debug the code, deftablemodel variable is carrying NULL data.

Also to make things even more complicated, The actual headers for the table aren't showing up,... not entirely sure why though.

import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Dimension;
import javax.swing.JOptionPane;
import javax.swing.JMenuBar;

[code]....

View Replies View Related

JSP :: Passing Parameters To Custom Tag Error

May 14, 2014

I am not able to pass parameters to custom tag. This is my tag file header.tag under web-in/tags folder

<img ><br>
<b><i>${subTitle}</i></b>

And This is my jsp page that use that tag.

<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<body>
<myTags:header subTitle="We make sure our clients dont have to do that" />

</body>
</html>

It says attribute subTitle invalid for tag header according to TLD.

View Replies View Related

Passing Value From Sub Class To Super Class

Oct 19, 2014

So the first thing we did was make a program called memory calculator. now we are supposed to make a sub class that modifies the program to also do exponents and natural logs. Then to make a new class that acts as the driver for what is now called the scientific memory calculator which includes the exponent and log. I have watched this through debug and im a little confused. first off it creates a variable for currentValue in current and in sci which are my instances, which i dont think is what i really want to do, I am unsure how to get the things in the Scientificmemcalc to do stuff without calling them directly. so when i try to do the power feature it does everything correct but it sets the sci current value to the correct answer, and now i cant figure out how to pass it on to the current current value.

This is the memory calculator :

public class MemoryCalculator {
public static void main(String[] args) {
MemoryCalculator current = new MemoryCalculator();//creates an instance
int choice = 0;
do{//main loop
System.out.println("Current value: " + current.getCurrentValue() + "

[Code] .....

View Replies View Related

Value Not Passing From Second Class?

Nov 8, 2014

I am trying to pass value from class to another using net beans but it seems that I am doing something wrong.

find my basic code at sourceforge.net/projects/val1toval2/files/SRC/

I would like to have both VAL1 and VAL2 having same value in Jlabel.

//Main.java 
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Second SEC = new Second();
l_dis.setText(String.valueOf(getInput()));
l_tot.setText(String.valueOf(SEC.getTotal()));

[code]...

View Replies View Related

Passing Value From JTextField In One Class To Another

Apr 6, 2015

I enter a value in the text box in one class and want to pass that value to another class in order to compare it and color the cell in a table. In the first class I have

package cege.ui;
 import cege.controller.HtmlController;
import cege.controller.ScreenCaptureController;
...
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

[Code] .....

How to pass the threshhold from the first to the second class?

View Replies View Related

Getting Values From One Class To Another Without Passing Into It

Feb 19, 2015

I am trying to get the username and password for one class and send them to another. However I cannot send them in the constructor because a database class is getting them and I need that constructor blank. However if I do not pass the class in the constructor I get a NULL error, even better when I do pass it in I seem to get a thread lock. I do try to do my own housekeeping and close the one frame before I open a new one but it doesn't work. I will do my best to show the design of the program.

program starts
Java Code: public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// connects to database and generates a GUI
new UserPromptScreen();

[code]....

I have to pass in UserPromptScreen in for it to work. This will cause me issues later with my design.

View Replies View Related

JSF :: Passing Backing Bean To Another Class

Mar 7, 2014

I am new to JSF and was trying to find an example.

My question is in the processPage() method... how do i pass the managed bean to the ProjectDAO insert statement?

Faces-config.xml

<managed-bean>
<managed-bean-name>projectBean_backing</managed-bean-name>
<managed-bean-class>com.att.ped.backing.Project</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

[Code] .....

View Replies View Related

Passing JComboBox To Another Class - JAVA GUI

Nov 15, 2014

Java Code:

createConnection();
try{
String str = "select * from Stocks";
stmt = conn.prepareStatement(str);
ResultSet rs = stmt.executeQuery();
while(rs.next())
jcbStock.addItem(rs.getString("stockID"));
}catch(Exception e){
e.printStackTrace();
} mh_sh_highlight_all('java');

I want to put this code in a class then call it in another class , but i do not how to do that. This code is working fine in my main class , but i want to write this code to another class for call it in main class.

View Replies View Related

Reading Input From JTextField And Passing It To Another Class

Sep 7, 2014

I am having trouble taking user input and passing it to another class as a variable. If I assign the value explicitly (see line 59), it works just fine. What I want to do though, is assign the input from inputField to the variable inputVariable. I tried using:

inputVariable = inputField.getText();

This does not work. Regardless of what is typed into inputField, the output I get is just:

"The user typed "

package example;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

[Code] .....

View Replies View Related

Passing Parameter From Object Of Class B To Object Of Class C By Use Of Class A?

Dec 13, 2014

Assuming that we have two classes B and C which inherit from class A. What is the best way to pass a parameter from an object of class B to an object of class C by the use of class A without using static variable and without defining a get function in B?

View Replies View Related

Getting Error - Variable May Not Have Been Initialized

Feb 21, 2015

I know what the error means but I don't think initializing the variable will make my code work as intended so I'm having a little dilemna here... here's the code and I'll highlight the part that is said to be not initialized:

Java Code:

import java.util.Scanner;
public class ItemCost {
public static void main (String []args){
int i=1,item=1,e=1, f=1, g=1;
int items, d ;
double gst, qst, subt, Tot = 1, PriceItems ;

[Code] ....

So I'm supposed to get the following output :

Java Code:

Please input the amount of items bought 2
Please input the price of the item 1 1
Please input the price of the item 2 2
Please input the rate of GST in % 20

Please input the rate of QST in % 18 mh_sh_highlight_all('java');

HOWEVER my program doesn't seem to add input of item 1, and 2 if I initialize subt= 0 initially. It'll only take the last value inputted in the loop. By the way, the increments are counters to count the amount of errors the user might input by accident ( or whatever). Some people have been pointing it out as useless but that's the only way I found it to work.

View Replies View Related

Error Occurs Unless Initializing Variable?

Oct 12, 2014

I don't understand that the error occurs when I don't initialize the variable myPoint. Whereas, I initialize the variable myPoint after variable declaration and before place of error.
 
package enumeration;
import java.util.Random; 
public class Craps {

[Code]....

When I initialize the variable myPoint to zero in its decleration, the error disappear. But why? I have already initialized the variable myPoint in default case before the line of error occured..

View Replies View Related

Word Cannot Be Resolved To A Variable Error

Jun 27, 2014

I am getting an error stating that 'word cannot be resolved to a variable' pointing to my return value. Why? Should I make a default String value for word before my while loop or something, like

String word = " ";
?

String getItRight(){//make sure the user enters the password correctly
Scanner input = new Scanner(System.in);
boolean repeating = true;
while(repeating){

[Code] ....

View Replies View Related

Eclipse Error - Cannot Be Resolved To A Variable

Jun 18, 2014

The error "cannot resolve to a variable". I get the error I just can't seem to fix the error.Presently I am working my way through the Oracle docs and that seems ok. Java for Dummies, Sams teach Yourself Java in 21 Days, plus my favorite Head First Java.

package tutorial;
import java.util.*;
public class HolidaySked {
BitSet sked;
public HolidaySked(){
sked = new BitSet (365);
int [] holiday = {1,15,50,148,185,246,281,
316,326,359};
for (int i = 0; i<holiday.length; i++){
addHoliday(holiday[i]);

[code]....

View Replies View Related

Inappropriate Error - Variable Arg Might Not Have Been Initialized

Mar 31, 2014

Consider the following simple code:
 
public class Test {
      private final int arg;
      private final Runnable runnable1 = new Runnable() {
            @Override
            public void run() {
                 // No errors here, exactly as expected
                 System.out.println("ARG: " + arg);

[Code] ....
 
The java compiler (version 1.8.0-b132) produces the following error when compiling this code:

"Error:(14, 46) java: variable arg might not have been initialized"
 
Actually, I do not expect the error here.

Both declarations 'runnable1' and 'runnable2' are essentially the same: these are just Runnable objects accessing value of the 'arg' field (which is initialized in the constructor).

The only difference between the declarations is that 'runnable1' - is an old-fashion instantiation of Runnable, whereas 'runnable2' - is an instantiation of Runnable via a lambda expression.

View Replies View Related

Catch Block Error Variable Might Not Have Been Initialized

Feb 28, 2015

I want to use a try catch block, but I am not sure how to fix this problem:

int a;

try{
a = Integer.parseInt(A.getText());
}
catch (Exception e){
Output1.setText("Error");
}

//do someting with a here

The purpose of the try-catch is to catch blank input.The problem with this is that underneath the try - catch I get an error saying that the variable might not have been initialized. I know why this happens. I know I could initialize the varaible before the try - catch, but there is no default or null I can set an int as. If I initialized it as 0, the blank input will no longer be catched.how to make this problem disappear?

View Replies View Related

Error Cannot Find Symbol - Variable Keyboard

Sep 14, 2014

I am trying to create this program I am pretty sure it is easy but I am making it difficult lol, it keeps giving me a error, it is saying cannot find symbol - variable keyboard, I don't think I have keyboard as a variable but I may be wrong.

double distancel = keyboard.nextdouble(); that is the specific line ....

import javax.swing.JOptionPane;
import java.io.File;
import java.util.Scanner;
//import java.util.totalInches;
//instance variables
public class Map{
public static void main(String[] args){

[Code] ....

View Replies View Related

Using A Variable From Main Class In Another Class

May 31, 2014

I have a program with 4 classes, all of them in the same package, one of them is the Main class, and in that class I declared a variable named "port" of type int. One of the 3 another ones is the class Connection class, which it requires the port variable. I want to use this variable in the Connection class. How can I do it?Both classes are shown below:

Main.java
package server;
/* Imports */
/* Another variables */
int port; /* <-- IS THIS ONE */

[code]....

View Replies View Related

Getting Error While Creating A Method - Void Is Invalid Type For Variable

Jun 25, 2014

I am new to Java and trying to learn it.I wrote the following program but while creating the method nav i am getting errors.

Error:- void is an invalid type for the variable nav

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.*;
public class YahooHomepage {
private static WebDriver driver;

[Code] .....

View Replies View Related

Using JFrame To Open Up Log In Or Out Windows For User - Unknown Variable Error

Jul 31, 2014

I am trying to use a JFrame to open up extra windows that will prompt the user the Log In or Out, but I am getting an error with one of my variables that writes to Excel. There is something wrong with the variable "sheet" contained in the "while(i <= 4)"

private void createLabel(WritableSheet sheet) throws WriteException

WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10);
times = new WritableCellFormat(times10pt);
times.setWrap(true);
WritableFont times10ptBoldUnderline = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.SINGLE);

[Code] .....

View Replies View Related

Methods From Original Class Receiving Error When In Test Class

Jul 5, 2014

I am working on a program that simulates a bug moving along a horizontal line, My code works correctly when I test it in it's own class but when I tried testing my constructor and methods in a test class I received an error saying, "package stinkBug does not exist" on lines with my methods. However, stinkbug is not a package.

Java Code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

[code]....

View Replies View Related

Dummy Node In Doubly Linked List - Cannot Find Symbol Variable Error

Jun 5, 2012

Im running into some problems with the Java compiler. This is my code:

public class DoublyLinkedList<T> implements SimpleList<T> {
protected Node dummy;
protected int n;
public DoublyLinkedList(){

dummy = new Node();
dummy.next = dummy;
dummy.pre = dummy;

n = 0;

[Code] ....

I want to use a dummy node in my implementation of the Doubly Linked List, so it will be easier to code all the methods I need to write. I keep on getting a problem with line 14 and 15:

dummy.next = dummy;

dummy.pre = dummy;

// cannot find symbol variable next (compiler error)

// cannot find symbol variable pre

View Replies View Related







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