Swing/AWT/SWT :: How To Get Data From JTextField Over To JTable

Jun 20, 2014

I am trying to get the data entered in a JTextField into a JTable but not clear on how. The LeftPanel is where the button is located and the RightPanel is where the JTable is. I want the actionPerformed to update the row of the JTable but I can't figure out how. There is another class that controls the GUI but did not think it was necessary to include. Also, I am aware that I am getting an error at the addRow line, can't seem to alleviate it.

public class LeftPanel extends JPanel {

private static final long serialVersionUID = -2311952438693382407L;
private RightPanel rPanel;
public LeftPanel(){
Dimension size = getPreferredSize();
size.width = 250;
setPreferredSize(size);

[code]....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: How To Populate All Items In JTable When Corresponding JTextfield Is Empty

Aug 3, 2014

I am designing a advanced search option in a java project with sqlite in NetBeans. there are 5 different JTextfields and 5 columns, I want to populate JTable with corresponding matching criteria. If a JTextfield is empty then it should select all items of that column.

query i was using is:
String val1=txt_billing2.getText(); //five input fields
String val2=txt_station2.getText();
String val3=txt_invoice2.getText();
String val4=txt_amonth2.getText();
String val5=txt_umonth2.getText();

[code]....

but when i leave a JTextfield empty it shows no data in JTable. only method i know is to use if else conditions but that generates 5!= 120 conditions!!!

View Replies View Related

Swing/AWT/SWT :: Refreshing Data In A JTable?

Apr 24, 2014

I have been trying to learn a bit about JTables for a project I want to undertake. I have created a new JFrame in netbeans and added a button. Onclicking the button I want add some data to a JTable model and then output the JTable with the data. When I click the button again I want the same process to happen again and overwrite the previous table being displayed.

I have written the following code below:

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

[code].....

The problem I have is that when I click the button for a second time the table stays on the screen exactly as it did following the first click. I can see that the data in the model is changing so I am not sure why a new JTable is not drawn.

View Replies View Related

Swing/AWT/SWT :: Saving And Loading Data Of Jtable

Apr 6, 2015

I am trying to make a program where a user can enter guests name for a hotel, the JTable includes rows for the name of the tenant, the room number, month etc.

I've made the table, however I am having some trouble in saving the data that I put into the table. I used jtextfield and a jbutton to but data into the jtable. I am trying to save the data, and load it just buy clicking a button.

table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Room", "Name", "Month", "Payment"//table rows
}
));

This is my basic table. And what I'm trying to do to save the data is:

