DO NOT DEAL WITH THIS MEMBER
I'm trying to format the text in collums using java.util.Formatter and Ive set the padding using the following
Code String.format("%s %45s %50s", name, amount, dropRate);
and here's the result, I can't get it to quite align properly though can somebody help me?
DO NOT DEAL WITH THIS MEMBER
Feb 7, 2017 04:53 AM
(This post was last modified: Feb 7, 2017 05:23 AM by g4143.)
I'm not familiar with Java's format but...
Code String.format("%s %45s %50s", name, amount, dropRate);
Shouldn't that be something like...
Code String.format("Item: %-20s Amount: %-45s Drop rate: %-50s", name, amount, dropRate);
DO NOT DEAL WITH THIS MEMBER
Feb 7, 2017 10:39 AM
(This post was last modified: Feb 7, 2017 10:49 AM by matt.)
(Feb 7, 2017 04:53 AM)g4143 Wrote: I'm not familiar with Java's format but...
Code String.format("%s %45s %50s", name, amount, dropRate);
Shouldn't that be something like...
Code String.format("Item: %-20s Amount: %-45s Drop rate: %-50s", name, amount, dropRate);
Yes, I've just put the variable names in each individual string along with the value.
Here's the full toString method
Code public String toString() {
String name = "@cya@Item: @or2@" + ItemDefinition.getItem(itemId).getName();
String tempAmount = amount;
if(tempAmount.toLowerCase().startsWith("random")) {
String[] data = tempAmount.substring(7).split(":");
tempAmount = String.format("%s - %s", data[0], data[1]);
}
String amount = "@cya@Amount: @or2@" + tempAmount;
String dropRate = "@cya@Drop rate: @or2@" + numerator + "/" + denominator;
return String.format("%s %45s %50s", name, amount, dropRate);
}
(Feb 7, 2017 10:39 AM)matt Wrote: Yes, I've just put the variable names in each individual string along with the value.
Here's the full toString method
Code public String toString() {
String name = "@cya@Item: @or2@" + ItemDefinition.getItem(itemId).getName();
String tempAmount = amount;
if(tempAmount.toLowerCase().startsWith("random")) {
String[] data = tempAmount.substring(7).split(":");
tempAmount = String.format("%s - %s", data[0], data[1]);
}
String amount = "@cya@Amount: @or2@" + tempAmount;
String dropRate = "@cya@Drop rate: @or2@" + numerator + "/" + denominator;
return String.format("%s %45s %50s", name, amount, dropRate);
}
Isn't there an escape character in java "\t" I believe that tabs things over, couldn't you just tab everything according to it's column?
Code String example = "\tFirst Column \tSecond Column \tThird Column";
DO NOT DEAL WITH THIS MEMBER
Feb 8, 2017 02:20 PM
(This post was last modified: Feb 8, 2017 02:20 PM by clrlslwi.)
RS has custom text rendering, tab characters aren't going to work. You're going to want to make 3 labels for each line, and align the x coordinate.
DO NOT DEAL WITH THIS MEMBER
(Feb 8, 2017 02:20 PM)clrlslwi Wrote: RS has custom text rendering, tab characters aren't going to work. You're going to want to make 3 labels for each line, and align the x coordinate.
This clears some stuff up, thanks man! :)
|