Home » Newcomers » Newcomers » sqLite-stored data can be shown in JTextField but not JTextArea(Almost anything that is displayed in a JTextField can be displayed in a JText Area instead. But there is something different about data from a sqLite DB file. What is messing me up?)
|sqLite-stored data can be shown in JTextField but not JTextArea [message #1786113]
||Wed, 25 April 2018 17:48
| Patrick Moran
Registered: March 2018
According to everything I have read about JTextField and JtextArea, they should both work entirely the same except that JTextField only provides for a single line of text. I have been working on a program from a tutorial by ProgrammingKnowledge because it would be ideal for some autoinstructional materials I want to work on. A single line of text will often not be enough for a single step in the teaching process, so I had hoped that I would be able to replace the tutorial program's JTextFields with JTextAreas. However, after considerable effort I have been unable to manage what looks like a simple job.|
If the following code works reliably, and it does, it seems that its analog ought to work too:
textFieldEID = new JTextField(); //EID means employee identification number
contentPane.add(textFieldEID); //textFieldEID is a data unit produced by
//the DB-reading part of the program.
textFieldEID.setBounds(113, 180, 160, 28);
So, swapping in a JTextArea ought to be easy. The following works if I feed it a String, but not if I feed it a "textFieldEID."
JTextArea txtrEmpID = new JTextArea();
txtrEmpID.setBounds(600, 185, 150, 16);
Working with a String variable I created in a sample file (attached herewith) I did it this way successfully:
String str0 = "with well-aged Cabernet";
txtSjtfield = new JTextField();
txtSjtfield.setText(str0); // set jtFIELD to str0
txtSjtfield.setBounds(261, 156, 170, 26);
JTextArea txtrStr = new JTextArea();
txtrStr.setText(str0); // set jtAREA to str0
txtrStr.setBounds(268, 263, 163, 45);
I made a separate, simple program that takes a string, sends it to a JTextField and then takes the information reference there and sending it to a JTetArea, or vice-versa. I've even pasted code from that little program to the bit program that messes up. The problem is that I'm not using a string anymore. I'm starting with something that has been copied out of a DB in some format that I do not know, and trying to output the information, but nothing happens.
I'll attach the problem Java document and also the short Java document that passes information from JT to JT.
If anybody wants to try to compile the larger one, you'll need to get sqlite-jdbc-3.21. and rs2xnk,jar.
Also, this is an ancestor of the file entered here by Mr. Ream. It kills WindowBuilder, or more precisely, it seems to go into an infinite loop, so you have to force-quit Eclipse.
Many thanks for anyone who can help with this problem.
Current Time: Thu Jun 27 01:55:28 GMT 2019
Powered by FUDForum
. Page generated in 0.03851 seconds