Monday, 2 September 2013

Java FX table column sorting with Comparator does not work

Java FX table column sorting with Comparator does not work

In Java FX I would like to display this Model in a sorted TableView:
public class ProfilZuordnungTableRowModel {
private int id;
private double kundenwert;
private String kundenwertFormatted;
private BooleanProperty selected; }
I would like to integrate a table column sorting with the column
"Kundenwert". The displayed value should be the attribute
"kundenwertFormatted" (String) and for sorting the attribute "kundenwert"
(Double) should be used.
So I wrote a comparator:
class ProfilZuordnungTableRowModelComparator implements
Comparator<ProfilZuordnungTableRowModel> {
@Override
public int compare(ProfilZuordnungTableRowModel t,
ProfilZuordnungTableRowModel t1) {
return t.getKundenwert() < t1.getKundenwert() ? -1 :
t.getKundenwert() == t1.getKundenwert() ? 0 : 1;
}
}
In my understanding this comparator should be used in the following way:
TableColumn kundenwertColumn = new TableColumn();
kundenwertColumn.setText("Kundenwert");
kundenwertColumn.setCellValueFactory(new
PropertyValueFactory("kundenwertFormatted"));
kundenwertColumn.setComparator(new
ProfilZuordnungTableRowModelComparator());
But when trying to sort by the column "Kundenwert" I get the following
exception:
java.lang.ClassCastException: java.lang.String cannot be cast to
model.ProfilZuordnungTableRowModel
at
dialog.TableCellFactorySample$ProfilZuordnungTableRowModelComparator.compare(TableCellFactorySample.java:53)
which points to this line:
kundenwertColumn.setComparator(new ProfilZuordnungTableRowModelComparator());
Any ideas?

logic to select the zip file from source and sending it to another directory

logic to select the zip file from source and sending it to another directory

I am stuck up in an odd situation that ia I have a folder in C: named
sourceconsists of one .dat file and one .zip file now I want to move only
zip file to another diretory in c : named target
1) Now first I have to write the logic to pick up the .zip file from
source folder
what I HAVE TRIED IS ...
private void filemove(String FilePath2, String s2) { filepath2 contains
the location of source c:\\source
String destination ="C:\\target\\"
try {
File f = new File(FilePath2);
if (f.getName().endsWith(".zip")) {
//please advise the logic to copy the file to destination folder
}
} catch (Exception e) {
e.printStackTrace();
}
}
please advise the logic to copy the files to destination folder

ActiveReport Truncate A Text

ActiveReport Truncate A Text

I make a Report in ActiveReport3.0 which has a Subreport. In my subreport,
in the Detail part actually, I have a textbox , that I bind my value to
the textbox.datafield. my value is a text in persian and it is also
long(about 8000 words).( I read the Value from Sql).I set the alignment of
the textbox to "rtl" because my text is in persian. then when I run my
app, the activereport truncate my text in persian (truncate it from left
and right of the textbox not at the bottom).what is the problem?

Custom color of part of text in Jtable cell

Custom color of part of text in Jtable cell

What i need is simple. I have a column in a jtable, and i need to insert a
string with different parts colorized. For example:
I need this [string] inserted into a jTable cell.
In the example, only the word "string" should have the red color,
everything else gray.
How do i do that?

Sunday, 1 September 2013

andorid keyboard with different language

andorid keyboard with different language

How to print urdu font in editbox while user press any button of the
softkeyboard?
I want to create urdu keyboard. I have made lots of research on that. I
found the solutions. but I couldn't found the way that how to print urdu
fonts in editbox when user type? I know about keyboard.xml and other
things.
Thanks.

Java division - don't works?

Java division - don't works?

i've a problem with java. An example:
int number1 = 3050;
int number2 = 95370;
System.out.println(number1 + "/" + number2 + " = " + number1/number2);
is 3050/95370 = 0 but it's not 0, it's 0.03198...
Thanks, Marian

Visual studion 2012 windows forms application (C ) .exe is not a valid Win32 application

Visual studion 2012 windows forms application (C ) .exe is not a valid
Win32 application

i have done a application in Visual studion 2012 Windows forms application
using C++. It runs very well in Windows 7 but it did not work in Windows
XP. it says ".exe is not a valid win32 application". how could i do?
Thanks