• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Help needed to assign a study from arraylist to student arraylist

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:

Iwan van den Hoek wrote:In Student administration I have 2 Arraylists one for students and one for Study's and courses. A student can be a RegulierStudent with a study or a scholer with a course, but not both.
I have to add a student based on the textfield in the Gui to the studenten ArrayList and check the already filled opleidingen Arraylist for the Study based on the selected String value in the pulldown menu from the Jcombobox.
if the chosen String value corresponds with a Value in the opleidingen ArrayList I want to add the student with that particular study/course to the studenten Arraylist.


In pseudo code (is this correct?)



Hi Carey,

Yes that is what I mean in pseudo code

I was just trying to this and that doesn't work

 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:In the opleiding combo box you're putting:

But in the opleidingen you're putting:

This is the problem with using Strings the way you are. You should be using an enum.



Hi Knute,

I did try to use Enum in the beginning but the teacher said that it is not best way to go about it. As I am new to it I took is answer for granted.
If you think it is better to use Enum and make it work I would be happy try it.
One thing I learned is that there is not one good design but different designs that can work.

So if you have an Idea on how to do it I would love to know about it.
 
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Iwan,

Sorry for stepping in late, but then again: you are already being helped by some of the best around here, so no need for me.

I too do not think that enums are handy in this case. The collection of "Opleidingen/Studies/CPPs/et cetera" is probably not some static thing that never changes.
But that is not my main point. And that is:

Can you answer Liutauras latest reply? About the what and not the how? Reading this topic sofar I am, like Liutauras, very much puzzled by all these RegulierStudents and Scholers doing either courses, CPP's, Opleidingen, Studies, and there is this administration that I do not quite understand. Is there a difference between say "SoftwareAcrchitect" (seems like a profession) and "Java" (is not a profession)?

Greetings,
Piet
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:No no, wait. That is the problem. You're telling how you need to do it without knowing what you need to do. Don't use any Java terms, we're not interested in those - we know some ourselves.
Don't tell anything about the GUI, problem most likely is not there. Don't even use your variable names in explanation, these could be not accurately chosen and they are in other language.

Iwan van den Hoek wrote:A student can be a RegulierStudent with a study or a scholer with a course, but not both.

Not sure understood that. Is regular student the one who enrolled to a full study programme, and the other type is the one who only enrolled to a one particular module to study?

Elaborate and expand more the quote below, this one is the way closer to what we want to hear from you.

Iwan van den Hoek wrote:... I want to create a new Student with the selected study...


Before you tell us in non technical language what is the exact task, please read tutorials StopCoding and WhatNotHow.

Note: The way you tried to solve this exercise, gave you the result you have now, if you're going to continue solving that way, the result going to be the same. So read those tutorials, and describe the task in plain english (in details, but without technical terminology).



Hi Liutauras,

Sorry for responding later. I went through the tutorials.

Here is what I want:
I want a program that can add a new student with a study , when it follows a complete education. Then add points to the student and when he has reached the amount of points needed (200 or 160) see if he has passed. Points can be added with 10.5 for example.
When the student is only following a course, I want to add the student with the chosen course which consists of modules that can be achieved. Then add a module to the student and when he has reached the needed modules (6, 4, 3) see if has passed the course.
I also want to see the info of the student when I have added the points or module, so I can see how much points or modules the student has and for which study/course.
I also want to be able to ask all the info of every student, where it shows the name, study/course and achieved points/modules and if he has passed.

The name of the student is new and the study's and courses are already set with the amount of points/modules:
Study (Opleiding):
Wiskunde has 160 points
Informatica has 200 points
Courses (CPP) :
Java has 6 modules
SoftwareArchitect has 4 modules
SysteemOntwikkelaar has 3 modules


I hope this clarify's it beter.

P.s. Piet I noticed you are from Holland, if you like I can send you the Assingment (in Dutch) we got, where it is explaind in full what we need to do.
 
Piet Souris
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Iwan,

indeed I am from Holland. Can you put that assignment here in this topic? We can translate all that's necessary, if someone asks for it.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:hi Iwan,

indeed I am from Holland. Can you put that assignment here in this topic? We can translate all that's necessary, if someone asks for it.



