Swing/AWT/SWT :: Create TreeTable - Parent Row With 6 Columns And Child Row Having 4 Columns

Dec 2, 2005

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

Parent row:
-Column1-+-Column2-+-Column3-+-Column4-+-Column5-+-Column6-+

Child row:
--CloumnC1--+--CloumnC2--+--CloumnC3--+--CloumnC4--+

Can this be achieved using JSwing ?Also, Can I be able to Change the Column Headers Correspondingly when user clicks on Parent row and Child rows?

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: What Are Parent And Child Components

Aug 11, 2014

I keep hearing these two term when it comes to painting in Swing, however, I'm not sure which is which. To my understanding is that the child components are the ones that already exist on screen (could be a JButton, JFrame, or custom painting) . and the parent components are the one to be added/drawn next. (hence, if we override the paintChildren() method when painting, the components that were already on the screen don't appear any more).

View Replies View Related

Painting In Swing - Parent And Child Components?

Aug 11, 2014

I keep hearing these two term when it comes to painting in Swing, however, I'm not sure which is which. To my understanding is that the child components are the ones that already exist on screen (could be a JButton, JFrame, or custom painting) . and the parent components are the one to be added/drawn next. (hence, if we override the paintChildren() method when painting, the components that were already on the screen don't appear any more) ....

View Replies View Related

Swing/AWT/SWT :: Jtable Find Duplicates By Two Columns

Nov 30, 2014

I'm trying to remove duplicates from table. I want to remove only those rows which are both id and data equal. My code failed at fourth line.

int i=jTable1.getSelectedRow();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
jXDatePicker1.setFormats(dateFormat);
String date = dateFormat.format(jXDatePicker1.getDate()).toString();
String c1=jTable1.getValueAt(i, 0).toString();
String c2=jTable1.getValueAt(i, 1).toString();

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Resize Columns In JTable That Has No Header?

Feb 26, 2014

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.

View Replies View Related

Swing/AWT/SWT :: Refreshing GUI - Display Table With Several Columns And Rows

Jun 6, 2014

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?

View Replies View Related

Parent / Child Classes - Set And Get Method?

Jan 25, 2014

I have been working on a simple problem, but I am stuck. I am trying to learn parent and child classes and how they work. The program in broken into three classes; the DemoBook class that runs the various methods, the Book class that gathers information and displays it, and finally a child class of Book (called TextBook) that just gets one piece of data and then is suppossed to return that data back to Book. However, this is not working and I know I am missing something; I believe it has to do with Set and Get methods, but I am confused with how these work.

Java Code:

