|
|
Learning Java, reading:
"Java the Complete Reference", Ninth Edition
This is regarding JavaFX.
Writer's code:
ImageView hourglassIV = new ImageView("hourglass.png");
Label hourglassLabel = new Label("Hourglass", hourglassIV);
rootNode.getChildren().add(hourglassLabel);
My Code:
Label hourglass = new Label("Hourglass", new ImageView("hourglass.png"));
rootNode.getChildren().add(hourglass);
Is my code okay, or should I write it like the book Writer's code?
|
|
|
|
|
Jonathan Hicks wrote: Is my code okay In respect of what? Does it work or is there some problem?
|
|
|
|
|
In respect to accepted Java coding guidelines.
My code works.
I'm a programmer in another language converting to Java and want to do it right.
|
|
|
|
|
Jonathan Hicks wrote: accepted Java coding guidelines. That is whatever guidelines your company uses.
|
|
|
|
|
The essential difference is that you will have no way to subsequently access the author's hourglassIV . Whether that matters is up to you. Oh, and your code may be harder to debug.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
connentivity problem with postgresql9.4
|
|
|
|
|
|
how write in file (.xls) without delete the older data
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("ma feuille");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = null;
cell = row.createCell((short) 0);
cell.setCellValue(1234);
sheet.addMergedRegion(new Region(0,(short)0,0,(short)3));
FileOutputStream fileOut;
try {
fileOut = new FileOutputStream("monfichier.xls");
wb.write(fileOut);
fileOut.close();
} catch (FileNotFoundException e) {
e.printStackTrace();}
|
|
|
|
|
You are creating a new workbook and worksheet, so there is no existing data.
|
|
|
|
|
Hello to everyone
I am developing a simple chat application in java. It has two parts Server.java and Client.java. When I run these files on a local network they work fine but when I run them on PCs that are on different networks it does not works. Can anyone please guide me how to do it.
Thanks
|
|
|
|
|
If you want someone to help you fix your code, then you need to share the relevant parts of your code.
We can't access your computer, see your screen, or read your mind. If you don't show us what you've done, we can't tell you what the problem is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It is a networking related problem (configuration, routing, and/or filtering) and not a Java related problem.
The system running the server code must allow incoming traffic to the used port. So you have to configure the firewall settings of your server system and related routers.
When your server system does not have a public IP address (e.g. with a dial-up internet connection) you have to configure also some kind of port forwarding on the router and use a dynamic DNS service.
|
|
|
|
|
can anyone out here provide me with "bookstore java project source code"its urgent ???
|
|
|
|
|
Yes, Google will find it for you, especially if it's urgent, as Google understands such words.
|
|
|
|
|
i need to get cell with this value "123k2"
i was tried that code
s.getRow(0).getCell(0).getRichStringCellValue().toString()
but i get this messege "
Cannot get a NUMERIC value from a STRING cell "
how i can get it
|
|
|
|
|
You should not need to call toString on a string item. Other than that the error message does not appear to match the code. Where is the actual code that is trying to get a numeric value?
|
|
|
|
|
ok is done.
so now i need to put this value in a arraylist i tried this code but it is incorrect i need to know where is the fault or have other method to put the cells in arraylist
t[0].add(s.getRow(0).getCell(0).getRichStringCellValue().toString();
System.out.println("ob "+t[0]);
|
|
|
|
|
With that code, the compiler will tell you where the fault is. (Missing closing parenthesis on the first line.)
If you get a compiler error or a runtime error that you don't understand, and you want us to help you, then you need to include the error details. Just saying "it is incorrect" or "it doesn't work" is not enough.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
iheb11 wrote: i tried this code but it is incorrect How is it incorrect? Please do not leave us to guess.
|
|
|
|
|
the error is :<pre>" Uncompilable source code - Incorrect symbol type: <any> .add"
The error is more complicated than a non-closed parenthesis on the first line
And we are all here to interact with each other and learn from each other even their mistake, tnx for your help and for your good advice
|
|
|
|
|
i need to get data from a file excel in java and to display the data on a jTable please help me to resolve this problem tnx
i was try this code but i think is incorrect
<
public Object getCellValue(Sheet sheet, int rowNum, int colNum) {
Row row = sheet.getRow(rowNum);
if ( row==null ) {
return null;
}
else {
Cell cell = row.getCell(colNum);
if ( cell==null ) {
return null;
}
else {
return getCellValue(cell);
}
}
}
public Object getCellValue(Cell cell) {
switch (cell.getCellTypeEnum()) {
case CellType.STRING:
return cell.getRichStringCellValue().getString();
case CellType.NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue();
} else {
return cell.getNumericCellValue();
}
case CellType.BOOLEAN:
return cell.getBooleanCellValue();
case CellType.FORMULA:
return evalCell(cell);
case CellType.BLANK:
return null;
default:
throw new IllegalStateException("Unknown cell type");
}
private Object evalCell(Cell cell) {
FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
CellValue cellValue = evaluator.evaluate(cell);
switch (cellValue.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
return cellValue.getBooleanValue();
case Cell.CELL_TYPE_NUMERIC:
return cellValue.getNumberValue();
case Cell.CELL_TYPE_STRING:
return cellValue.getStringValue();
case Cell.CELL_TYPE_BLANK:
return null;
case Cell.CELL_TYPE_ERROR:
throw new RuntimeException("Excel formula error");
default:
throw new IllegalStateException("Unknown cell type");
}
}
|
|
|
|
|
iheb11 wrote: i was try this code but i think is incorrect Then please explain why. We can only help if you explain what the problem is.
|
|
|
|
|
|
Can Write a java program to develop object oriented software covering requirements mentioned below.
Requirements of the Software Application
* Select title for the software application and it should be meaningful
* Application should use number of classes between 3-5 in additional to main method class.
CAN ANYONE WRITE A SIMPLE PROGRAM USING Encapsulation, inheritance, polymorphism and abstraction please.
ITS SO THAT I CAN UNDERSTAND BETTER
(SORRY FOR MY BAD ENGLSIH)
ALSO I NEED THIS IN CONSOLE JAVA (u know to run with cmd)
What I have tried:
I Tried writing JAVA in notepad but i couldnt understand how to write a simple program combining Encapsulation, inheritance, polymorphism and abstraction
|
|
|
|