Here is the assingment:
Een eenvoudige studentenadministratie
In deze opgave maken we een applicatie die gebruik maakt van zelf
ontworpen klassen waarbij overerving en dynamische binding centraal
staan.
Een studentenadministratie beheert studenten. Een student kan een
reguliere student of een deelnemer aan een scholingstraject (scholer) zijn.
Van een reguliere student wordt de opleiding vastgelegd waarbij deze is
ingeschreven, van een scholer het CPP. We gaan ervan uit dat reguliere
studenten en scholers gescheiden groepen zijn, dat wil zeggen een
scholer is geen reguliere student en een reguliere student is geen scholer.
Er zijn twee opleidingen, namelijk Informatica en Wiskunde.
Er zijn drie CPP’s, namelijk CPP Java, CPP Softwarearchitect en CPP
Systeemontwikkelaar.
We maken een applicatie voor het invoeren en tonen van studenten met
de volgende mogelijkheden en randvoorwaarden:
– Van alle studenten wordt de naam ingevoerd en vastgelegd.
– Van reguliere studenten worden de opleiding waarbij ze staan
ingeschreven en het aantal behaalde studiepunten vastgelegd. Hoewel de
volledige opleiding uit een geheel aantal studiepunten bestaat, kan er per
keer ook een gebroken aantal punten behaald worden (bij de OU zijn er
vakken van bijvoorbeeld 4.3 studiepunten). Het aantal behaalde
studiepunten is dus een gebroken getal.
– Van scholers wordt het CPP en het aantal behaalde modules
vastgelegd. Dit laatste is een geheel getal.
– Van iedere opleiding wordt de naam en het totaal aantal studiepunten
vastgelegd: Wiskunde 160, Informatica 200. Dit totaal is altijd een geheel
getal.
– Van ieder CPP wordt de naam en het aantal modules waaruit het CPP
bestaat vastgelegd. (Het CPP Java bestaat uit 6 modules, het CPP
Softwarearchitect uit 4 en het CPP Systeemontwikkelaar uit 3)
– Het systeem moet de mogelijkheid hebben de gegevens van alle
studenten te tonen: naam, opleiding of CPP, aantal behaalde modules of
studiepunten en of de student geslaagd is.
Aanwijzingen
Het gaat in deze opdracht om een goed gebruik van overerving en
dynamische binding. De applicatie hoeft niet robuust te zijn; er hoeft
bijvoorbeeld niet na te gaan of invoervelden leeg zijn, en of
studentnamen uniek zijn, etc.
Als bouwsteen krijgt je een klasse StudentAdminFrame die de grafische
interface voor de studentadministratie vormt. De volgende figuren tonen
de verschillende delen van de user interface en nog enkele extra
aanwijzingen voor de gewenste functionaliteit.

Nieuwe student
Tabblad nieuwe student dient om een nieuwe reguliere student te
kunnen invoeren. Om het niet te ingewikkeld te maken, worden alleen
achternamen ingevoerd.
Na klikken op de knop Voeg student toe wordt in dit geval een nieuwe
student Jansen met opleiding Informatica toegevoegd aan de studenten.
De combobox bevat alle reguliere opleidingen waaruit gekozen kan
worden.
In deze niet‐robuuste versie hoeft niet gecontroleerd of de student al
bestaat en mag dus een eerder toegevoegde student of scholer
overschreven worden.

2 Nieuwe scholer
Het tweede tabblad dient om een nieuwe scholer in te voeren.

De functionaliteit is gelijk aan die van nieuwe student maar nu wordt een
scholer met zijn bijbehorende CPP‐opleiding toegevoegd aan de
studenten.

3 Studentinfo
Op het derde tabblad wordt informatie over een student getoond en kan
worden aangegeven dat deze een onderdeel van de studie heeft behaald.
Als de naam van een student ingevoerd is en op enter is gedrukt,
verschijnt de informatie van de student onderin het scherm. Deze
informatie bestaat uit de naam, de naam van de opleiding of van het
CPP, de behaalde studiepunten of het aantal behaalde modules en of een
student al dan niet geslaagd is.
Ook kan met dit scherm het aantal studiepunten (door aantal punten op
te geven in tekstveld, gevolgd door enter) of het aantal modules (door op
knop te drukken wordt het aantal modules met één verhoogd) van de
student worden verhoogd. Wanneer dat wordt gedaan, dan moet ook
weer de meest actuele informatie van de student worden getoond.
Hierbij mag de operatie alleen slagen wanneer deze bij het type student
hoort (in deze niet‐robuuste versie mag een verkeerde operatie eventueel
wel tot een exception leiden).

