Get Input Of Several JComboBoxes

Jul 24, 2014

I'm trying to get the input of several JComboBoxes and execute a statement depending on which option the user chose for example if destination combo Box = japan duration combo box = 10 days and hotel combox = hotel then print line "welcome" I have tried many options but not getting the desired outcome. at the moment I'm using an if statement with only 2 of 3 of the J combo boxes but it's not working here's my code:

String[] Dest = new String[] {"Select Destination","Crete", "Paris", "Croatia"};
String[] Accomodation = new String[] {"Select your Accomodation","Hotel", "Villa", "Bed in Breakfast","Youth Hostel"};
JComboBox<String> comboDest1 = new JComboBox<String>(Dest);
JComboBox<String> comboAccom1 = new JComboBox<String>(Accomodation);
 
[code]....

View Replies


ADVERTISEMENT

Why JFrame Not Showing Components Such As JComboBoxes

Sep 4, 2014

my JFrame is not showing anything, (Perhaps test it in your own IDE on your own PCs/laptop)

// Project: RestaurantBillCalculator.java Calculates a table's bill.
 
// Import statements for different classes
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JComboBox;

[code]....

View Replies View Related

Swing/AWT/SWT :: Making Two JComboboxes To Be In Sync When One Selects Item From Dropdownlist?

Jan 17, 2015

basically I would like to know how to to the following Java. Example... Say I have one JComboBox, and it is populated with 10 items which reads from a text file ("apple","banana","kiwi","orange","grape fruit"), and the other JComboBox holds the price ($1,$2,$4, etc etc...you get the drift).

How do I make in such a way when I select for example banana from the JCombobox that it syncs the other JCombox to the correct price?

Basically syncing the two JCombobox so that you do not need to select the price yourself - it does it automatically for you.

View Replies View Related

Swing/AWT/SWT :: How To Display Two JComboBoxes Side By Side

Jan 20, 2015

I am trying to display two JComboBoxes side by side. I can successfully display them as part of a BorderLayout if they are in the North and East, but when I try to display them side by side in the same area, eg North, only one of the combo boxes gets displayed.

package selectingshapes;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import java.awt.Graphics2D;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;

[Code] .....

View Replies View Related

Generate QR Code From Input Text And Display Information About Input / Output Bits

Nov 12, 2014

I am trying to write a program that will generate a QR Code from an input text and also display some information about the input/output bits. So far I have created the frame and what to do next. And I'm not sure if I am on the right track since my level of programming is not that great. By the way, I am using zxing libraries from GitHub. I know, there are plenty of generators online for the QR Code, but that is not what I am looking for. As you can see on the attached image, I am more interested in the efficiency of encoding 2D data. Also, I noticed that almost all the online projects regarding 2D codes are for Android. Which is not very useful.

// QR Code Generator
package qrcode;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

[Code]....

View Replies View Related

Create Program That Prompts Input And Creates File With That Input As Name

Jul 14, 2014

