Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 30
Registered: March 2018
Member
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);
textFieldEID.setColumns(10);

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();
//contentPane.add(txtrEmpID);
contentPane.add(textFieldEID);
txtrEmpID.setBounds(600, 185, 150, 16);
txtrEmpID.setColumns(10);

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);
frame.getContentPane().add(txtSjtfield);
txtSjtfield.setColumns(10);

JTextArea txtrStr = new JTextArea();
txtrStr.setText(str0); // set jtAREA to str0
txtrStr.setBounds(268, 263, 163, 45);
frame.getContentPane().add(txtrStr);
txtStr.setColumns(10);

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.
Re: sqLite-stored data can be shown in JTextField but not JTextArea [message #1786125 is a reply to message #1786113] Wed, 25 April 2018 20:14 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3155
Registered: July 2009
Senior Member

Other than it killing Eclipse, there's nothing really specific to Eclipse here. I
see that you do "contentPane.add(textFieldEID)" twice, but really it looks like
the sort of question to take somewhere like StackOverflow or the relevant
JavaRanch forum, https://coderanch.com/f/2/GUI .


Nitin Dahyabhai
Eclipse Web Tools Platform
Re: sqLite-stored data can be shown in JTextField but not JTextArea [message #1786132 is a reply to message #1786125] Wed, 25 April 2018 22:48 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 30
Registered: March 2018
Member
Thanks for looking at this mess. I'm surprised that there weren't more mistakes noticed that need to be cleaned up. I've spent hours trying various ways to get the desired result, so there were bound to be mistakes that I failed to catch. I am, however, not pleased with WindowBuilder's not being able to exit from a failed process without killing Eclipse. I suspect that there may be something like an infinite loop. I learned that programs need to check for processes that go on forever and exit gracefully. I made a mistake working on the shellgame.java that crashed Eclipse and took the xxx.java files out of two projects. Always keep backups, no?

I just sanitized Peter Ream's original (simpler) file. However, starting from the Employeeinformation.java file he provided, I cannot get WindowBuilder to show the buttons, labels, etc. So it produces a GUI that is entirely blank. I thought WindowBuilder was supposed to be good at opening Java files obtained from other places.

Thanks again.
Previous Topic:Need to salvage my code. Does eclipse have cache of currently opened files?
Next Topic:Tomcat times out while attempting to start
Goto Forum:
  


Current Time: Sun May 20 19:49:43 GMT 2018

Powered by FUDForum. Page generated in 0.03463 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top