Alle studenten
Het vierde tabblad toont, bij een druk op de knop, de gegevens van alle
studenten. Voor iedere student wordt dezelfde informatie getoond als op
het vorige tabblad: naam, de naam van de opleiding of van het CPP, de
behaalde studiepunten of het aantal behaalde modules en of een student
al dan niet geslaagd is.
 
Bartender
Posts: 7298
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Google Translate:

Here is the assingment:

A simple student administration

In this exercise we create an application that uses self designed
classes with inheritance and dynamic binding central stand.
A student administration manages students. Students may obtain a
regular student or a participant in a training program (scholer) are.
A regular student training is recorded in which it is
registered, a scholer the CPP. We assume that mainstream
students and scholers are separate groups, i.e., a
scholer is not a regular student and a regular student is not scholer.
There are two programs, namely Computer Science and Mathematics.
There are three CPP, namely CPP Java Software Architect CPP and CPP
System Developer.
We make an application for entering and displaying students
the following features and conditions:
- Of all the student's name is entered and recorded.
- From regular students the education to which they are
registered and the number of earned credits recorded. Although the
full program consists of a set number of credits, there may be a
times are also achieved a broken number of points (at the OU are
boxes, for example, 4.3 credits). The number obtained
study is thus a fractional number.
- From scholers, the CPP and the number of modules achieved
recorded. The latter is an integer.
- For each program, the name and the total number of credits
recorded: 160 Mathematics, Computer Science 200. This total is always a whole
number.
- From each CPP to the name and the number of modules from which the CPP
recorded exists. (The CPP Java consists of 6 modules, CPP
Software Architect 4 and the CPP System Developer from 3)
- The system shall have the details of all
to show students: name, training or CPP, some earned modules or
credits and whether the student has passed.
instructions
It is in this command a good use of inheritance and
dynamic binding. The application does not need to be robust; there is no need
For example, not to determine whether input fields are empty, and whether
Student names are unique, etc.
As a building block you get a class Student Admin frame which graphic
interface is for the student administration. The following figures show
the different parts of the user interface and some additional
instructions for the desired functionality.

new student
Tab, new student needs to a new regular student
can enter. In order not to make it too complex, only
introduced surnames.
After clicking the button Add a new student in this case
student Jansen Science program added to the students.
The combo box contains all the regular courses which can selected
be.
do not check in this non-rugged version whether the student
Thus, there may a previously added student or scholer
be overwritten.

2 New scholer
The second tab is used to enter a new scholer.

The functionality is similar to that of a new student, but is now a
scholer with its associated CPP-training added to the
students.

3 Student Info
The third tab displays information about a student and can
indicate that this has achieved a part of the study.
If the name of a student is introduced and pressed enter,
displays the information of the student at the bottom. This
information includes the name, the name of the program or the
CPP, the credits earned or number of modules and achieved or
student has not passed.
Also on this screen, the number of credits (by number of points
enter text field, followed by enter) or the number of modules (due to
button, the number of modules is increased by one) of the
Students are increased. When that is done, it must also
again displayed the latest information from the student.
This operation can only succeed if it with the type of student
belongs (in this non-rugged version a wrong operation may possibly
lead to an exception).

all students
The fourth tab shows, at the press of a button, the data of all
students. For every student the same information as shown on
the previous tab: name, the name of the program or the CPP, the
credits earned or number of modules achieved and whether a student
or is not successful.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:From Google Translate:

Here is the assingment:

.



Thank you Carey,

I posted the Dutch one for Piet.
 
Carey Brown
Bartender
Posts: 7298
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:Please don't quote huge blocks of text if you can help it.


You are absolutly right. Didn't think it through. I have edited the post.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:Out of curiosity, what does CPP mean/stand for ?


Hi Carey

It means certified professional program.
 
Piet Souris
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Iwan,

Well, the assignment is there, and I hope that Google's work is good enough for those poor ones who do not speak Dutch! Important is that it is about inheritance and dynamic binding.

A question: now that your NPE is solved, are you satisfied with what you have so far? Does it fullfill the assignment? And that is apart from the GUI, just the classes and the interfaces concerning the Studies and the Students (and the administration, of course).
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:hi Iwan,

Well, the assignment is there, and I hope that Google's work is good enough for those poor ones who do not speak Dutch! Important is that it is about inheritance and dynamic binding.