So I was going to try to create a program that prompts input and creates a file (That didn't exist before) with that input as name.Then, the program prompts inputs after stating questions such as 1 + 1, then if the user inputs an answer, put "Question # = Correct "or" Wrong.Code SO Far:

Java Code:

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class File_Read {
public File_Read() {//File_Read is the Interactive object

[code]....

So that it puts the Correct or Wrong into the file.

View Replies View Related

Where To Input Segment To Get User Input Dialog

Apr 9, 2015

Where do I input this segment?

Scanner user_input = new Scanner( System.in );// This line goes at the top with the other global variables

public void getUserInput(){
System.out.print("Enter litres: ");
litres = user_input.nextDouble( );
System.out.print("Enter mileage: ");
mileage = user_input.nextDouble( );
System.out.print("Enter speed: ");
speed = user_input.nextDouble( );

[Code] ....

This is my client file.

class Client{
public static void main(String []args){
Bike R1=new Bike(5.0, 60.0,30.0);//create bike object with params
Bike R2=new Bike();//without params
System.out.println(R1.increaseSpeed());//calling methods
System.out.println(R1.maxDistance());
System.out.println(R2.increaseSpeed());
System.out.println(R2.maxDistance());
}
}

View Replies View Related

Decimal To Hex - Not Getting Value 0 When Input Is 0

Mar 4, 2014

Why do i not get a value 0 when my input is 0.

import java.util.Scanner;
public class Dec2Hex {
public static void main(String[] args){
int dec;
String hexStr = "";
int radix = 16;

[Code] .....

View Replies View Related

How To Get User Input

Nov 13, 2014

I have been coding in my class at school (Grade 11 Computer science) and i just downloaded the program on my computer at home, unfortunately i cannot access my computer notes at home and i also dont remember certian specifics of coding, so my question is how would i get user input to create a program. The comments are the parts i dont remember. (I am trying to slowly build my memory with this stuff)

Here is my code so far:

import java.util;
[highlight=java]
public class hello_world {
public static void main(String[] args) {
string name;
//WHAT DO I PUT HERE????

[code]....

View Replies View Related

Sum Of Odd Digits Of Input

Oct 14, 2014

I have it so it gives me the sum of any digit, i just cant figure out how to get only the odd digits to add up. for example if I were to type 123. The odd numbers = 4 but using this program i get 6

class SumOfDigits {
public static void main(String args[]) {
int sum = 0;
System.out.println("Enter multi digit number:");

[Code] ....

View Replies View Related

How To Get Each Row Of A Matrix From Input

Apr 24, 2014

Im trying to get the user to input the rows one by one but my input stops after the first. the examples i looked at in my book had this way i used as well. i are my rows and j are my columns. What is the correct way to do it?

import java.util.Scanner;
public class Exercise08_01 {
public static void main(String[] args) {

[Code]....

View Replies View Related

Asking User For Input Twice?

Apr 19, 2014

I'm working on creating a dice game and getting the users input is giving me a really hard time. I have the main game working but this part I'm stuck on. The problem is that it's not giving me the chance to enter the second input when I ask for the game.

//Create Scanner object
Scanner keys = new Scanner(System.in);
//Get chips

[Code]....

*****This is what I get when I run it

run:

How much money would you like to change? 50

You now have $50 in chips.

What game do you want to play? You did not pick dice.

View Replies View Related

Input In Else If Ladder?

Jul 24, 2014

So I'm currently self learning java. Currently I'm trying to write my own code with an else-if ladder to spit out the data on different types of ships. For some reason, when I put in the input, it always puts in my final else statement instead of the other ones. I've ran this code manually inputting a char (in the code the variable is ch) to see if the else-if ladder runs properly, and it does. But for some reason the input isn't running the ladder right.

class Ships {
public static void main (String arg[])
throws java.io.IOException {
char ch;
int length, beam, draft, min, max;

[Code].....

View Replies View Related

Do-while Input Validation

Oct 24, 2014

I need to write an input validation while using the do-while statement. I feel like most of it is good except that it gets stuck inside the brackets of the do statement. After I enter an input, it just keeps asking me over and over for an input. Then I have to make it s if you enter an input that is out of range, you have to keep entering an input until it is in range.

Java Code:

do
{
System.out.print("Please enter the amount of spaces the letters will shift... ");
shift = uInput.nextInt();
} mh_sh_highlight_all('java'); Java Code: public class ShiftEncoderDecoderDriver
{
public static void main(String[] args)

[code]....

View Replies View Related

Largest Of Input Numbers?

Nov 5, 2014

I think the problem in this is that the variable max is initialised as 0. Afterwards it remains in the while loop only, so the output is always 0. I dont know how to bring the last max value out of loop and print it.

import java.util.Scanner;

/**
*
* @author
* @version
*/
public class TEST1

[Code].....

View Replies View Related

Converting Input From Textbox Into Int?

Apr 8, 2015

Here is my code, basically I'll tell you what my program is suppose to do, I want to be able to leave the text box's empty if I like I want to skip 1 or more or all if I like skipping just basically means 0 but getting this error, it's forcing me to type in them all.

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unk nown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at StockControl.addToStock(StockControl.java:86)

[Code] .....

My code :

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
 
[Code] .....

View Replies View Related

Can Control User Input

Oct 11, 2014

Is there a way you can control user input?

For example, is it possible to only allow the user to enter digits?

View Replies View Related

Loading File From Input

Mar 24, 2015

how I can change my code so that somebody can actually input the specified file path, rather than having it fixed in the code. I previously used

Scanner in = new Scanner(System.in);
System.out.println("What is the filename?");
String input = in.nextLine();
File file = new File(input);

But then the program would not display the frequencies.

import java.io.File;
import java.util.*;
/*
This program will allow the user to enter in a text file name, when prompted the program will anaylser the text and display the frequencies
*/
public class AssP {
public static void main(String[] args ) {
Scanner scan;
try {
Scanner scanner = scan = new Scanner(new File("C:/Users/Mary/workspace/Assingment/src/test.txt"));

[code]....

This is my current code and I need to so the user can load their own files.

View Replies View Related

Formatting User Input

Feb 4, 2014

I have been given a piece of work to do for College that requires me to format user input. For example: This is an example of text that will have straight left and right margins after formatting

will transform into:

This..is..an.example
of..text..that..will
have..straight..left
and...right..margins
after.....formatting

The user inputs the width, in the case above being 20. Each line has to therefore be 20 characters long. All spaces are to be replaced with full stops.

This.is.an.example.o
f.text.that.will.hav
e.straight.left.and.
right.margins.after.
formatting..........
public class Main {
public static void main ( String args[])

[code]....

View Replies View Related

Dynamic Array With Input

Oct 25, 2014

Create a one dimensional array which holds 10 values. Ask the user to input an index value between 0 and 9. Print the value the user selected. Be sure to explain the output to the user. That is my assignment, and here is my code:

import java.util.Scanner;
public class Array {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a[]= new int[9];
a[0] = 10;
a[1] = 20;

[code]....

I don't know how to use the scanner to get someone's input properly.

View Replies View Related

Fields Won't Hold Value Given Through Input?

Oct 18, 2014

At the end of my main method, I want it to print out the input given that should have been stored in my sandwich class fields, but it didn't.

import java.util.*;
import java.lang.*;
public class SandwichBuilder {
public static void main(String[] args) {
Scanner inputDevice = new Scanner(System.in);

[Code] .....

View Replies View Related

How To Take One Million Of Character As Input

Mar 29, 2014

How To Take 1 Milion's Of Character As A Input

View Replies View Related

Checking If Any Input Has Been Entered

Jan 12, 2015

I just can't find a way to check if user puts any input or not? The line is Employee Name and I need to validate that he puts something there.

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

[Code] ....

View Replies View Related

FILE Input Without Delimiter

Apr 28, 2014

This is my input from my text file: 1|John Jay Smith|1985-01-10|2010-05-10|2014-03-05|212-222-2233..So, I have to convert 1 to integer. Break John Smith into first name as John and Middle name as Jay Last name as Smith.If no middle name is given then first is John and Last is Smith . Read 1985-01-10 as a date value . 2010-05-10 as another date value which could be null. 2014-03-05 as another date value which could be null. and at last 212-222-2233 as phone number.

Scanner sc = new Scanner (inFile);
sc.nextLine();
while (sc.hasNext()){

String row= sc.nextLine();

I want to read this line of input and assign the value accordingly.

View Replies View Related

Cannot End Input Of Data On Program

Apr 25, 2014

Write a program that allows the user to enter students names followed by their test scores and outputs the following information(assume that the maximum nmber of students in the class is 50; if the number of students is less than 50, to indicate the end of input data, after entering the last students data, on a line by itself, hold the ctrl key/press z and then press the Enter key):

a) Class average

b) Names of all the students whose test scores are below the class average, with an appropriate message( youre below class average)

c) Highest test score and the names of all the students having the highest score.

Use methods.

Now I wrote the program but i cant figure out how to end the input by pressing ctrl key/press z and then press the Enter key...

Here is my code

import java.util.Scanner;
 public class ClassAverage {
public static void main(String args[]) {
String names[] = new String[50];

[code]....

View Replies View Related

Calculator That Change Input Value Into Another Value

Nov 14, 2014

I am currently working on a small java programm. I use netbeans for it. And obviously I am new to java.

Basically its a calculator that change the input value into another value: like 10 € into whatever $ and same with Inch and Centimeters.

Therefore I need a second jDialog Form where i can change the factors for the calculator and start the calculator again.

Here is my problem: I can open the second Dialog but if I want to change the factor it doesn't change the value in the variable and the second calculator frame is with the old factors. It seems the double variable isn't working globally

I will add the files later when i find out how?

View Replies View Related







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