Example usage for javax.swing Box Box

List of usage examples for javax.swing Box Box

Introduction

In this page you can find the example usage for javax.swing Box Box.

Prototype

public Box(int axis) 

Source Link

Document

Creates a Box that displays its components along the specified axis.

Usage

From source file:AppearanceExplorer.java

TexCoordGenerationEditor(Appearance initApp, boolean initEnable, int initMode, Vector4f initPlaneS,
        Vector4f initPlaneT) {/*w ww.  ja  v a  2  s .c  o m*/

    super(BoxLayout.Y_AXIS);
    app = initApp;
    enable = initEnable;
    mode = initMode;
    planeS.set(initPlaneS);
    planeT.set(initPlaneT);
    setTexGen(); // set up the initial texGen

    JCheckBox enableCheckBox = new JCheckBox("Enable Tex Coord Gen");
    enableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enable = ((JCheckBox) e.getSource()).isSelected();
            texGen.setEnable(enable);
        }
    });
    add(new LeftAlignComponent(enableCheckBox));

    // texture boundaries
    String[] modeNames = { "OBJECT_LINEAR", "EYE_LINEAR", "SPHERE_MAP", };
    int[] modeValues = { TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.EYE_LINEAR,
            TexCoordGeneration.SPHERE_MAP, };

    // tex gen modes
    IntChooser modeChooser = new IntChooser("Generation Mode:", modeNames, modeValues);
    modeChooser.setValue(mode);
    modeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            mode = value;
            setTexGen();
        }
    });
    add(modeChooser);

    // make a panel for both sets of sliders and then two sub-panels,
    // one for each group of sliders
    Box sliderPanel = new Box(BoxLayout.Y_AXIS);
    add(sliderPanel);

    Box planeSPanel = new Box(BoxLayout.Y_AXIS);
    Box planeTPanel = new Box(BoxLayout.Y_AXIS);
    sliderPanel.add(planeSPanel);
    sliderPanel.add(planeTPanel);

    planeSPanel.add(new LeftAlignComponent(new JLabel("Plane S:")));
    FloatLabelJSlider planeSxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeS.x);
    planeSxSlider.setMajorTickSpacing(0.1f);
    planeSxSlider.setPaintTicks(true);
    planeSxSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.x = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSxSlider);

    FloatLabelJSlider planeSySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeS.y);
    planeSySlider.setMajorTickSpacing(0.1f);
    planeSySlider.setPaintTicks(true);
    planeSySlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.y = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSySlider);

    FloatLabelJSlider planeSzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeS.z);
    planeSzSlider.setMajorTickSpacing(0.1f);
    planeSzSlider.setPaintTicks(true);
    planeSzSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.z = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSzSlider);

    FloatLabelJSlider planeSwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeS.w);
    planeSwSlider.setMajorTickSpacing(0.1f);
    planeSwSlider.setPaintTicks(true);
    planeSwSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.w = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSwSlider);

    planeSPanel.add(new LeftAlignComponent(new JLabel("Plane T:")));
    FloatLabelJSlider planeTxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeT.x);
    planeTxSlider.setMajorTickSpacing(0.1f);
    planeTxSlider.setPaintTicks(true);
    planeTxSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.x = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTxSlider);

    FloatLabelJSlider planeTySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeT.y);
    planeTySlider.setMajorTickSpacing(0.1f);
    planeTySlider.setPaintTicks(true);
    planeTySlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.y = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTySlider);

    FloatLabelJSlider planeTzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeT.z);
    planeTzSlider.setMajorTickSpacing(0.1f);
    planeTzSlider.setPaintTicks(true);
    planeTzSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.z = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTzSlider);

    FloatLabelJSlider planeTwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeT.w);
    planeTwSlider.setMajorTickSpacing(0.1f);
    planeTwSlider.setPaintTicks(true);
    planeTwSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.w = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTwSlider);
}

From source file:AppearanceExplorer.java

