GUI JTextField Input Not Storing / Displaying
Oct 21, 2014
I'm trying to get data from a GUI input window into an ArrayList and back out via a JTable. I can get the array lists to print to the console within the input class, but I need to wire it to a data container and out through a different class. Here is code from one input class, and its corresponding output class:
Input:
public class AddClassroom extends JFrame implements java.awt.event.ActionListener {
// UI components
// are declared here...
[code]....
View Replies
ADVERTISEMENT
Mar 2, 2014
I have been stuck on this now for almost a week, the problem is that the textfield keeps flickering. I have read that swing does not work well with fullscreen exclusive mode, but I'm not sure what else to do other than create my own class similar to a textfield and detect every single key press which doesn't seem the right thing to do.
- If this line is uncommented "TextFieldTest.this.tfChatField.paint(g);" then it will display the textfield at the top of the screen, and a flickering textfield at the bottom(which is where it's meant to be)
Java Code:
package textfieldtest;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Graphics;
import java.awt.Graphics2D;
[Code] ....
View Replies
View Related
Jun 29, 2014
How would I display certain output text if the text entered equaled "text".
So lets say you enter a question into a JTextField. You press a button that submits the text. The output displayed depends on what the question you asked was.
Think about it as "If question = What color is the sky? On submit, display text "Blue". How to implement this.
View Replies
View Related
Jan 20, 2015
I am having trouble with getting a user input once they enter it in to a JTextArea and then storing it in to a string value. See, I wanted the user to enter an answer in to the JTextArea, and then once I store it in to a string value, I would be able to use it later. I wanted to after storing the variable to print it on to a JLabel, but nothing is showing up... Heres my code.
static String usera[]= new String [10];
for (int i=0; i< usera.length; i++) {
//These are the JTextArea names
usera[0]= Question1.getText();
usera[1]= Question2.getText();
[Code].....
I already initialized the JLabels earlier in my code, and I did not feel the need to post all my code here. This is where I am trying to get the string variable and then printing it out.
View Replies
View Related
Sep 13, 2014
I need to get users input from jtextfield and set it to JTable. This is my code:
public class Projektni extends JFrame {
public final JTextField ime = new JTextField(10);
public final JTextField prezime = new JTextField(10);
public final JTextField index = new JTextField(10);
public DefaultListModel podaci = new DefaultListModel();
JButton imeB=new JButton("Upisi u tabelu");
[Code] ....
View Replies
View Related
Jul 5, 2014
I have a GUI with a JTextField. I need to check that the input entered by the user is made up of only integers.
For example I accept: 1, 10, 530, ...
I do not accept: -10, 1.5, -6 ...
I would like to implement this control by using a regular expression so I would have a code like that.
JTextField text = new JTextField();
String input = text.getText();
boolean bool = checkInteger(input);
if(bool)
System.out.println("Ok");
else
System.out.println("Error");
The checkInteger(String input) method should check if the input string is correct or not.
How can I do to implement this control with regular expressions?
Is there an easier way to do it?
View Replies
View Related
May 7, 2014
My problem is that in my program, I have the user input data for one of three product objects, however when I read the data for all three objects, the same data is stored in all of them.
Anyway this is the method from the Interface class:
private void readInput() // the only method in the program that accepts product data from the user {
Store matesStore = new Store();
String name;
int demandRate, productChoice;
double setupCost, unitCost, inventoryCost, sellingPrice;
Scanner console = new Scanner(System.in);
[Code] ....
And here is the method from the Store class:
public static void addData(int option, String newName, int newDemand, double newSetup, double newUnit, double newInventory, double newPrice)
//sets the product data for a particular product {
if (option==1) setData(product1, newName, newDemand, newSetup, newUnit, newInventory, newPrice);
else if (option==2) setData(product2, newName, newDemand, newSetup, newUnit, newInventory, newPrice);
else /*(option==3)*/ setData(product3, newName, newDemand, newSetup, newUnit, newInventory, newPrice);
[Code] ....
The problem I had was with static variables and methods.
View Replies
View Related
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
Dec 4, 2014
I am trying to populate a JTable using Several JTextFeild a JComboBox and a JLabel.
The textfields are originalPrice and itemName
JComboBox is departmentComboBox
label is salePriceLable.
When hitting the button i need the program to calculate the price after discount and add the item name, department, original price, and discounted price to a table. I have the calculation down, but am lost on populating the table.I used NetBeans 8.2
/*
* Program: JavaRetailCalculator
* Purpose: To calculate the ammount of a discount and display results in a Table
*/
import java.awt.*;
import javax.swing.*;
public class CalculatorFrame extends javax.swing.JFrame {
/**
* Creates new form CalculatorFrame
*/
public CalculatorFrame() {
initComponents();
[Code] .....
View Replies
View Related
Jul 8, 2014
I am trying to make a program that calculates the change due in dollars and cents. The user inputs both the amount due and the amount tendered. My program only works with whole numbers?
View Replies
View Related
Sep 13, 2014
I have project to get from users input like name,surname,to save to Jtable,i have table and jtextfiled but when user get input they don t save to table here is my code:
Project.zip (33.54K)
public class Projektni extends JFrame {
public final JTextField ime = new JTextField(10);
public final JTextField prezime = new JTextField(10);
public final JTextField index = new JTextField(10);
public DefaultListModel podaci = new DefaultListModel();
public JList lista = new JList(podaci);
String kolone[] = {"ID","Name","Age"};
[Code] ....
View Replies
View Related
Sep 16, 2014
I am required to read user input to create two matrices which will eventually be added together. I am unsure as to how I can read the input from the user as an int and not a String. The input is from size 0-10 for both column and row size. Also, can you have a new button created in the actionPerformed method of a previous button?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Matrices implements ActionListener {
private JFrame win1, win2, win3, win4;
[Code]...
View Replies
View Related
Jan 29, 2014
I have been creating a Java program to track inventory using an array. I need to add a search function to it to take a term, input through a text field, and locate a matching instance within the array. How can I code a JButton to grab test input from a JTextField and search for it within the array then display the corresponding information? I also need to add buttons to add and delete items as well.
View Replies
View Related
Mar 10, 2015
I am trying to get through JSF /PF tag for h:inputSecret but its not taking or displaying value. Please see the code snippet below
demo.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
[code]....
I am using JSF 2.2.
View Replies
View Related
Sep 13, 2014
I'm working a an assignment for my IT/215 class and I'm having a little trouble with my arrays. My code compiles just fine but when it comes to displaying the information I've input into my array it doesn't seem to want to and I'm not sure what I'm doing wrong here. On line 136 originally I had [DVDs [count] = count+1]] but it wouldn't compile. I then put line 136 to [ DVDs[count] = new Inventory();] and I think that's were my issue is but I'm not sure....
// Purpose:the purpose of this software is to display inputs as wells as the stocks and price of inputs.
class Inventory
{
private double ItemNumber; //to store Item number
private String ItemName; //to store Item name
private double UnitsInStock; //to store number of units in stock
private double UnitPrice; //to store Unit price
private double InventoryValue; //to store Inventory value
private double TotalInventory; //to store Total Inventory value
[Code] .....
View Replies
View Related
Apr 5, 2014
I have written some error checking code
File name ErrorPage.jsp
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Error</title>
</head>
[code]...
I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .
View Replies
View Related
Sep 24, 2014
One of the requirements of my programming assignment is that a user enters a command along with two numbers. For example, if I entered the following command:
I 5 6
The program create an image like this (it wouldn't be outputted though):
00000
00000
00000
00000
00000
00000
It creates a 5 x 6 "image". This is where my troubles begin. The program should also accepts other commands, such as:
L 3 2 F
which would produce (also not outputted):
00000
00F00
00000
00000
00000
00000
Here is my method for creating an "image" with an M * N array
for (int i = 0; i < column; i++) {
for (int j = 0; j < row; j++) {
System.out.print("0");
} System.out.println();
}
The code works, but I need to store the image in an array so it can be changed by other methods (I can't create the image manually every time). I tried doing something like this but it doesn't work:
public static String[][] createImage(int row, int column) {
String[][] image = new String[row][column];
for (int i = 0; i < column; i++) {
for (int j = 0; j < row; j++) {
image[j][i] = "0";
} System.out.println();
} return image;
}
This method outputs as many blank lines as the columns I entered and the memory location of image.
So my question is: how would I store "0" in a 2D array so that it can be accessed and changed by other methods?Or, am I using a 2D array incorrectly and will the image have to be created manually every time? If so, how would I output image if it is created in a separate method?
View Replies
View Related
Aug 6, 2014
I am storing out of range values in int and byte type
public class OverflowDemo {
public static void main(String args[]) {
int value = 2147483647 + 10;
System.out.println(value);
byte b=127+10;
System.out.println(b);
}
}
Program will give error for only byte type as OverflowDemo.java:8: error: possible loss of precision
byte b=127+1; ^
required: byte
found: int
So why not for Integer?
View Replies
View Related
Apr 1, 2014
how can i store biginteger in an array?
View Replies
View Related
Oct 9, 2014
I trying to write a piece of code which takes a set of numbers or even data type and stores in an array (or something more suitable).
For example:
Date N1 N2 N3 N4 N5 Day
10/11/2012 10 09 32 100 15 Thursday
11/12/2013 01 0 0 23 50 51 Tuesday
I'd like to be able to sort them so that if I want to search for one of the entries, I can then create a function which allows me to sort them by date or even return all the numbers by a given date or day, etc....
However, I'd like to be able to set it up so that each set is "linked" meaning that again that I can search by date and it returns everything at that date.
I wanted to use an array but I don't know:
-How to do it?
-Whether this is a suitable approach?
View Replies
View Related
Dec 3, 2014
I have the following method that I need to implement:
{
// YOUR CODE HERE
File file = new File(filename);
int counter = 0;
String tempArtist, tempName;
Album tempAlbum;
Track tempTrack;
[code]....
Ok so I updated my code from the initial post since I made some progress on my own. I guess now I'm just stuck on how to scan in the file of strings and stock it into the type Track. (I've tried using both the initial linked list for this and a temporary variable with no luck).
View Replies
View Related
Mar 26, 2014
I've the following requirement. A centralized server needs to be established using java code. The server's responsibility is receiving the status of the each client machine as a XML file and storing it in the server's disk space. The client machine also runs the java code to send the status to the server as an XML file in a daily basis. I've planned to create a SOAP webservice in server machine and client machine will invoke the soap webservice to send the status. Do I have to establish any FTP server for storing the XML files? Is there any other better solution for this requirement?
Do I have to establish any FTP server for storing the XML files?
View Replies
View Related
May 20, 2014
Write a complete Student class that allows you to use the statements such as the following in methods in outside classes, with the obvious meanings. Then write an application program that creates one student object, reads in test grades until a negative "grade" is seen (as a signal that the list of grades has ended), then prints out all available information about the Student:
Student bob = new Student ("Robert", "Newhart");
bob.storeGrade (23); // bob scored 23 on this test
return bob.getTotalGrades();; // total of test scores to date
return bob.getAverageGrade();; // for all test scores to date
return bob.getName();; // returns "Robert Newhart"
What I need is in the Student class... I'm not sure how to go about storing the grades without renewing the value of storeGrade (I'm sure what I have right now is incorrect, but I'm stuck). This is what I have so far, as you can see I left some of the grade-related bits blank for now, but all I want to know is how I can store the grades:
Java Code:
public class Student extends Object
{
private int itsTotalGrades;
private int itsAverageGrades;
private String itsFirstName;
private String itsLastName;
private int storeGrade;
public Student (String first, String last)
[Code] ....
View Replies
View Related
Jun 10, 2014
I am building an app, where I have to store the data eg: "hello ! how are you" in java as a string and then use scanner to get input and check if the entered word is present in the line stored. If it is stored then the entire sentence must be displayed. eg : if the stored string is "hello how are you"
if the entered string is "how", then the entire sentence "hello how are you" should be displayed.
View Replies
View Related
Jul 29, 2014
I need to store the data of a bunch of objects of a particular class in files in a predefined directory. Later, I want to get all the files from the directory and turn them into the objects again. Ideally, I'd like to have one file per object and have the files be human-readable and editable without too much difficulty. The class used by the objects will likely be subject to change in the future, as well. To keep things simple, all the data members are either primitives, Strings, or arrays of them. What is the best library/API to use to deal with this situation? Or should I write my own classes for these operations?
I read into serialization, but I read that it doesn't deal well with classes that are frequently modified. I also found articles on Preferences, but none of the ones I saw seem to explain how to best handle reading and writing to and from multiple objects, especially when I don't know a prior all the objects that were written to disk.
View Replies
View Related
Mar 31, 2014
How can I store a value in long type variable whose range is greater than int type variable ....
View Replies
View Related