当前位置: 首页>>代码示例>>Java>>正文


Java LControl.setSize方法代码示例

本文整理汇总了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);
}
 
开发者ID:NickAcPT,项目名称:Lithium-Backend,代码行数:7,代码来源:LOverlay.java

示例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++;
}
 
开发者ID:NickAcPT,项目名称:Lithium-Forge,代码行数:78,代码来源:NewLithiumGUI.java


注:本文中的net.nickac.lithium.backend.controls.LControl.setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。