public Color4fEditor(String initName, Color4f initColor) {
    super(BoxLayout.Y_AXIS);
    name = initName;//from  ww  w  .ja va  2  s  . c o m
    color.set(initColor);
    color3f.x = color.x;
    color3f.y = color.y;
    color3f.z = color.z;

    JPanel colorPanel = new JPanel();
    colorPanel.setLayout(new BorderLayout());
    add(colorPanel);

    JLabel label = new JLabel(name);

    preview = new JPanel();
    preview.setPreferredSize(new Dimension(40, 40));
    preview.setBackground(color3f.get());
    preview.setBorder(BorderFactory.createRaisedBevelBorder());

    button = new JButton("Set");
    button.addActionListener(this);

    JPanel filler = new JPanel();
    filler.setPreferredSize(new Dimension(100, 20));

    Box box = new Box(BoxLayout.X_AXIS);
    colorPanel.add(box, BorderLayout.WEST);

    box.add(label);
    box.add(preview);
    box.add(button);
    box.add(filler);

    FloatLabelJSlider alphaSlider = new FloatLabelJSlider("    Alpha");
    alphaSlider.setValue(color.w);
    alphaSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent event) {
            color.w = event.getValue();
            valueChanged();
        }
    });
    add(alphaSlider);
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void setToolBarAndMenus(final Container contentPane) {
    JToolBar toolBar;//w ww.  j a v  a2s. c om
    if (Environment.isRibbonUI()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        setRibbon((JRibbonFrame) container, getMenuManager());

        //         JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        //         topTabs = new TabbedNavigation();
        //         JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true);
        //         tabs.setAlignmentX(0.0f); // so it is left justified
        //
        //
        //          Box top = new Box(BoxLayout.Y_AXIS);
        //          JComponent bottom;
        //         top.add(tabs);
        //         bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false);
        //         contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        //         contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE);
        //         if (Environment.isNewLaf())
        //            contentPane.setBackground(Color.WHITE);

        //         if (Environment.isMac()){
        //            //System.setProperty("apple.laf.useScreenMenuBar","true");
        //            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
        //            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU);
        //            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());
        //
        //            ((JFrame)container).setJMenuBar(menu);
        //            projectListMenu = (JMenu) menu.getComponent(5);
        //         }

    } else if (Environment.isNewLook()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR);
        if (!getLafManager().isToolbarOpaque())
            toolBar.setOpaque(false);
        if (!isApplet())
            getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false);

        if (Environment.isExternal()) // external users only see project team
            getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false);

        toolBar.addSeparator(new Dimension(20, 20));
        toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0),
                new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)));
        toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel());
        toolBar.add(Box.createRigidArea(new Dimension(20, 20)));
        if (Environment.isNewLaf())
            toolBar.setBackground(Color.WHITE);
        toolBar.setFloatable(false);
        toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        Box top;
        JComponent bottom;

        top = new Box(BoxLayout.Y_AXIS);
        toolBar.setAlignmentX(0.0f); // so it is left justified
        top.add(toolBar);

        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        topTabs = new TabbedNavigation();
        JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true);
        tabs.setAlignmentX(0.0f); // so it is left justified

        top.add(tabs);
        bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM,
                false);
        contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE);
        if (Environment.isNewLaf())
            contentPane.setBackground(Color.WHITE);

        if (Environment.isMac()) {
            //System.setProperty("apple.laf.useScreenMenuBar","true");
            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU
                    : MenuManager.SERVER_STANDARD_MENU);
            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());

            ((JFrame) container).setJMenuBar(menu);
            projectListMenu = (JMenu) menu.getComponent(5);
        }

    } else {

        toolBar = getMenuManager().getToolBar(
                Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR);
        filterToolBarManager = FilterToolBarManager.create(getMenuManager());
        filterToolBarManager.addButtons(toolBar);
        contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR);
        viewToolBar.setOrientation(JToolBar.VERTICAL);
        viewToolBar.setRollover(true);
        contentPane.add(viewToolBar, BorderLayout.WEST);

        JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()
                ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU)
                : MenuManager.SERVER_STANDARD_MENU);

        if (!Environment.isMac()) {
            ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder());
            JMenuItem logo = (JMenuItem) menu.getComponent(0);
            logo.setBorder(BorderFactory.createEmptyBorder());
            logo.setMaximumSize(new Dimension(124, 52));
            logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }
        ((JFrame) container).setJMenuBar(menu);
        projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6);
    }

    //accelerators
    addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null);
    addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita
    addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null);
    addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita
    addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null);
    addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null);
    addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null);
    addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction());
    addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction());

    // To force a recalculation. This normally shouldn't be needed.
    addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction());
}