DefaultTableModel model = new DefaultTableModel();
private JFileChooser myJFileChooser = new JFileChooser(new File("."));
private void saveTable() {
if (myJFileChooser.showSaveDialog(null) ==
JFileChooser.APPROVE_OPTION ) {
saveTable(myJFileChooser.getSelectedFile());

[Code] ....

When I run my program, I'm able to click on a button, and the dialog box will appear, I'm also able to save the data to a file. However when I click on the retieve data button I made the dialog box opens, the file is there, however when I click it, nothing happens.

View Replies View Related

Swing/AWT/SWT :: JTable - How To Repaint With Updated Data

Jun 5, 2014

Here's what I would like to happen:

Java/Swing dialog box appears on the user's screenIt allows the user to enter 2 values into labelled text fields (fname/sname)They select a "Click Me" push button which I hope will write the data into the table. But the table does not get refreshed.

If I minimise the dialog box and then open it again, the data still does not appear.

The code I originally built using eclipse/WindowBuilder. I've cut it back and tried to isolate the issue. But I still cannot figure it out.

I've added some diagnostic log messages to ensure that I am seeing the various events I think I need to see and have put code in the action callbacks etc.

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: How To Display Hugeclob Data On JTable

Feb 26, 2015

I was trying to run an sql query to display onto my jtable. However, i got this as a result:

oracle.sql.CLOB@11876a2

When I run the same SQL query on Toad i get the field hugeclob and one is then able to see whats inside the field. I want to basically either have a hugeclob on my jtable or perhaps to display on a textarea the data

View Replies View Related

Swing/AWT/SWT :: Copy Selected Data From JTable Cell To Clipboard

Feb 18, 2014

I have a jtable that I would like to copy from a cell that I select to clipboard. How could I do these.

View Replies View Related

Swing/AWT/SWT :: Sort JTable Data On Year Between A Range Of Years?

Jan 16, 2014

i have a JTable with data that contains a column with Years.

I want to get the user to be able to sort the data between a range of two years.

Example:

a user sets te filter so he/she can view all the data between the years 1990 and 2000.

I am a beginner in Java and don't know how to code such a filter.

I guess it will be something with an if/Else statement or a loop?

View Replies View Related

Get User Input From JTextField And Set It To JTable

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

Populate JTable With Input From JTextField And JComboBox

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

JTextfield And Jtable - Get Users Input From Field To Table

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

Swing/AWT/SWT :: Autocomplete In JTextField

Apr 2, 2014

I have been reading several suggested solutions for implementing autocomplete for a JTextField. However, the documentation is a bit confusing to me. It seems like they mostly require switching to a JComboBox. Can I or can I not continue to use a JTextField and implement an autocomplete feature? I also saw what I thought was a built-in autocomplete "decorator" for swing objects (although it was not clear if it can be used for JTextField) but most of the implementations seem to start from scratch. Any simplest way to implement this (assuming those 2 conditions are not mutually exclusive)?

View Replies View Related

Swing/AWT/SWT :: Inputting One Letter Into JTextField

Mar 9, 2014

I'm writing a java program in eclipse of a tic-tac-toe game. I have to create it using JTextField's only I'm having trouble where the JTextField will only accept one letter and will only accept X and O is there any particular way to do this I started off with this piece of code

String text=tf1.getText();
if(text.length()>1) {
System.out.println("this is not allowed");
tf1.setText("");

But it doesn't work so is there something I'm missing....

View Replies View Related

Swing/AWT/SWT :: How To Make JTextField Editable

Jul 10, 2014

I'm having a hard time finding out the way to make JTextField editable. In what circumstances it can be disabled to write? [even the text in the field can't be selected, not to mention being uneditable. I did the followings to make it editable.

1. In its Properties panel(frame or whatever), checked the "editable" item.
2. In the code I made it run the code below :

void makeFieldsEditable(Boolean flag) {
Left_Name_field.setEditable(flag);
Left_Name_field.setEnabled(flag);
...
}

Is it related with the properties of the control(JTextField)'s surrounding panel, or even the largest containing frame? Using Netbeans ....

View Replies View Related

Swing/AWT/SWT :: How To Get One Value From JTextField To Show In Another Classes

May 17, 2014

I want the text that the user inputs into the JTextField in the user input panel to be what shows up in the JTextField in the totals panel.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import javax.swing.*;
import javax.swing.border.TitledBorder;

[Code] ......

I know that I will need to take advantage of the get and set methods, could I get an example of this? How to write the code.

View Replies View Related

Swing/AWT/SWT :: Unwanted Echo Of JTextField

Oct 29, 2014

I recently began writing a much larger program than I will show. I have boiled the problem down to this SSCCE.

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
class TextButton extends JRadioButton

[Code] ....

What i wanted was a JRadioButton with no label carrying around a JTextField. When I added a restore configuration feature in the real program, i found that the text destined for the JTextField was being echoed into the JRadioButton.

Perhaps it is obvious but i sure don't see what I am doing wrong. I am using Java 1.7.0 for development if that makes a difference.

View Replies View Related

Swing/AWT/SWT :: How To Get Text From Jtextfield And Transfer It Between Classes

Apr 8, 2014

Im writing a program that records the score in a dart game. One component of the program is a stage where players enter their name.This information needs to be displayed in another part of the program. These two components are in two different classes. My problem is I dont know how to get that information from one class to another.

Im using Jtextfield in Jframe to record the information.

View Replies View Related

Swing/AWT/SWT :: JTextField Automatically Highlighting Current Values

Mar 10, 2014

I want to have JTextField automatically highlighting the current values for overwriting when the box is selected. Is there a way to do this? It seems like something that might occur in an action listener.

View Replies View Related

Swing/AWT/SWT :: Adding Items To JComboBox Taken From JTextField Listener

Nov 11, 2014

I need to take the value of what's typed in my JTextField, and once the submit button is clicked, I want to add that string to my JComboBox list items.

Depending which RadioButton they selected, I need to put the team in HOME or AWAY teams, and so on and so on, until they continue clicking submit.

View Replies View Related

Swing/AWT/SWT :: JTextField Size Changes With JLabel Text Length

Nov 11, 2014

I want to create 3 JTextFields in a row with all being of equal size.But my first Text field gets so wide than the other two.After adding each component at a time and seeing what causes the problem I realized that if I type a long text for the JLabel that's when this problem occurs.If I reduce the length of the text in the JLabel JTextFields get into the sizes I want. Here's my code

import java.awt.*;
import java.awt.event.*;
import java.lang.Math;
public class Calculator1 extends JFrame {
JTextField value1=new JTextField("0");
JTextField value2=new JTextField("0");

[Code] ....

How can I stop the JTextFields changing size when I change the JLabel label1's text length...

View Replies View Related

Swing/AWT/SWT :: Add JTextField And Additional Output Within ComponentEvent Handlers

Jan 30, 2014

Using the code from the Java Docs (listed below) I am getting behavior that was a bit unexpected. The only changes were to add JTextField and additional output within the ComponentEvent handlers. Run the code and when the frame appears, think of each side as North, South, East (right side) and West (left side) as you are looking at it. This was run using JDK 1.7.0_25.

Run the code.

1 - Click the East edge (right) of the frame and drag to be wider or more narrow. Only the "Resized" is executed for all components which makes sense.

2 - Click the West edge (left) of the frame and drag to be wider or more narrow. This time "Resized" is executed for all components EXCEPT it is "Moved" for JFrame. Why is it "Moved" here for JFrame but not in Step 1?

3 - Click the South edge (bottom) of the frame and drag to be taller or shorter. This time only 2 components are affected. JPanel is "Moved" while JFrame is "Resized".Why isn't both JFrame and JPanel just "Resized"?

4 - Click the North edge (top) of the frame and drag to be taller or shorter. This time only 2 components are affected again but the output is slightly different. JPanel is "Moved" while JFrame is BOTH "Resized" and "Moved".

There just doesn't seem to be consistency here. What are the guidelines or criteria for when these Events are to be executed?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ComponentEventDemo extends JPanel
implements ComponentListener,
ItemListener {

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Make JLabel Hyperlink Change Depending On JTextField

Jul 30, 2014

This is a part of my program. When the user enters "Exam Schedule" in the JtextField and clicks the add button I want the link to change to a link that opens a local pdf file. And if the user enters "Academic Calendar" the Jlabel will be set to another link. So far this works fine but the problem is that if you erase the textfield and enter another value the link of the previous value will still be there.

public void actionPerformed (ActionEvent e){
if (e.getSource ==add) {
if (text.getText().equalsIgnoreCase("Exam Schedule")){
link1.setText(text.getText());
link1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

[Code] .....

View Replies View Related

Using Jtextfield On Jframe (Swing) To Enter Search Terms In Different Class

Dec 4, 2014

I have a swing jFrame set up with a control group which contains 3 radio buttons.

When one is clicked it sends its label to a jtextfield in a different class i have code parsing text by a term

Java Code:

Scanner s = null;
try {
s = new Scanner(new BufferedReader(new FileReader("/Stage_One.txt")));
s.useDelimiter("*");
String total = (s.next());
Pattern p = Pattern.compile("[]+");

[Code] ....

I just need to know how to access the jframe variables (textfields, panels and such) so i can use their inputs in code to filter a text file.

View Replies View Related

Cannot Show SQL Data In JTable?

Feb 27, 2014

I'm trying to display the data from database in a jtable by following the jtable demo example in Java Tutorials Sample Code; but, I couldn't output the data to the jtable. The following code is what I've done so far.
 
import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;
public class Patient { static String szJdbcURL = "jdbc:oracle:thin:@129.78.110.188:1521:MyDB";                
static String szUser = "...";                
static String szPasswd = "...";                
static String szModelName = "...";

[Code] .....

View Replies View Related

Capturing User Data Through JTable

Jan 1, 2015

I am developing a quotation generator application using Java. I am using a JTable to capture user input(this input is taken from a database i.e. each cell of the tale will have a combobox where the user can select an input value). when the user is done he/she has to print the quotation as A4 page.

My issue is: Is there a way of doing it besides using the JTable?

View Replies View Related

Swing/AWT/SWT :: Error At Class Name - Type JTextField Must Implement Inherited Abstract Method

Oct 27, 2014

This code is directly from Swing: I'm using Eclipse and keep getting an error on line 10 saying :

"The type JTextField must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)."

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

[Code] ......

View Replies View Related







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