本文整理汇总了Java中net.nickac.lithium.backend.controls.LControl.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java LControl.setSize方法的具体用法?Java LControl.setSize怎么用?Java LControl.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.nickac.lithium.backend.controls.LControl
的用法示例。
在下文中一共展示了LControl.setSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addControl
import net.nickac.lithium.backend.controls.LControl; //导入方法依赖的package包/类
@Override
public void addControl(LControl c, int x, int y, int w, int h) {
c.setSize(new Dimension(w, h));
c.setLocation(new Point(x, y));
addControl(c);
}
示例2: addControlToGUI
import net.nickac.lithium.backend.controls.LControl; //导入方法依赖的package包/类
/**
* Adds a Lithium control to the GUI.<br>
* This is the method that does the heavy lifting..
*
* @param c Control to be added
*/
public void addControlToGUI(LControl c) {
//Here we check if control is a panel, and if it is, check if it's centered on x or y axis.
boolean centeredX = MiscUtils.isCenteredX(c);
boolean centeredY = MiscUtils.isCenteredY(c);
//Then we finally calculate the location of the control.
//Minecraft has some limitations regarding button height, so it's always equal to the constant
Point newLoc = centerControl(c);
int controlX = newLoc.getX();
int controlY = newLoc.getY();
//The cool part!
//Adding the control
if (c.getClass().equals(LPanel.class)) {
LPanel pnl = (LPanel) c;
for (LControl lControl : pnl.getControls()) {
addControlToGUI(lControl);
}
} else if (c.getClass().equals(LButton.class)) {
LButton b = (LButton) c;
GuiButton bb = generateGuiButton(b);
addButton(bb);
buttonsCounter.put(globalCounter, b);
reverseLButtonsCounter.put(b.getUUID(), bb.id);
reverseButtonsCounter.put(bb.id, globalCounter);
} else if (c.getClass().equals(LTextLabel.class)) {
LTextLabel lbl = (LTextLabel) c;
if (!labels.contains(lbl)) {
labels.add(lbl);
}
} else if (c.getClass().equals(LTextBox.class)) {
NickGuiTextField txt = new NickGuiTextField(
globalCounter,
ModCoderPackUtils.getFontRenderer(),
controlX, controlY,
c.getSize().getWidth(), c.getSize().getHeight(),
((LTextBox) c).isPasswordField()
);
txt.setText(c.getText() != null ? c.getText() : "");
textBoxes.put(c.getUUID(), txt);
textBoxesReverse.put(txt.getId(), c.getUUID());
textBoxesLReverse.put(c.getUUID(), (LTextBox) c);
} else if (c.getClass().equals(LProgressBar.class)) {
progressBars.put(c.getUUID(), (LProgressBar) c);
} else if (c.getClass().equals(LCheckBox.class)) {
checkBoxes.put(c.getUUID(), (LCheckBox) c);
} else if (c.getClass().equals(LImage.class)) {
images.put(c.getUUID(), (LImage) c);
ImageManager.handleImage((LImage) c);
} else if (c.getClass().equals(LSlider.class)) {
//Normalize slider height...
//Buttons have a max height of 20
switch (((LSlider) c).getSliderType()) {
case HORIZONTAL:
c.setSize(new Dimension(c.getSize().getWidth(), Math.min(c.getSize().getHeight(), 20)));
break;
case VERTICAL:
c.setSize(new Dimension(Math.min(c.getSize().getWidth(), 20), c.getSize().getHeight()));
break;
}
sliders.put(c.getUUID(), (LSlider) c);
}
if (c.getParent() == null || (c.getParent() != null && c.getParent().equals(baseWindow))) {
baseWindow.addControl(c);
}
globalCounter++;
}