Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sample maintenance disply

 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have/know of a sample code/program that shows how to display a file's fields on a screen for user editing? I can display the wole file in a text area, but when I tried to switch & use textFIELDS, the wheels fell off. I have to be both stand-alone, & "old java" compatible (ie. no fancy stuff) & can't use a browser(which lets out an applet). The file is a 50-element array, with each element being 7 fields. I'd like to show ONE element on the screen & then just use an up/down button to scroll forward/backward through the file, then write the array back out on the SAVE_button_Click event. (Sorry 'bout the VB slipping out). I've been programming 30+ years & this is my maiden JAVA voyage. It's been fun....so far. ; ) Thanks, -Bill.
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you want to scroll through the 50 elements, pick one from the list, and then edit the 7 items of that one element? Or do you want to be able to edit all 7 items of all 50 elements on the page at one time?
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kim, thanks for the reply. I would like to edit all the fields for a given element on the screen at once. This could be a "child" window if needed, but 3 of the fields are actually Comments & another 3 are 40 byte segments of a single customer display message. Thanks, -Bill.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Bill!
I'm moving this to the Swing / JFC / AWT forum where those GUI folks might have some ideas for you...
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way I've seen this done is to create a panel with two panes:

The top pane is a list of the items in a textbox. Nothing fancy. However, if the user clicks on one of the lines in the text box, the program fills in the fields in the lower half of the pane and enables the [modify] button. If the user hits [modify], the program reads the fields from the text fields, then changes and redisplays the line.
Might this work for you?
Joe
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
Thanks, this would work, but is the top part a textAREA, or a textField? I seem to have a problem with textFields. Areas I can display & they look to be auto-scrolling by definition. Does a click on ANY line return just that line? Sorry for the ignorance, I'm 1/3 way thru my "For Dummies" course.
Also, Does it matter whether I use a pane or a panel? The latter seems to be giving me the former. HA!HA!
Thanks, -Bill.
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill, I'd have to spend a little more time with this to give you definitive answers, but let me try a couple:
1. I think I'd make the top a listbox (JList). That way, the user can click a line and you'll be able to add a listener for that event (addListSelectioneListener).
2. I would use a Panel within a Panel. I would create the outer Panel with a BorderLayout, putting the JList in the NORTH section. Then I would create a new Panel (probably with a GridLayout) for my fields. I would add the second Panel to the first Panel's SOUTH section.
3. Then I would play with the positioning to see what worked best for me.
Joe
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe, Thanks for the ideas. I'm assuming from your statement that I need to clearify something... the user needn't click on any line or field or anything. At the point in time that we're waiting on user input, there are only 3 options -modify (overkey) one of the 3 Message Line fields, scroll up or down to the next of 50 messages, or save/exit. It seems a little bit impractical to have fields in the top pane (your JListbox). Have I helped a bit? Here's what I had in mind...
+----------------------------------------------------------------+
+ Message No. 32 +
+ ================= +
+ +
+ Comment............................... 1 +--------+ +
+ Comment............................... 2 + UP + +
+ Comment............................... 3 +--------+ +
+ +
+ Message Line...........................1 +--------+ +
+ Message Line...........................2 + DOWN + +
+ Message Line 3 +--------+ +
+ +
+----------------------------------------------------------------+
Thanks, -Bill.
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't understand. There are, say, 50 messages, each with three fields? They can scroll through the messages and modify any of the three fields? Is there a list of all the messages and the one they are currently on is highlighted, or are there simply up and down buttons that move them to the next or previous message?
I think you might want to take the time to say, in words, exactly what your data is and what your UI is intended to do. Evidently our mental shorthands aren't on the same frequency .
Joe
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What problem are you having with textfields?
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill Raterink:
Does anyone have/know of a sample code/program that shows how to display a file's fields on a screen for user editing? I can display the wole file in a text area, but when I tried to switch & use textFIELDS, the wheels fell off. I have to be both stand-alone, & "old java" compatible (ie. no fancy stuff) & can't use a browser(which lets out an applet). The file is a 50-element array, with each element being 7 fields. I'd like to show ONE element on the screen & then just use an up/down button to scroll forward/backward through the file, then write the array back out on the SAVE_button_Click event. (Sorry 'bout the VB slipping out). I've been programming 30+ years & this is my maiden JAVA voyage. It's been fun....so far. ; ) Thanks, -Bill.

I already asked about the textfield issue so I will just ask about the other questions I have. What do you mean by stand-alone and old java? The stand-alone taken with your other comments means java application. But what do you mean by old java? What jdk? Are you talking AWT vs Swing?
I would use GridBagLayout with text fields. I personnaly would use next and prev buttons rather than up and down. Are the file and app going to reside on a server?
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case you wanted an example.
 
Bill Raterink
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe, Paul, & All,
Thank you so much for the help. Like I said, this is my first attempt at java & where I thought I had a problem, "screen display", I actually have SEVERAL! I see now,that I need a little more education on the use of different "layouts". Evidently I made some BASIC assumptions & got burned by them. OK, here's the project... There are 50 messages in a flat ASCII editable file, delimited by quotes & crlf's. Each msg "element" is made up of any number of Comments, one Display line, 3 print lines (for receipts). I am limiting the comments to 3, just because I can. The OS is a POS system that currently only supports Java 1, and maybe AWT, but not sure about SWING. This is where the "nothing fancy" constraint comes in. So... I've tried the borderlayout & the card layout. Each one seems to work for some things, but not for others. I'll try the GridBag next (thanks for the sample).
My problem with textfields was, I tried to use them like I did the textArea in the borderlayout, but I couldn't get them "added" to the layout. I think I can see that issue now. Thanks again, I'l try to post more intelligent questions after I get the layouts down. c ya soon, -Bill.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic