GUI - Calling Int And Double Values From One Panel To Another

May 10, 2014

So I am making a panel project that calls three panels. Panel one holds all information and the other two panels are panels that open up when I press a button. How it works is I call the first panel, press a button, second panel opens. Then in the second panel I plug in a password. If it is correct, a third panel will open. I need to call values from the first panel into the third panel and those values act as sort of like counters. In the third panel it will display all the counters that were added as well as the complete sub total, tax, and total that the program accumulated during its run time duration. I know how to use constructors, accessors and mutators, but the values I need are generated in an event when I press a button. I am trying to figure out how to call those values from the event into the third panel. Here is my code :

Main Class:
import javax.swing.*;
public class AppleRegister {
public static void main(String[] args) {
double subTotalp2 = 0, taxP2 = 0, realTotalp2 = 0;
JFrame frame = new JFrame("Apple Crazy Cola Cash (Apple IIC) Register");

[Code] .....

Here is the main panel holding the information. The counters counterp21 through p24, subTotalp2, taxP2, and realTotalp2 are the values that need to be carried over to the third panel and displayed in the textfields. I will post half of the panel, at least the important parts. Notice that I made my constructor initialize double variables which are the subTotalp2, taxP2, and realTotalp2. In this instance, I am not calling the counters just yet due for the sake of testing purposes. TempListener2 is the event that holds the variables that I am trying to call into the third panel.

Main Panel:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class AppleRegisterPanel extends JPanel {
private JButton button1, button2, button3, button4, button5, button6;

[Code] ......

And here is how I am trying to call those values into the third panel. If you notice, the class is actually called AppleRegisterPanel2; this is because I made this before the second panel that is now implemented. This panel now acts as the third panel.

Third Panel:
public class AppleRegisterPanel2 extends JPanel {
private JButton b1;
private JTextField t1, t2, t3, t4, t5, t6, t7;
private JPanel panel, panel2, panel3;
private JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9;
private double subTotalp2, realTotalp2, taxP2;

[Code] ....

So my question is; is what I am trying to do even possible? I know the information that is being stored is inside a void that is acting as an event. As it stands the code that is called in the third panel is 0.0. I know this code seems sloppy but I've been trying different things with no result. How I can do this if at all?

View Replies


ADVERTISEMENT

Calling Out Constructor And Assigning Values To It From A Scanner

Oct 16, 2014

import java.util.Scanner;
public class Try{
static String name;
static int age;
static Scanner a = new Scanner(System.in);
static Scanner b = new Scanner(System.in);
static Scanner c = new Scanner(System.in);
public Try(String name, int age){

[Code] ....

I was trying to make a program that asks the user to create a person or a group of persons and assign names and age to them. So I made a constractor "Try" and a method "AskUser".in AskUser() I use a do/while loop where user is asked to input a name, an age and if he likes to create another person. Now how do I take the input data each time the loop runs, and send it to constractor to create new objects with it? And how these new objects will be called?

View Replies View Related

Converting Double Values (0.0-110.0) To A 4.0 Scale (as Used In GPA Calculation)

Sep 3, 2014

I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, I am pasting the code I currently have below.

import javax.swing.JOptionPane;
public class GPA_Calculation1_0 {
public static void main(String[] args) {
String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one
double numOne = Double.parseDouble(courseOne);

[Code] ....

View Replies View Related

Using For Loop To Populate Array With Random Double Values

Oct 26, 2014

Write a program that creates an array that can hold 9 double values that represent baseball batting averages for a starting baseball lineup. Use a for loop to populate array with random double values in the range of 0.00 to 0.500. Recall that "double" values are what Java calls "real" numbers. Use a second for loop to print the values in the array with one number per line. Finally, use a third for loop to traverse the array and find and print the maximum batting average in the array. Note: you will need to use String.format to control the precision of a double number when you print it- Here is my code so far:

public class P2F {
public static void main (String[] args) {
double [] player= new double [9];
//player[0]= Math.random();
for (int index=0; index < player.length; index++) {

[Code] ....

When I open the terminal window I get different variations of this [D@4545c5]. I would like to know all the things I am doing wrong.

View Replies View Related

Scanner Class Error For Decimal Values (double / Float)

Apr 23, 2014

I'm not getting why my program is giving error.

package rockjava;
import java.text.NumberFormat;
import java.util.Scanner;
public class file4 {
public static void main(String[] args)

[Code] ....

Please Input Num of Pods + Num of Keys= 20.5
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextFloat(Unknown Source)
at alijava.file4.main(file4.java:14)

(It is not accepting double values. However working fine for integers.)

View Replies View Related

Calculate Distance Between Two Points - All Numbers And Return Values Should Be Of Type Double

Jul 8, 2014

Write method distance to calculate the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type double. Incorporate this method into an application that enables the user to enter the coordinates of the points.

Hints:

- The distance between two points can be calculated by taking the square root of

( x2 - x1 )2 + ( y2 - y1 )2

- Use Math class methods to compute the distance.

- Your output should appear as follows:

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: 1

Enter Y1: 1

Enter X2: 4

Enter Y2: 5

Distance is 5.000000

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: ^Z

View Replies View Related

Swing/AWT/SWT :: When Click On Button From Bottom Panel Top Panel Need To Be Redrawn

Apr 1, 2014

When i click on the button from bottom panel, top panel need to be redrawn. But redrawing is not happening. It happens only when resizing the applet.

public class Graphics_Chart(){
public init(){
JScrollPane topPane = new JScrollPane(new ImagePanel2());
topPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
topPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

[code]...

View Replies View Related

How To Switch From One Panel To Another Panel

Apr 5, 2014

I have two(panel1 and panel2) panels in a jframe,all three of them are different classes .

In jframe there is a display panel on which the panel1 and panel2 are called and displayed.

now i have a button in panel1 .i want that when i will click on that button panel2 will be displayed or added to the dispalypanel of jframe.

View Replies View Related

Store Pixels Values Currently On Screen And Compare Them To Values On The First Frame?

Aug 29, 2014

I need a way to store the pixels values currently on the screen and compare them to the values on the first frame. Right now I'm using glreadpixels as follows:

currentBuffer= BufferTools.reserveByteData(mapSize);
glReadPixels(mapStartX, mapStartY, mapWidth, mapHeight, GL_BLUE, GL_UNSIGNED_BYTE, currentBuffer);
for (int i = 0; i < mapSize; i++) {
if (currentBuffer.get(i) != baseBuffer.get(i)) {
//Do nothing
continue;
}
//Do something
}

This works perfectly fine but turns out to be a real bottleneck, dropping the fps to a third of what it was. Is there any quicker way? All I'm after is speed, I don't even need to show it on the screen if the comparison is made "behind the scene".

View Replies View Related

Servlets :: How To Send Multiple Values Of Same ID But Different Values Of HTML

Feb 27, 2015

I have a question in mind that this is my registration form. I am sending these values from HTML form to server and database. I have question that in my case if I click next to Add Another Mobile no in HTML.then a block is genereated and each time a new name is generated.

My Question is if I click 6 times then 6 name attribute are generated. How can I send and differentiate them on my server side.

Because at their I will use something request.getAttribute("Attr_Name");

But they are same. How to do this?.

View Replies View Related

When Add Second Panel The Result Is All White

May 11, 2014

import javax.swing.*;
import java.awt.*;
public class PRJ04 extends JFrame {
public static void main (String [] args) {
PRJ04 frmApp = new PRJ04();
PanelChart pnlChart = new PanelChart();

[Code] .....

When I comment out the adding and setting of the pnlChart on my main driver, the pnlPopulationInputs shows up fine, and it runs ok. When I add the pnlChart I get errors like crazy and a white screen. My errors:

Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero
at PanelChart.drawChart(PanelChart.java:45)
at PanelChart.paintComponent(PanelChart.java:24)
at javax.swing.JComponent.paint(JComponent.java:1054)

[Code] ....

Once more with this one, I refer back to our in class example. Our programs are set up the same, yet he has no issues with the "/ by zero" exception.

View Replies View Related

Scrolling In Panel Won't Work

Oct 9, 2014

I've got a panel which an arbitrary number of text fields may be added to at run time. I've got it set up so that the window's height, and the height of the panel in which the fields appear will never exceed the height of the screen.What I don't have is a way to make the panel scroll to access the fields that are being visually truncated. I'm setting the autoscrolls on the panel to true, but when I run the program, the fields are simply truncated.

pnlDeclensions.setAutoscrolls(true);

View Replies View Related

Which Listener To Use On Video Panel

Jun 4, 2014

I have panel = window(new frame) and its used to render a video image on, i need to pickup a touchscreen press change of event but not sure which event listener to use and on which component. Is it a panel, window or frame event? and which listener would detect a focus change or a mouse press

I know mouse listener and focus listener and window listeners are available but not sure they would be able to detect the screen press on the video rendered image...

View Replies View Related

Graphing Using Drawing Panel

May 1, 2014

import java.awt.*;
 public class Program5 {
 public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(300,500);
panel.setBackground(Color.white);
Graphics g = panel.getGraphics();
g.setFont(new Font("Helvetica", Font.PLAIN, 12));
double ball = 10;

[code]....

I'm fairly new to Java and am having a hard time with this particular assignment. The program runs and shows up on the drawing panel fine but I can't get the lines quite right.Capture.jpg

View Replies View Related

Fill A Panel With Seats

Jun 13, 2014

We get a database and some DAO classes. We had to fill a ShowPanel with different shows being given in a theatre, and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel. I got the first part with the shows and dates. But Im stuck at getting the seatings.We have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method). I think i just don't know how to link the chosen show+date with the seatings.For the moment i have

public ArrayList<Seats> getSeating() throws SeatingException{
Show s = shows.getName();
ArrayList<Showdate> showdate = s.getDates();
ArrayList<Place> seating = new ArrayList<Place>();
try{
for (Showdate sd : showdate ){

[code]...

The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.

View Replies View Related

Button Not Showing On Panel?

Jan 27, 2014

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;

[code]....

View Replies View Related

Centering A Panel In JFrame

Nov 19, 2014

Okay so I have the codes all written but I didn't really look at that I had to color the center of the frame. I have base code for it but it just doesn't want t ocolor the cnter frame for me for some reason. I have been looking around and still am having problem with it only coloring the center of the frame.

Java Code:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class MenuColors {

[Code] ....

View Replies View Related

How To Get Object From Panel Back Across To GUI

Jul 6, 2014

I've been putting together an addressbook and try to work on some idea but I have hit a bit of a wal early on, and Im sure the problem is easy to resolve, I just can't get the old brain to do it.At present I have 5 classes

PersonDetailsAdressDetailsAddressBookAddressBookGUIEnterDetailsPanel

I have taken EnterDetailsPanel out of the main GUI code, as I plan, or had planned on using additional JPanels for the other options of the application until I got stuck. What I want the EnterDetails panel to do, which it does so far is to have the user enter all of their information and when the button is pressed it will then create a PersonDetails object and here is where my problem is. how to get the object from the panel back across to the GUI which initalises the AddressBook class in the constructor and add it to the List via an addDetails() method.

If I create a quick method in the AddressBookGUI class I can add the object to the List fine, I'm guessing this is because I have created a new instance of the AddressBook in here already via the constructor, however if I add an AddressBook reference in the EnterDetailsPanel I get a nullpointerexception for the opposite because it's not been created in there.These are what most of the classes do so far.

PersonDetails has a reference to the AddressDetails and holds all information for that person.AddressBook contains a List that accepts PersonDetails and has methods to add/remove the person.AddressBookGUI creates a new instance of the AddressBook class along with the general gui things. EnterDetailsPanel is added to JTabbedPane in the GUI class and allows the user to enter their details and submit those via a button which will then create a new PersonDetails object that I am trying to get added to the AddressBook class List

View Replies View Related

Transparent Panel Drawing

Apr 23, 2015

solve my problems regarding drawings on my JPanel(Transparent panel).My Jframe & other components are created by netbeans GUI builder & the transparent panel is created manually but one problem is that i can't impose this Transparent panel into JFrame like it is attached to the JFrame.Another problem is that,i want that transparent panel size should be counted in inch like my attached picture(TOTAL SIze 36 inch) & also when i clicked on that panel those mouse points highest distance should be measured in Inch.How can i do all of these three task??

View Replies View Related

How To Change Background Color Of Panel

Oct 23, 2014

I have a Jpanel with JButtons on the panel is it possible to change the background color of the pannel but leave the JButtons thr default color

View Replies View Related

How To Hide A Panel But Preserve The Space

Mar 27, 2014

I have eight panels that are one above the other and are the full width of the frame.

I would like to hide some of them some of the time and then "bring them back".

If I use panel1.setVisible(false) panel1 will disappear but then all the panels below it move up to take panel1's place.

I don't want that to happen. I want just a blank area where panel1 was.

Is there a way to do that?

View Replies View Related

JSF :: PrimeFaces Accordion Panel Information

Aug 13, 2014

I have an JSF that uses primefaces accordion snippet. However I want to populate the information from each tab from a seperate webpage that would also have accordion snippet in it. I can do this on a single page no problem, but the length of the program (webpage) is getting to the point that it is unmanageable.

The code I have:

<p:layoutUnit position="center">
<p:accordionPanel activeIndex="null">
<p:tab title="Burglar">
<h:outputText value= "Burglar"/>
<p:accordionPanel activeIndex="null">
<p:tab title="Skills">
<h:outputText value= "Skills"/>

[Code] ....

What I am after:

<p:layoutUnit position="center">
<p:accordionPanel activeIndex="null">
<p:tab title="Burglar">
<h:outputText value= "Burglar"/>
<p:accordionPanel activeIndex="null" url="burglar.xhtml">
</p:accordionPanel>

[Code] ....

How to get this to work... I am sure that it has something to do with my url but not sure how to fix it and I can not find anything on the web on how to do this.

View Replies View Related

Function That Returns The Panel Of The Graph

Jun 9, 2014

Before I created the data file are the points of x and y I created a model class that represents the graph. I have a problem with making a function that returns the panel of the graph.

Attached File(s)

 data.cvs.txt (726bytes)
Number of downloads: 12
 chart.txt (3.72K)
Number of downloads: 10

View Replies View Related

Enable / Disable All Textboxes In Panel

May 31, 2014

I am learning Java but have a strong C# background. I am trying to figure out the syntax to do this in Java. In C# I would do the following to enable all text boxes in a panel

private void EnableAll() {
foreach (Control ctrl in Panel1.Controls) {
if (ctrl is Textbox)
((Textbox)ctrl.Enabled = true;
}
}

Is there something similar I can do in Java to do the same thing.

View Replies View Related

Collapse / Expand Panel In Java

Nov 13, 2014

If I wish to create a toolbox that looks like the toolbox as in photoshop tat some can collapse or expand, which type of button or function should I use?

View Replies View Related

How To Use Data From Login Panel In Another Class

Aug 4, 2014

I am getting data from user and checking it with database (MS SQL ) if it fits it is switching to new window. In new window I need to use again my database so I need to add connecting data again. I would like to get them from login window. How to do that? I know theory but when I am writing code nothing works. Here is working code for login panel :

/*import java.awt.BorderLayout;
import javax.swing.*;
public class Login extends JFrame {

[Code].....

View Replies View Related







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