• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Adding JList to JScrollPane and adding them to JPanel which is added to JTabbedPane  RSS feed

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have JFrame which is my central window, on it, I added simple JTabbedPane, it will have 4 tabs once I complete it. For now I'm having issues with second tab.

The goal of second tab is when I hit JButton "Requested" or "Scheduled" (action listener fires up), I should see a JScrollPane containing a JList object which contains certain number of (medical) Exam objects where each Exam has its string representation and that string is placed inside JLabel.  Now, the functionality which I require is to select any Exam and after selecting it to hit Cancel button which will cancel selected Exam (programming logic for actual process of canceling exam is completed, I just need GUI) .

I'm having big problems displaying that JScrollPane in JPanel and being able to select Exam.

Any suggestions?






P.S. sorry for some spelling mistakes...
 
Sheriff
Posts: 24374
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you're not adding the JScrollPane to the JPanel until the user presses one of the buttons. I don't recommend doing that because it can lead to things which are maybe the same as your big problems.

If you thought to do that because you don't have the data available until the user presses that button, then I recommend adding the JScrollPane to the JPanel in the initGUI() method, only with no data in the JList. Then when the user clicks the button and you get the data, add the data to the model of the JList.
 
Miljan Puletic
Ranch Hand
Posts: 31
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Paul,

Sorry for replying so late, lectures and all that...Yes, I did what you've proposed and I read little bit of documentation on JList's. Specifically, I used JListModel and it worked.





 
Shiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!