I am very new to Java Swing. I have to create a TreeTable in Java Swing with a Parent Row having say 6 columns and its all child row having just 4 columns. like shown below
I'm having a problem with using the openCSV library when I create a JAR file. I'm currently using BlueJ to run my code. When I compile my program in there, I have no problems whatsoever and it runs great, yet when I create my program into a JAR file, my application doesn't work.
I would think that my problem is either stemming from faulty exception handling, although I don't understand why an input would work in the BlueJ environment, but not when using the JAR file. Or, perhaps the openCSV library isn't in a correct class path(I don't know if this is correct terminology).
I have a JScrollPane with two coulmns. In the first column I have an image pane JTable, and in the second a list with names of sections. This second column I try to divide in two columns, one (the second column) to display the names of the sections (each row contains one name), and in the other column (the third) I want to show some values for every section in the row respectively. But, instead of displaying the desired values in the third column, I get the same names of the sections as in the second column. Here is a part of the code I have:
private Vector<Section>daten = new Vector<Section>(0); //These are the values for the first column in the Jscroll private String[] header = {"Section","calcGYR"}; // These are the values for the second and third column (in this case the header for the both columns public TrafficObserveModel(Vector<Section> daten) { setData(daten);
[code]....
But I don't know how to modify the methods in order to render the desired integer values in the third column.
I have a 5x5 array of which I read from an external file and I am supposed to print out the original matrix and then add up each row and column, proceeding to store them into the sixth positions in my matrix. After that I print out the new matrix.
I am confused as to how to isolate rows and print them out. I know how to add the entire matrix up but isolation is my issue.
Here is what I have including how to read the matrix and the sum of the whole thing
import java.io.*; import java.util.*; public class prog470cAddingRandC { public static void main (String [] args) { //read the file Scanner inFile=null;
public static void displayOutputs (int[][] anArray) { System.out.println("Here is your 2Dim array:"); for (int i = 0; i < anArray.length; i++) { System.out.println(Arrays.deepToString(anArray)); } }
This is my code and I get this as a result when I input 10,20,30,...,90 into array[0][0], array[0][1], ..., array[2][2] (3rows, 3columns array)
[[10, 20, 30], [40, 50, 60], [70, 80, 90]]
[[10, 20, 30], [40, 50, 60], [70, 80, 90]]
[[10, 20, 30], [40, 50, 60], [70, 80, 90]]
While I expect to get only
[10, 20, 30]
[40, 50, 60]
[70, 80, 90]
I get no errors at least when I have the same # of rows and # of columns. However, when I have more columns than rows, a compiler stops running when it runs columnSum method.Here's an error message.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at lab10.Array2DMethods.columnSum(Arrays2DDemo.java:70) at lab10.Arrays2DDemo.main(Arrays2DDemo.java:111) Java Result: 1
And here's my code
public static void columnSum (int[][] anArray) { int sum =0; for (int col=0; col < anArray.length; col++) { sum=0; for (int r = 0; r < anArray[col].length; r++ ){ sum += anArray[r][col]; } System.out.println("Sum of column " + col + " = " + sum); } }
why my code doesn't work when I have more columns.
How can I find the overall averages of the columns in this array?when i run my code it gives me an output that looks like this (showing me wrong averages): 0 1 2 3 overall grade
I need to write a class,that will give me output like this:
* *** **** *** *
I have to use for loop,i know that i have to use nested for loops, for rows and columns. I just cant figure it out the thing with spaces,and how to turn it to count back.
I am making rows and columns in the form of a multiplication table, listed below is my code:
package assignments; public class MultTable { public static void main (String [] args) { int row, column, x, y; for(row = 0; row < 8; row++)
[Code] .....
If you see my sample run you can see that I have the multiplication table down but, I haven't completed it. I have to make the bottom left half of the whole table blank somehow. For example, I have to make it halfway through the middle of the table the bottom left half full of white space...
5 6 7 8 9 12 14 16 18 21 24 27 32 36 90
hm, it's supposed to be the other way around horizontally.
Is it possible to allow users to resize columns in a JTable that has no header? I'd like the user to be able to grab the column lines on any of the data rows and be able to resize just like they can in the header.
I have a database table containing two columns A and B. They both contain integers. I'd like to know if it's possible, when displaying them in a JTable, to be combined in one column X. I still need, however, to be able to distinguish them from each other when selecting a row from the JTable. E.g. to store each of the values in a a separate variable. Maybe I can combine them when reading from the ResultSet and use some sort of delimiter ? But how?
I'm making a tree of contacts with people's names as one string and their numbers as another. I need to read that in from a .dat that is set up to have two columns, across from the names are the numbers, so i have to read that in, but I'm not sure how. Here is what I have:
Tree<String, String> tree = new Tree<String, String>(); BufferedReader br = new BufferedReader(new FileReader("/Users/katedess/Desktop/animals.dat")); String read; while((read = br.readLine()) != null) { tree.add(read); } br.close(); }
How to sort data from a .csv file. The file has a column that contains duplicate groups, and a column that has duplicate employee id's. I need to take the data and sort it into rows. The employee's id will be in the first column, then the groups the employees belong in will occupy the following columns. The groups and employees are dynamic.
groups| empId ----------------- Group A| a1234 | Group A| e3456 | Group A| w3452 | Group A| d3456 | Group A| j7689 | [Code] ....
I want to format the .csv as follows:
-------------------------- empId | group 1 | group 2 | -------------------------- a1234 | group A | group B | --------------------------- w3452 | group A | group B | ---------------------------
I have created one dataTable in page and shown some columns but I want to show only those columns which have entries ( if any column doesn't have record then it should not be displayed on the page.) . How should I put validation on this and display table.
I am continuing on in trying to build up the basics of matrix algebra from scratch.
I have created an object class called Matrix
import java.util.ArrayList; public class Matrix { public int NumRows; public int NumColumns;
// This array contains the entries of our matrix. ArrayList<Double> entry = new ArrayList<Double>();
[Code] ......
Bottom line: a matrix has a number of rows and a number of columns, and for each pair of row and column, we have a number in our matrix. The DisplayMatrix method prints my matrix to the screen, and the GetEntry method returns a particular value. This all works fine and dandy as far as I can tell.
A fundamental operation done to matrices to obtain a special matrix called the RREF is the process of switching 2 rows. Here is a method I have written that switches two rows of a matrix, and outputs the result as a new matrix. Note that I want the original matrix to be unchanged.
// Switch two rows public static Matrix SwapRows(Matrix A, int r1, int r2){ if(r1<1 || r1>A.NumRows || r2<1 || r2>A.NumRows) PRINTLN("illegally switching rows"); Matrix C = A; double dummy[] = new double[A.NumColumns];
[Code] ....
How I call this, inside a public static void main(String[] args), is as follows:
// Declares that A is a 2 by 2 matrix. Matrix A = new Matrix(2,2);
// We now add values in. The top left entry of A is 4, the top right entry of A is 1, the bottom left entry of A is 2, and the bottom right entry of A is 6.
double pony[]= new double[4]; pony[0]=4; pony[1]=1; pony[2]=2; pony[3]=6; A.AddEntries(pony);
// We can display the matrix in the output, and it looks exactly as expected!
A.DisplayMatrix();
// I am now going to create a new matrix called B. It is going to be obtained by flipping the first and second rows of A.
//Note that I want A is stay as I initialized it.
//I dont want A to have it's 2 rows switched. I want B to the matrix obtained by switching two rows of A.
Matrix B=SwapRows(A,1,2); B.DisplayMatrix();
// Displaying B gives me the desired result. However, if I now display A again, it is the same as B.
A.DisplayMatrix();
Why is my matrix A being modified? Of course, I am more than capable of providing more details/comments if requested. I suspect that this is a super silly mistake.
I am trying to code a TableView with dynamic columns and I saw a lot of examples like this one: Creating columns dynamically. But any of those would work for my needs.
Its very simple: I got a List of Customers, and each one has a List of Buys. A Buy has a String "buyDetail" and a Date for the ship.
My TableView need to have the first column with the name of the Customer, and one column more for every day of existing ships. We don't know previously which days will be used. If the amount of money is superior of 100, for example, I need to be able of applying different styles.
I cant use the Properties because i dont know how many Buys will have each Customer.
My best try (only for the first column) was this, but I cant get the Buy updated if I edit the value in the cell: I didn't try to write the others columns code because I feel that im doing it really wrong.. This Shows the Customer´s names, but I cant handle if that data is edited.
table = new TableView<Customer>(); ObservableList<Customer> lista = FXCollections.observableList(registros); table.setItems(lista); TableColumn<Customer, Customer> customerNameColumn = new TableColumn<Customer, Customer>("");
I've written two programs. My first program compares the difference of two text files and prints the differences in an output. My second program creates a simple Html table. I would like to write my output to this table. How would I go about doing this in java?
I'm new in JSF, so maybe this is a very simple problem: My small application actually uses 'primefaces ' and I'd like to display the course of some laboratory values this way:
I am trying to write a code for multidimensional array, allocate memory for variables and access the value of the arrays. I want them to be shown as rows and columns. but my code only shows one column and no rows. here is my code:
public static void main(String[] args) { int[ ][ ] aryNumbers = new int[2][2]; aryNumbers [0][0] = 1; aryNumbers [0][1] = 2; aryNumbers [1][0] = 3; aryNumbers [1][1] = 4; int rows = 2; int columns = 2;
I have an application that displays a GUI and this GUI displays a table with several columns and rows. I have a class that extends DefaultTableModel. I wrote the code that displays the GUI. When the database table changes, how would I updated the GUI dynamically? Do you have any sample code that does that?
I am trying to put together a small application in my spare time. Nothing major, but one thing I want it to do is accept a few inputs, and take those and add them to a table with columns for use later (printing, calculations, etc). I was originally looking at something like Jtable, but that looks just like an excel spreadsheet done Java, so not what I'm looking for.
I'm looking for something that's read-only, where I can insert data from input fields, and then perform calculations with the column data later.