I have following lines of code that just don't want to be wrapped:
tran = TransactionFactory.generateDoubleEntryTransaction(cAcc, acc, qTran.amount, qTran.date, qTran.memo, qTran.payee, qTran.number);
logger.info("Different currencies, Credit: " + entry.getCreditAmount() + " " + creditCurrency.getSymbol() + " -> " + entry.getDebitAmount() + " " + debitCurrency.getSymbol());
Both lines are 150 respective 190 chars long. In my Code formatting settings the maximum line length is set to 100, the Line wrapping settings for Function Calls are all set to "Wrap when necessary". In the preview pane at least it looks like right. Just it doesn't wrap.
I'm using Eclipse 3.6.2 here.
You have to press CTRL+SHIFT+F
Related
I am a new programmer in javafx.
Using java FX in IDE I want to make a student information application.
I want to print the input data into the text area but it prints out in the console now.
(After clicking display button I want to show all the input data in textarea)
please help me out to solve this problem.
I am attaching my code below for your suggestion..
Main.java
Just place
textArea.setText("Name: " + t1.getText() +"\nAddress: " + t2.getText()
+"\nProvince: " + t3.getText() +"\nCity: " + t4.getText()
+"\nPostal Code: " + t5.getText() +"\nPhone Number: " + t6.getText()
+"\nEmail: " + t7.getText() + "\nCourses: "+comboBox.getItems()
+ "\nActivities: "+c1.getText() + "\n"+c2.getText());
into the action handler.
And remove the imports
import javax.swing.JTextArea;
import java.awt.*;
They are not JavaFX.
You are printing your result into the standard output stream (System.out). I assume you want to display what is printed by:
System.out.println("Name: " + t1.getText() +"\nAddress: " + t2.getText()
+"\nProvince: " + t3.getText() +"\nCity: " + t4.getText()
+"\nPostal Code: " + t5.getText() +"\nPhone Number: " + t6.getText()
+"\nEmail: " + t7.getText() + "\nCourses: "+comboBox.getItems()
+ "\nActivities: "+c1.getText() + "\n"+c2.getText());
Please visit the documentation of the TextArea class. Printing your result into the standard output stream has nothing to do with printing your result in your TextArea. Simply use a normal String that contains your result and set the text of your TextArea accordingly.
this is the code I used for the restaurant bill. I want the outcome like a real recipe, but the problem is the text I get is next to each other instead of underneath. This is the outcome..
Can someone help me with this?
BonField.setText("\tKassabon\n" +
"Klantnummer:" + klant +
"\n=================================================================\t " +
"\n======================================================\t " +
"\nBtw 6%:\t\t\t\t\t" + BTW +
"\nSub Totaal:\t\t\t\t\t" + SubTotaal +
"\nTotaal bedrag:\t\t\t\t\t" + Totaal +
"\nContant betaald:\t\t\t\t\t" + Totaal +
"\n======================================================\t " +
"\nDatum: " + Tdate.format(timer.getTime()) +
"\t\tTijd: " + tTime.format(timer.getTime()) +
"\n\n\tBedankt voor uw bezoek, graag tot ziens\n" );
First things first: Never format your textbox or any other visual element by it content directly in final builds of your applications. Although it is understandable for debug usage and stuff, you'll probably need to handle auto adjustment things within final builds.
Secondly: Too few info to help you, bro. Think and express properly when asking questions or you'll keep having your questions underrated.
Good luck with your work!
I am having an issue trying to add a new line to a DialogBox. I have tried the normal "\n" and also tried putting my lines inside of HTML style tags. Neither of these attempts worked. Help is appreciated.
DialogBox dialog = new DialogBox();
dialog.setText(" Meter ID:\t\t" + blink.getMeterId() + "\n X coordinate:\t\t" + blink.getXCoord() + "\n Y coordinate:\t\t" + blink
.getYCoord());
Issue resolved via using setHTML to set the contents of the DialogBox
dialog.setHTML("<p> Meter ID: " + blink.getMeterId() + "</p> <p> X coordinate:\t\t" + blink.getXCoord() + "</p> <p> Y coordinate:\t\t" + blink
.getYCoord() + "</p>");
note this is using <p></p> for new paragraph but <br> and other html will work also
just use another \ as an escape character in a string:
new line: \\n
DialogBox dialog = new DialogBox();
dialog.setText(" Meter ID:\\t\\t" + blink.getMeterId() + "\\n X coordinate:\\t\\t" + blink.getXCoord() + "\\n Y coordinate:\\t\\t" + blink
.getYCoord());
I have a control that must be highly customizable, and that means being able to use an image for the control background. To that end I need to know how I can, in code, set the CSS Style to point to the image specified by the user.
I have the following (which didn't work, I get a warning about "unknown protocol: c" (which I don't even know what that means)):
BG = //The CSS String
"-fx-background-position : 50% 50%;\n" +
"-fx-background-repeat : no-repeat;\n" +
"-fx-background-size : contain;\n" +
"-fx-background-image : url(\"" + GS.bgImage.getAbsolutePath() + "\");\n";
BG += "-fx-border-width : " + GS.borderWidth + ";\n" //For adding the Border
+ "-fx-border-color : " + GS.borderColor.toString();
this.setStyle(BG);
GS is a class I constructed from which the control reads the information to know what to make itself look like. GS.bgImage is the background image control is trying to use as it's background. So... what am I doing wrong here? Should i not be using .getAbsolutePath()? Is it something else?
Okay so it turns out trying to do it with File.getPath() or File.getAbsolutePath() was the issue. Turns out to make it work in code you need to use File.toURI().toURL().
So the proper method would be:
BG = //The CSS String, you need to wrap with a Try/Catch to capture a MalformedURLException, but I'm too lazy to do that here...
"-fx-background-position : 50% 50%;\n" +
"-fx-background-repeat : no-repeat;\n" +
"-fx-background-size : contain;\n" +
"-fx-background-image : url(\"" + GS.bgImage.toURI().toURL + "\");\n";
BG += "-fx-border-width : " + GS.borderWidth + ";\n" //For adding the Border
+ "-fx-border-color : " + GS.borderColor.toString();
Java newbie here, I'm having trouble setting a new line in this code:
String FnameTextboxText = FnameTextbox.getText();
String LastnameTextboxText = LastnameTextbox.getText();
String CourseTextboxText = CourseTextbox.getText();
Summary.setText("Firstname:" + " " + FnameTextboxText + "\nLastname:" + " " + LastnameTextboxText + "\nCourse:" + " " + CourseTextboxText);
Also tried something like: "\n" + "Lastname" But its no good.
Do you have any idea on how to make new lines. So that it'll look like this;
Firstname: x
Lastname: y
Course: Z
Using netbeans 6.8. On windows.
I guess you need to use TextArea.
First, use TextArea
Second, test using \r or \n or \r\n
Sometimes, people use \n to make new line and sometimes, like me, use \r\n to make new line