How to display specific items from an ArrayList based on a value from another ArrayList?
up vote
-1
down vote
favorite
I'm currently carrying out a task, where I have to create a software development solution to allow managers to add new staff and tasks. for this, I have an ArrayList
called staffMembers
, which takes name, grade and salary as parameters and an array list called tasksToDo
, which takes taskName
, taskGrade
and taskHours
as parameters.
One of the requirements is to enable the managers to click a JButton
and this will only display staffMembers
whose grade is equal to or greater than the taskGrade for the selected task (this is selected using JComboBox
). the result will be displayed in a JTable
.
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
However, the code above doesn't give the required result and I hoped someone my be able to point me in the right direction.
java swing arraylist jtable jcombobox
|
show 3 more comments
up vote
-1
down vote
favorite
I'm currently carrying out a task, where I have to create a software development solution to allow managers to add new staff and tasks. for this, I have an ArrayList
called staffMembers
, which takes name, grade and salary as parameters and an array list called tasksToDo
, which takes taskName
, taskGrade
and taskHours
as parameters.
One of the requirements is to enable the managers to click a JButton
and this will only display staffMembers
whose grade is equal to or greater than the taskGrade for the selected task (this is selected using JComboBox
). the result will be displayed in a JTable
.
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
However, the code above doesn't give the required result and I hoped someone my be able to point me in the right direction.
java swing arraylist jtable jcombobox
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
1
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
Where exactly isthis.jobGrade
and what value does it have (initially and possibly reassigned)?
– deHaar
Nov 22 at 14:19
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23
|
show 3 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm currently carrying out a task, where I have to create a software development solution to allow managers to add new staff and tasks. for this, I have an ArrayList
called staffMembers
, which takes name, grade and salary as parameters and an array list called tasksToDo
, which takes taskName
, taskGrade
and taskHours
as parameters.
One of the requirements is to enable the managers to click a JButton
and this will only display staffMembers
whose grade is equal to or greater than the taskGrade for the selected task (this is selected using JComboBox
). the result will be displayed in a JTable
.
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
However, the code above doesn't give the required result and I hoped someone my be able to point me in the right direction.
java swing arraylist jtable jcombobox
I'm currently carrying out a task, where I have to create a software development solution to allow managers to add new staff and tasks. for this, I have an ArrayList
called staffMembers
, which takes name, grade and salary as parameters and an array list called tasksToDo
, which takes taskName
, taskGrade
and taskHours
as parameters.
One of the requirements is to enable the managers to click a JButton
and this will only display staffMembers
whose grade is equal to or greater than the taskGrade for the selected task (this is selected using JComboBox
). the result will be displayed in a JTable
.
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
However, the code above doesn't give the required result and I hoped someone my be able to point me in the right direction.
java swing arraylist jtable jcombobox
java swing arraylist jtable jcombobox
edited Nov 22 at 14:10
Andrew Thompson
152k27162336
152k27162336
asked Nov 22 at 14:05
smokinraygunn
11
11
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
1
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
Where exactly isthis.jobGrade
and what value does it have (initially and possibly reassigned)?
– deHaar
Nov 22 at 14:19
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23
|
show 3 more comments
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
1
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
Where exactly isthis.jobGrade
and what value does it have (initially and possibly reassigned)?
– deHaar
Nov 22 at 14:19
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
1
1
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
Where exactly is
this.jobGrade
and what value does it have (initially and possibly reassigned)?– deHaar
Nov 22 at 14:19
Where exactly is
this.jobGrade
and what value does it have (initially and possibly reassigned)?– deHaar
Nov 22 at 14:19
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23
|
show 3 more comments
2 Answers
2
active
oldest
votes
up vote
0
down vote
You are setting model.setDataVector each time you get a match. Besides, (sm.grade > num1)
must have >= comparing, if you want equal or greater grade.
Also, you shouldn't use get(i) multiple times, do it once and store in a variable for any further actions. Or just use forEach.(Or lambda if You use java8+)
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
List<Object> rowData = new ArrayList<>();
Object member;
for (StaffMember sm:staffMembers) {
if (sm.grade >= num1) {
rowData.add(new Object {(Object)sm.name, (Object)sm.grade,
(Object)sm.getCost()});
}
}
model.setDataVector(rowData.toArray(new Object[rowData.size()]), colNames);
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
add a comment |
up vote
0
down vote
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
Don't use code like the above. You are reserving space in your 2D array assuming all staff members are selected. What if only the first and last meet your criteria? You will have a bunch of empty lines in the middle of the table.
Instead you should just dynamically add a row of data to the model when your specific criteria is met. Something like:
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = new DefaultTableModel(colNames, 0); // create empty model
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
Vector<Object> row = new Vector<Object>(3);
row.add( staffMembers.get(i).name );
row.add( staffMembers.get(i).grade );
row.add( staffMembers.get(i).getCost() );
model.addRow( row );
}
}
staffByTaskGradeTable.setModel( model );
You still need to debug why your "if condition" doesn't do what you expect.
Or how do you know that you are replacing the data in the model of the table that is visible on the frame. Maybe you have to instance of the table and only one is visible on the frame. A simple test it to just replace all the code in your method with:
DefaultTableModel model = new DefaultTableModel(5, 5);
staffByTaskGradeTable.setModel(model);
Now you should see an empty table with 5 row and 5 columns. If this works the problem is with your "if condition". The data is not what you expect.
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using theInteger.parseInt(...)
method.
– camickr
Nov 23 at 15:30
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You are setting model.setDataVector each time you get a match. Besides, (sm.grade > num1)
must have >= comparing, if you want equal or greater grade.
Also, you shouldn't use get(i) multiple times, do it once and store in a variable for any further actions. Or just use forEach.(Or lambda if You use java8+)
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
List<Object> rowData = new ArrayList<>();
Object member;
for (StaffMember sm:staffMembers) {
if (sm.grade >= num1) {
rowData.add(new Object {(Object)sm.name, (Object)sm.grade,
(Object)sm.getCost()});
}
}
model.setDataVector(rowData.toArray(new Object[rowData.size()]), colNames);
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
add a comment |
up vote
0
down vote
You are setting model.setDataVector each time you get a match. Besides, (sm.grade > num1)
must have >= comparing, if you want equal or greater grade.
Also, you shouldn't use get(i) multiple times, do it once and store in a variable for any further actions. Or just use forEach.(Or lambda if You use java8+)
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
List<Object> rowData = new ArrayList<>();
Object member;
for (StaffMember sm:staffMembers) {
if (sm.grade >= num1) {
rowData.add(new Object {(Object)sm.name, (Object)sm.grade,
(Object)sm.getCost()});
}
}
model.setDataVector(rowData.toArray(new Object[rowData.size()]), colNames);
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
add a comment |
up vote
0
down vote
up vote
0
down vote
You are setting model.setDataVector each time you get a match. Besides, (sm.grade > num1)
must have >= comparing, if you want equal or greater grade.
Also, you shouldn't use get(i) multiple times, do it once and store in a variable for any further actions. Or just use forEach.(Or lambda if You use java8+)
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
List<Object> rowData = new ArrayList<>();
Object member;
for (StaffMember sm:staffMembers) {
if (sm.grade >= num1) {
rowData.add(new Object {(Object)sm.name, (Object)sm.grade,
(Object)sm.getCost()});
}
}
model.setDataVector(rowData.toArray(new Object[rowData.size()]), colNames);
You are setting model.setDataVector each time you get a match. Besides, (sm.grade > num1)
must have >= comparing, if you want equal or greater grade.
Also, you shouldn't use get(i) multiple times, do it once and store in a variable for any further actions. Or just use forEach.(Or lambda if You use java8+)
private void jButtonSelectTaskActionPerformed(java.awt.event.ActionEvent evt) {
int num1 = this.jobGrade;//use the int supplied
//by user
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = (DefaultTableModel) staffByTaskGradeTable.getModel();
List<Object> rowData = new ArrayList<>();
Object member;
for (StaffMember sm:staffMembers) {
if (sm.grade >= num1) {
rowData.add(new Object {(Object)sm.name, (Object)sm.grade,
(Object)sm.getCost()});
}
}
model.setDataVector(rowData.toArray(new Object[rowData.size()]), colNames);
answered Nov 22 at 14:26
Alermikon
214
214
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
add a comment |
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
Thank you very much for your suggestion. However, I still get the same result.
– smokinraygunn
Nov 22 at 14:36
add a comment |
up vote
0
down vote
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
Don't use code like the above. You are reserving space in your 2D array assuming all staff members are selected. What if only the first and last meet your criteria? You will have a bunch of empty lines in the middle of the table.
Instead you should just dynamically add a row of data to the model when your specific criteria is met. Something like:
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = new DefaultTableModel(colNames, 0); // create empty model
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
Vector<Object> row = new Vector<Object>(3);
row.add( staffMembers.get(i).name );
row.add( staffMembers.get(i).grade );
row.add( staffMembers.get(i).getCost() );
model.addRow( row );
}
}
staffByTaskGradeTable.setModel( model );
You still need to debug why your "if condition" doesn't do what you expect.
Or how do you know that you are replacing the data in the model of the table that is visible on the frame. Maybe you have to instance of the table and only one is visible on the frame. A simple test it to just replace all the code in your method with:
DefaultTableModel model = new DefaultTableModel(5, 5);
staffByTaskGradeTable.setModel(model);
Now you should see an empty table with 5 row and 5 columns. If this works the problem is with your "if condition". The data is not what you expect.
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using theInteger.parseInt(...)
method.
– camickr
Nov 23 at 15:30
add a comment |
up vote
0
down vote
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
Don't use code like the above. You are reserving space in your 2D array assuming all staff members are selected. What if only the first and last meet your criteria? You will have a bunch of empty lines in the middle of the table.
Instead you should just dynamically add a row of data to the model when your specific criteria is met. Something like:
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = new DefaultTableModel(colNames, 0); // create empty model
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
Vector<Object> row = new Vector<Object>(3);
row.add( staffMembers.get(i).name );
row.add( staffMembers.get(i).grade );
row.add( staffMembers.get(i).getCost() );
model.addRow( row );
}
}
staffByTaskGradeTable.setModel( model );
You still need to debug why your "if condition" doesn't do what you expect.
Or how do you know that you are replacing the data in the model of the table that is visible on the frame. Maybe you have to instance of the table and only one is visible on the frame. A simple test it to just replace all the code in your method with:
DefaultTableModel model = new DefaultTableModel(5, 5);
staffByTaskGradeTable.setModel(model);
Now you should see an empty table with 5 row and 5 columns. If this works the problem is with your "if condition". The data is not what you expect.
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using theInteger.parseInt(...)
method.
– camickr
Nov 23 at 15:30
add a comment |
up vote
0
down vote
up vote
0
down vote
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
Don't use code like the above. You are reserving space in your 2D array assuming all staff members are selected. What if only the first and last meet your criteria? You will have a bunch of empty lines in the middle of the table.
Instead you should just dynamically add a row of data to the model when your specific criteria is met. Something like:
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = new DefaultTableModel(colNames, 0); // create empty model
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
Vector<Object> row = new Vector<Object>(3);
row.add( staffMembers.get(i).name );
row.add( staffMembers.get(i).grade );
row.add( staffMembers.get(i).getCost() );
model.addRow( row );
}
}
staffByTaskGradeTable.setModel( model );
You still need to debug why your "if condition" doesn't do what you expect.
Or how do you know that you are replacing the data in the model of the table that is visible on the frame. Maybe you have to instance of the table and only one is visible on the frame. A simple test it to just replace all the code in your method with:
DefaultTableModel model = new DefaultTableModel(5, 5);
staffByTaskGradeTable.setModel(model);
Now you should see an empty table with 5 row and 5 columns. If this works the problem is with your "if condition". The data is not what you expect.
Object rowData = new Object[staffMembers.size()][3];
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
rowData[i][0] = staffMembers.get(i).name;
rowData[i][1] = staffMembers.get(i).grade;
rowData[i][2] = staffMembers.get(i).getCost();
model.setDataVector(rowData, colNames);
}
}
Don't use code like the above. You are reserving space in your 2D array assuming all staff members are selected. What if only the first and last meet your criteria? You will have a bunch of empty lines in the middle of the table.
Instead you should just dynamically add a row of data to the model when your specific criteria is met. Something like:
String colNames = {"Name", "Grade", "Montlhly Salary/Hourly Rate"};
DefaultTableModel model = new DefaultTableModel(colNames, 0); // create empty model
for (int i = 0; i < staffMembers.size(); i++) {
if (staffMembers.get(i).grade > num1) {
Vector<Object> row = new Vector<Object>(3);
row.add( staffMembers.get(i).name );
row.add( staffMembers.get(i).grade );
row.add( staffMembers.get(i).getCost() );
model.addRow( row );
}
}
staffByTaskGradeTable.setModel( model );
You still need to debug why your "if condition" doesn't do what you expect.
Or how do you know that you are replacing the data in the model of the table that is visible on the frame. Maybe you have to instance of the table and only one is visible on the frame. A simple test it to just replace all the code in your method with:
DefaultTableModel model = new DefaultTableModel(5, 5);
staffByTaskGradeTable.setModel(model);
Now you should see an empty table with 5 row and 5 columns. If this works the problem is with your "if condition". The data is not what you expect.
edited Nov 22 at 15:22
answered Nov 22 at 15:07
camickr
273k15126238
273k15126238
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using theInteger.parseInt(...)
method.
– camickr
Nov 23 at 15:30
add a comment |
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using theInteger.parseInt(...)
method.
– camickr
Nov 23 at 15:30
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Thanks for your advice. I think my issue is getting the value of jobGrade when selecting it in the jComboBox. Assuming that the objects are converted to strings and I am trying to get an int value. Does that make sense? My terminology isn't the best as I'm relatively new and just learning the basics of Swing
– smokinraygunn
Nov 23 at 14:35
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using the Integer.parseInt(...)
method.– camickr
Nov 23 at 15:30
Assuming that the objects are converted to strings
- why would it be converted to a string? If the value is an int then it should be stored in your object as an int so you can do comparison with your "num1" variable which is an int. If your object stores the value as a string then you first need to convert it to an int by using the Integer.parseInt(...)
method.– camickr
Nov 23 at 15:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432712%2fhow-to-display-specific-items-from-an-arraylist-based-on-a-value-from-another-ar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What result does it give?
– Jason Armstrong
Nov 22 at 14:13
1
Share the results of your code and add an actual question.
– sechanakira
Nov 22 at 14:15
It gives me a list of all staff, including those whose grade is less than the job grade
– smokinraygunn
Nov 22 at 14:15
Where exactly is
this.jobGrade
and what value does it have (initially and possibly reassigned)?– deHaar
Nov 22 at 14:19
@deHaar this.jobGrade takes the value from the tasksToDo ArrayList once the task is created
– smokinraygunn
Nov 22 at 14:23