A question: now that your NPE is solved, are you satisfied with what you have so far? Does it fullfill the assignment? And that is apart from the GUI, just the classes and the interfaces concerning the Studies and the Students (and the administration, of course).



Hi Piet,

Unfortnately I am stumbeling on a new Nullpointer exception, when I want to ask for name of the study for the student.
student.getStudie().getNaamStudie() is causing the Nullpointer

 
Piet Souris
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the line number of the error report you see which of the two is generating this error (RegulierStudent of Scholer). To make that even more clear, print the Test3 or Test4 before the error occurs.
So, either the Studie is null, or the name of the Studie (or both, of course).

To see that easily, make sure that all relevant classes have a toString defined. Printing the student, then the Studie will show you if there is some Studie without a name defined. If you use an IDE, then setting a break on the offending line and then debugging the program, will let you easily inspect this student and his Studie.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sideline in the conversation for a second: how enums can make your code a lot simpler and more robust. Say you have this enum (it would just be called Opleiding):

Now in Student you would have:

In StudentAdminFrame, you would have:

In StudentenAdministratie, everything concerning opleidingen goes away.

When you need to get the point of the student's study, use
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

At this point I have managed to get it working (not as good as I want),.
The Null pointer I got came from an incomplete constructor in study.

I will keep posting some of the progress and I Still have to make it robust.

@knute

Your example on enum does look good, I want to try it, but we need to make the application with a Study class with 2 subclasses opleiding and cpp.
I will try to see if I can still use the enum in that matter. if you have a tip on how let me know


 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to thank everyone for their help.
i have managed to get the program to work properly.

the only thing now is that the teacher is not happy with how I populate the Jcombox.
This is how I do it, but the string value should not be hardcoded. He said that I need to get the info from the ArrayList opleidingen



I have tried it with a getter but I don't get the value back

Any Idea's on how to to it?
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would loop through opleidingen and add each item with a opleidingen.get(index).
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I would loop through opleidingen and add each item with a opleidingen.get(index).



Hi Knute,

Thank you, I am trying to do that, but kinda stuck on how to do that.
The ArryList is from class Studie and is created in StudentAdministratie class.

StudentAdminFrame can only access Studentadministratie class

So I need to get the value with a getter in StudentAdministratie class.

It's probably not that difficult but somehow I am not getting it done :-(
 
Piet Souris
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Iwan,

glad to hear that your assignment is going well. I was about to start some discussions concerning your classes (just before your second NPE), but that is not important, can wait till later.

Regarding your question about these comboboxes:
an easy way to get these boxes filled without looping is something like:

List<Opleiding> opleidingen = ...;
...
JComboBox<Opleiding> comboOpleiding = new JComboBox<>(opleidingen.stream().toArray(Opleiding[]::new));
// or new JComboBox<>(new Vector<>(opleidingen));

You need a decent toString() method though.
If you ever change one of those Studie-lists, then there are nice ways to inform the comboboxes of these changes. But that for later.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Knute,

I have created a method in StudentAdministratie class that gets all the String values.


But when I call the method from the combobox it only shows the last value.

How can I get it to show all the values in the combobox?
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:hi Iwan,

Regarding your question about these comboboxes:
an easy way to get these boxes filled without looping is something like:

List<Opleiding> opleidingen = ...;
...
JComboBox<Opleiding> comboOpleiding = new JComboBox<>(opleidingen.stream().toArray(Opleiding[]::new));
// or new JComboBox<>(new Vector<>(opleidingen));

You need a decent toString() method though.
If you ever change one of those Studie-lists, then there are nice ways to inform the comboboxes of these changes. But that for later.


Hi Piet,

Thank you for the example, the only thing is that it will not work for this assignment.
The Gui can only access the StudentAdministratie class and the Studie class is associated with StudentenAdministratie.
Studie class has 2 subclasses Opleiding and CPP.

The Array List Studie is filled with opleidingen en cpp's.

So I need to get the values from this Arraylist and populate them in the Jcombox. Also I need to get the opleidingen in the Student combobox and the cpp's in the Scholer combobox.

That's why I thought that use a for loop in the arraylist would be my best shot, but it is only returning the last value :-(

So if you could help me with this that would be great.

 
Piet Souris
Bartender
Posts: 4066
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see...

Well, have a look at your latest method. You have this line in your loop:

and when the loop is over, you return this 'test'. No wonder you only see the last one!

I suggest you change this method into something like:

Edit: oops, I should have read a little better. What exactly are your needs? Do you have one combined List<Studie> and do you need to get that plitted into a List<Opleiding> and a List<CPP>? If so, then 'instanceof' works well.
Creating a JComboBox is then also easy, just add (in a loop), all the elements of one of these Lists into your box. unfortunately, a JComboBox only has constructors that take either an array or a Vector.

Hope I'm a bit clearer, now.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:I see...

Well, have a look at your latest method. You have this line in your loop:

and when the loop is over, you return this 'test'. No wonder you only see the last one!

I suggest you change this method into something like:

Edit: oops, I should have read a little better. What exactly are your needs? Do you have one combined List<Studie> and do you need to get that plitted into a List<Opleiding> and a List<CPP>? If so, then 'instanceof' works well.
Creating a JComboBox is then also easy, just add (in a loop), all the elements of one of these Lists into your box. unfortunately, a JComboBox only has constructors that take either an array or a Vector.

Hope I'm a bit clearer, now.



Hi Piet,

Yes I have one combined ArrayList<Studie> and have to get a List <Opleiding> and a List<CPP>.
Should I use the instanceof in the method as shown above?
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to either add the items to your combo box one by one...

...or add them all when you create the combo box:

(The method name "getOpleidingen" is not a good one; I'd call it something like "convertOpleidingenToArray".)

But it would be even better if you could add the Opleidingen objects themselves. (Opleidingen would need a good toString() method):
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I believe you need to either add the items to your combo box one by one...

...or add them all when you create the combo box:

(The method name "getOpleidingen" is not a good one; I'd call it something like "convertOpleidingenToArray".)

But it would be even better if you could add the Opleidingen objects themselves. (Opleidingen would need a good toString() method):



Unfortnately that won't work as I can't access any other class then StudentenAdministratie from the Frame class. We need to use inheritance.

I need a method in StudentenAdministratie that checks the Arraylist<Studie> for the values
With a cast to CPP and Opleidingen because I have two comboboxes one that only fills the Opleidingen (studies) and one that fills the CPP(courses)

The ArrayList has both the Opleidingen and CPP's stored in there and with instanceof I can differentiate them.

If I could access all teh classes from the GUI it would be a lot easier, but the assignment doesn't allow it.

that is why I am stuck :-(
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are you stuck on now?
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:What exactly are you stuck on now?



Getting the values in the combobox with a method.
The method I have tested are as follows:

But this only returns the object reference, I added a toString from Studie but that doesn't help, probably not strong enough (don't really know what that means)

I have tried the one in the previous post and as Piet explained that will only show the last value.

So I need a way to get the values in the 2 combobox
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about passing in your combo box and using:
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:How about passing in your combo box and using:



Hi knute

Could you elaborate on that. As the method is in the studentenadminitratie class and not in the GUI frame class where the combobox is.

Or should i use a arraylist getter and create a variable in the frame based on the getter and then use the for loop in the frame.



 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Or should i use a arraylist getter and create a variable in the frame based on the getter and then use the for loop in the frame.


If I'm understanding you, this sounds correct. Assuming that StudentenAdministratie can be instantiated in StudentAdminFrame. You need to be able to access opleidingen from the StudentAdminFrame class, something like:

This is assuming you have this in StudentenAdministratie:

Notes: this is not a good design, but I get the feeling you just want to get this assignment over with. At some point you should come back to this a design it better. We can talk about that later if you want.

Also, I don't have your latest code, or the complete code, as there is no main() in any class and I don't think you are using a framework.
 
Iwan van den Hoek
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:

Or should i use a arraylist getter and create a variable in the frame based on the getter and then use the for loop in the frame.


If I'm understanding you, this sounds correct. Assuming that StudentenAdministratie can be instantiated in StudentAdminFrame. You need to be able to access opleidingen from the StudentAdminFrame class, something like:

Notes: this is not a good design, but I get the feeling you just want to get this assignment over with. At some point you should come back to this a design it better. We can talk about that later if you want.

Also, I don't have your latest code, or the complete code, as there is no main() in any class and I don't think you are using a framework.



Hi Knute,

Yes this is true as well, I needed it to be finished. The new assignment is to make the application robust and start working with Throw Exception.

I have solved it with the code below:


Thank you for your help and everyone else as well.

So I will speak to you guys soon enough with the new assignment :-) and Knute I would definately want to learn how to do this in a better way.
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic