Files
NotEnoughItems/src/codechicken/nei/ItemQuantityField.java
T
Jason Mitchell 6d9ff9ea0a Backport some JEI features
* Licensed under LGPL
* Remove TMI style
* Remove Load/Save inventory state
* Reworked ItemPanel so it's no longer used statically
* BookmarkPanel inherits from ItemPanel
* Rework LayoutManager
* Bookmarks - including loading & saving
* Utility/Cheat buttons line up and wrap based on GUI size
2019-12-30 14:32:55 -08:00

45 lines
1.0 KiB
Java

package codechicken.nei;
public class ItemQuantityField extends TextField
{
public ItemQuantityField(String ident) {
super(ident);
centered = true;
}
// Find a way to work this this back in
public boolean isValid(String string) {
if (string.equals(""))
return true;
try {
return Integer.parseInt(string) >= 0;
} catch (NumberFormatException nfe) {
return false;
}
}
public int intValue() {
return intValue(text());
}
public int intValue(String s) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException nfe) {
return 0;
}
}
@Override
public void loseFocus() {
setText(Integer.toString(NEIClientConfig.getItemQuantity()));
}
@Override
public void onTextChange(String oldText) {
if (intValue(oldText) != intValue())//hacky recursion stopper
NEIClientUtils.setItemQuantity(intValue());
}
}