public class DemoBook
{
public static void main (String[] args)
{
Book aBook = new Book();
Textbook aText = new Textbook();

[Code] .....

View Replies View Related

Parent-Child Commenting Algorithm

Sep 11, 2014

I am creating a commenting system for a side project of mine I'm building using AnuglarJS for the front-end and Spring MVC for the backend.

I am having difficulty coming up with an algorithm that will populate each comment object with a list of the comments that are responses/children of it.

The below code is what I have so far. The problem is is that it duplicates comments.

public List<Comment> getComments(int id)
{
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("id", id);
List<Comment> allComments = jdbc.query("select * from comments where debate_id=:id", params, new RowMapper<Comment>()

[Code] ....

View Replies View Related

JSF :: Inserting Parent And Child Entities Into A Third Entity Using SelectOneMenu?

Oct 31, 2014

The company entity contains companyName, Sector and Segment columns. The mapping is 3 entities (Company, Sector, Segment) where Sector and Segment are used to create a company record. Sector has a OneToMany relationship with Segment and with Company. I put the Sector and Segment values into two select menus as use these to create a Sector and Segment reference for the Company table. I'm getting the following exception:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row:
a foreign key constraint fails (`testdummy`.`company`, CONSTRAINT `FK_COMPANY_FK_COMPANY_SECTORID` FOREIGN KEY
(`FK_COMPANY_SECTORID`) REFERENCES `sectors` (`SECTORID`))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

I'm thinking that the problem is that since the Segment entity is a child of Sector it must be entered through an instance of Sector. Because it's being entered as a separate value I'm getting this error. The problem is Segment is defined as a Set in the Sector entity and I can't figure out how to declare Segment as an instance using its parent entity (Sector).

My code is as follows, starting with the Sector entity:

@Entity
@Table(name = "SECTORSNEW")
public class SectorsNew {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int sectorId;
private String sectorName;
@OneToMany(cascade = CascadeType.PERSIST)

[code]....

View Replies View Related

Output In Columns

Mar 1, 2014

Any way i can format this output into columns?

for(int i = 0; i < 5; i++) {
System.out.println(t[i]+n[i]+s[i]);
}

View Replies View Related

Writing In Different Columns With OpenCSV?

Mar 13, 2015

I'm using opencsv and I want to write two arrays into a csv file and each array should be in a column. For example:

Column1 Column2
2423542 2332332
5242324 4343434
4242352 7565656
4343434 6565656
public class Writer {

[Code] ....

With my code the arrays are all in one column. What do I have to change that my output will be in two columns?

View Replies View Related

Equal Values In Two Columns For Every Row In Jtable?

Feb 5, 2014

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.

View Replies View Related

Adding Rows And Columns In A Matrix?

Apr 16, 2015

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.

For example this just using a 2 by 2,

Original
1 2 3 4 5
1 2 3 4 5
New 3 by 3
1 2 3 4 5 15
1 2 3 4 5 15
2 4 6 8 10 30

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;

[code].....

View Replies View Related

Summing Columns And Displaying Array

Apr 24, 2015

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.

View Replies View Related

How To Find Overall Averages Of Columns In Array

Nov 6, 2014

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

Badger,Bradley 37 70 51 48 68.66666666666667
Emu,Emma 35 81 75 40 72.83333333333334
Aardvark,Alice 42 85 22 0 65.11111111111111
Dodo,Donald exc 12 25 0 54.17391304347826
Cassowary,Cassie 50 97 72 68 62.758620689655174

my code is :

Java Code: public static double[] computeAllGrades(int[][] scoreTable, int[] itemPointValues)
{
{
double totalPoints = 0;
double totalPointsPossible = 0;
double allGrades[];
double grade =0;

[code]....

View Replies View Related

Nested FOR Loops For Rows And Columns

Apr 21, 2014

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.

View Replies View Related

Rows And Columns In The Form Of Multiplication Table?

Mar 12, 2014

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.

View Replies View Related

Fixing JTable Columns In Place And Length

Jan 26, 2014

now i'm working on a program which contain JTable..how i can make the columns fixed in it's place and how i can make them in a fixed length.

View Replies View Related

How To Transpose 2D Array As In Switch Rows And Columns

Apr 14, 2015

how to switch the elements in a 2D array. As an example row 1 would become column 1 in a second array.

View Replies View Related

How To Merge Two SQL Table Columns Into One JTable Column

Sep 5, 2013

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?

View Replies View Related

Using Buffered Reader And Columns To Read In Two Strings?

Dec 8, 2014

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();
}

View Replies View Related

Sorting CSV Data Into Rows That Contains Duplicates In Columns

Apr 30, 2015

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 |
---------------------------

View Replies View Related

JSF :: Enable / Disable Columns In DataTable PrimeFaces

Jul 21, 2014

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.

View Replies View Related

JSF :: Data Table Showing Records In Columns?

Aug 2, 2014

I'm new in JSF, so maybe this is a very simple problem:

My small application uses 'primefaces ' and I'd like to display the course of some laboratory values this way:

Parameter2014-08-022014-08-012014-07-31
Natrium [mmol/l]140.0135.0135.5
Calcium [mmol/l]2.12.02.3
Kalium [mmol/l]4.34.05.3
[...] [mmol/l]1.32.02.3

Data is stored in a per day manner, so each table column shows one record.

In JSF, I've only seen tables showing records in rows. How to display a transposed data table in JSF.

View Replies View Related

Matrix Algebra - Number Of Rows And Columns

Mar 19, 2015

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.

View Replies View Related

JavaFX 2.0 :: TableView With Dynamic And Updatable Columns

Jan 30, 2015

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.
 
Example:
Customer2015/01/022015/01/032015/01/09Morgan$400 (buyDetail)0$100Luis00$20Steven$1000Hulk0$5$32 

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>("");
 
[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved