So I have a form that I want a User to fill out
it must have the date at the top which are 3 combo boxes for Day, month and year.
then I give them a form which they can partially fill out
So lets say there are 4 rows
each row has a combo box and a field.
Now i've been testing for the past hour nearly to check if one when is null is the other? otherwise it's invalid.
I've tried combo.toString() and then testing if that was null or empty but that didn't work for some reason.
So basically if the combo box has no value, then the field can have no value too, but if one has a value then the other MUST, otherwise the form is invalid.
Please help
Related
The situation is:
I want to use two date values obtained from two jDateChoosers and calculate the number of days between two selected days.
The question is: what should I do that after choosing both dates a calculated value would appear in a label (or Text Field, which one is better?) without any additional submission (in other words, without clicking on any buttons ect.)?
Have an actionListener checking for if both dates have been input when the jDateChoosers close and then have a function such as update() to perform the calculations and update your label
I just got this Jtable on Netbeans . First I want it to auto-calculate some grades, as you can see it has 3 columns (1st, 2nd and 3rd evaluation). I have to type between 0 and 100, in each row.
In the end, get the total and average. This can be displayed in a Jlabel, or a textfield. But, it has to be displayed real-time (as I'm typing the values).
Also, I can't type data on all the cells, just one for each row. How do I do this?
I know I can change the columns to accept only Integer values, but for everything else, I have no idea how to proceed.
In the end, get the total and average. This can be displayed in a Jlabel, or a textfield. But, it has to be displayed real-time (as I'm typing the values).
Well, you would want to update "after" the user has finished editing a cell and saves the value to the table.
So you can use a TableModelListener. You add the TableModelListener to the TableModel. Then when the data is saved an event will be generated and you can recalculate the values and update the label.
Check out the following for a simple example to get your started: TableModelListener and multiple column validation. Your logic in the listener will change based on your exact requirement.
You can do this by attaching a defaultTableModel to your JTable. After attaching TableModel to your JTable. You can use command JTable.addRow(Object[]) to add rows to table.
I used PrimeFaces LineChart. It works properly when all values are available but if there is no item one of the x-axes values(months). One of the series doesn't have item in the first two month and there is in third month. It shows its label points not properly. Items value for March displayed in March correctly but its label points displayed in february which is wrong. How to handle this issue I couldn't find solution through web.
You have to handle this issue in time you are creating the series. Simply check if the item has all attributes needed or isn't null. Series has to contain only valid data in time they are loaded to LineChart by Primefaces.
So I have two JComboBoxes, and what I am trying to do is be able to compare the value in one, with the value in the second and then figure out the difference or the total. I want to be able to input a time in the first box (let's say 8:00 A.M) and then I want to be able to input 5:00 P.M in the second box, and have it display 9.
Is there a way to do this?
I don't have any working code, just need to be steered in the right direction.
you can add itemListener on both the comboboxes and in those item listeners, check if there is something selected in other combobox...accordingly you can perform your calculations....
I'm creating a Java application where the user can search through a list of objects, which are then displayed in a JEditorPane window using a dynamically generated table whose size varies by the amount of results returned.
I then want to allow the user to select and edit the objects. (The Java objects, not the HTML code) Is this feasible, or should I be doing something completely different? Should I even be using a JEditorPane, or should I be using a different method, and how would I go about that?
The display in question has anywhere from 1 to 50 (depending on the results) cells that read like this:
Name
Text
a picture of the object
year
check boxes for two boolean variables that are part of the object.
The check boxes should allow the user to click on them and change the boolean variables, which would then be saved to the main object collection.
Thoughts?
JTable is suited for this sort of task. you can do a lot of what you are looking for with renderers and editors. Here is a tutorial. An exerpt with my emphasis reads:
To choose the renderer that displays the cells in a column, a table first determines whether you specified a renderer for that particular column. If you did not, then the table invokes the table model's getColumnClass method, which gets the data type of the column's cells. Next, the table compares the column's data type with a list of data types for which cell renderers are registered. This list is initialized by the table, but you can add to it or change it. Currently, tables put the following types of data in the list:
Boolean — rendered with a check box.
Number — rendered by a right-aligned label.
Double, Float — same as Number, but the object-to-text translation is performed by a NumberFormat instance (using the default number format for the current locale).
Date — rendered by a label, with the object-to-text translation performed by a DateFormat instance (using a short style for the date and time).
ImageIcon, Icon — rendered by a centered label.
Object — rendered by a label that displays the object's string value.
Cell editors are chosen using a similar algorithm.