javax.swing.BoxLayout#PAGE_AXIS源码实例Demo

下面列出了javax.swing.BoxLayout#PAGE_AXIS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: megamek   文件: CommonSettingsDialog.java
private JPanel createSettingsPanel(ArrayList<ArrayList<Component>> comps) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    Box innerpanel = new Box(BoxLayout.PAGE_AXIS);
    for (ArrayList<Component> cs : comps) {
        Box subPanel = new Box(BoxLayout.LINE_AXIS);
        for (Component c : cs) {
            if (c instanceof JLabel) {
                subPanel.add(Box.createRigidArea(LABEL_SPACER));
                subPanel.add(c);
                subPanel.add(Box.createRigidArea(LABEL_SPACER));
            } else {
                subPanel.add(c);    
            }
        }
        subPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        innerpanel.add(subPanel);
    }
    innerpanel.add(Box.createVerticalGlue());
    innerpanel.setBorder(new EmptyBorder(10,10,10,10));
    panel.add(innerpanel,BorderLayout.PAGE_START);
    return panel;
}
 
private JPanel createParametersPanel() {
    JPanel paramsPanel = new JPanel();
    BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
    paramsPanel.setLayout(layout);
    AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon("/org/esa/snap/resources/images/icons/Add16.png"), false);
    addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
    paramsPanel.add(addParamBut);

    this.paramsTable =  new OperatorParametersTable(this.fakeOperatorDescriptor, appContext);
    JScrollPane tableScrollPane = new JScrollPane(paramsTable);
    tableScrollPane.setPreferredSize(new Dimension(500, 130));
    tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    paramsPanel.add(tableScrollPane);
    addParamBut.addActionListener((ActionEvent e) -> paramsTable.addParameterToTable());
    TitledBorder title = BorderFactory.createTitledBorder("Template Parameters");
    paramsPanel.setBorder(title);
    return paramsPanel;
}
 
源代码3 项目: snap-desktop   文件: ToolAdapterEditorDialog.java
@Override
protected JPanel createParametersPanel() {
    JPanel paramsPanel = new JPanel();
    BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
    paramsPanel.setLayout(layout);
    AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
    addParamBut.setAlignmentY(Component.TOP_ALIGNMENT);
    paramsPanel.add(addParamBut);
    int tableWidth = (formWidth - 2 * DEFAULT_PADDING);
    int widths[] = {27, 120, (int)(tableWidth * 0.25), (int)(tableWidth * 0.1), 100, (int)(tableWidth * 0.32), 30};
    for(int i=0; i < widths.length; i++) {
        paramsTable.getColumnModel().getColumn(i).setPreferredWidth(widths[i]);

    }
    JScrollPane tableScrollPane = new JScrollPane(paramsTable);
    tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    paramsPanel.add(tableScrollPane);
    addParamBut.addActionListener(e -> paramsTable.addParameterToTable(new ToolParameterDescriptor("parameterName", String.class), 0));
    TitledBorder title = BorderFactory.createTitledBorder(Bundle.CTL_Panel_OpParams_Border_TitleText());
    paramsPanel.setBorder(title);
    return paramsPanel;
}
 
@Override
protected JPanel createParametersPanel() {
    JPanel paramsPanel = new JPanel();
    BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
    paramsPanel.setLayout(layout);
    AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addParamBut.setText("New Parameter");
    addParamBut.setMaximumSize(new Dimension(150, controlHeight));
    addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
    addParamBut.setAlignmentY(Component.TOP_ALIGNMENT);
    paramsPanel.add(addParamBut);
    JScrollPane tableScrollPane = new JScrollPane(paramsTable);
    tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    paramsPanel.add(tableScrollPane);
    addParamBut.addActionListener(e -> paramsTable.addParameterToTable());
    return paramsPanel;
}
 
源代码5 项目: netbeans   文件: GenericToolbar.java
private void tweak() {
    if (UIUtils.isGTKLookAndFeel() || UIUtils.isNimbusLookAndFeel()) {
        int axis = getOrientation() == VERTICAL ? BoxLayout.PAGE_AXIS :
                                                  BoxLayout.LINE_AXIS;
        setLayout(new BoxLayout(this, axis));
    }
    
    if (UIUtils.isNimbusLookAndFeel())
        setBorder(BorderFactory.createEmptyBorder(-2, 0, -2, 0));
    else if (UIUtils.isAquaLookAndFeel())
        setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    
    if (UIUtils.isWindowsClassicLookAndFeel()) setRollover(true);
}
 
源代码6 项目: visualvm   文件: GenericToolbar.java
private void tweak() {
    if (UIUtils.isGTKLookAndFeel() || UIUtils.isNimbusLookAndFeel()) {
        int axis = getOrientation() == VERTICAL ? BoxLayout.PAGE_AXIS :
                                                  BoxLayout.LINE_AXIS;
        setLayout(new BoxLayout(this, axis));
    }
    
    if (UIUtils.isNimbusLookAndFeel())
        setBorder(BorderFactory.createEmptyBorder(-2, 0, -2, 0));
    else if (UIUtils.isAquaLookAndFeel())
        setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    
    if (UIUtils.isWindowsClassicLookAndFeel()) setRollover(true);
}
 
源代码7 项目: Briss-2.0   文件: DragAndDropPanel.java
private void init(ImageIcon icon, ActionListener actionListener) {
    BoxLayout boxLayout = new BoxLayout(this, BoxLayout.PAGE_AXIS);
    setLayout(boxLayout);
    JLabel dndText = new JLabel(icon);//"Drag and drop your PDF file here");
    dndText.setAlignmentX(Component.CENTER_ALIGNMENT);
    loadButton = new JButton("Load file");
    loadButton.addActionListener(actionListener);
    loadButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    loadButton.setPreferredSize(new Dimension(100, 50));
    add(Box.createVerticalGlue());
    add(dndText);
    add(Box.createRigidArea(new Dimension(0, 40)));
    add(loadButton);
    add(Box.createVerticalGlue());
}
 
源代码8 项目: ganttproject   文件: RoleSetPage.java
@Override
public Component getComponent() {
  Box domainBox = new Box(BoxLayout.PAGE_AXIS);
  JLabel label = new JLabel(GanttLanguage.getInstance().getText("chooseRoleSets"));

  final JList roleSetsList = new JList(myListModel);
  roleSetsList.setCellRenderer(myListModel.getCellRenderer());
  roleSetsList.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      int index = roleSetsList.locationToIndex(e.getPoint());
      myListModel.toggle(index);
    }
  });
  roleSetsList.setAlignmentX(0);
  label.setLabelFor(roleSetsList);
  label.setAlignmentX(0);

  domainBox.add(label);
  domainBox.add(Box.createVerticalStrut(5));
  domainBox.add(roleSetsList);

  JPanel result = new JPanel(new BorderLayout());
  result.add(domainBox, BorderLayout.CENTER);
  // result.setBorder(LineBorder.createBlackLineBorder());
  return result;
}
 
源代码9 项目: netbeans   文件: BoxLayoutSupport.java
/** Since BoxLayout is not a bean, we must specify its properties
     * explicitly. This method is called from getPropertySets() implementation
     * to obtain the default property set for the layout (assuming there's only
     * one property set). So it woul be also possible to override (more
     * generally) getPropertySets() instead.
     * @return array of properties of the layout manager
     */
    @Override
    protected FormProperty[] getProperties() {
        if (properties == null) {
            // we cannot use RADProperty because "axis" is not a real
            // bean property - we must create a special FormProperty
            properties = new FormProperty[1];

            properties[0] = new FormProperty(
                                PROP_AXIS,
                                Integer.TYPE,
                                getBundle().getString("PROP_axis"), // NOI18N
                                getBundle().getString("HINT_axis")) // NOI18N
            {
                @Override
                public Object getTargetValue() {
                    return new Integer(axis);
                }

                @Override
                public void setTargetValue(Object value) {
                    int ax = ((Integer)value).intValue();
                    if (ax == BoxLayout.X_AXIS || ax == BoxLayout.Y_AXIS
                            || ax == BoxLayout.LINE_AXIS || ax == BoxLayout.PAGE_AXIS) {
                        axis = ax;
                    }
                }

                @Override
                public boolean supportsDefaultValue() {
                    return true;
                }

                @Override
                public Object getDefaultValue() {
                    return new Integer(BoxLayout.LINE_AXIS);
                }

                @Override
                public PropertyEditor getExpliciteEditor() {
                    return new BoxAxisEditor();
                }
            };
            // [!!]
//            properties[0].setPropertyContext(
//                new FormPropertyContext.DefaultImpl(getContainer().getFormModel()));
        }

        return properties;
    }
 
源代码10 项目: netbeans   文件: ConnectionErrorDlg.java
private ConnectionErrorDlg(Segment[] segments) {
    super(BoxLayout.PAGE_AXIS);
    initComponents(segments);
}
 
源代码11 项目: netbeans   文件: QuickSearchComboBar.java
public static Issue selectIssue(String message, Repository repository, JPanel caller, HelpCtx helpCtx) {
    QuickSearchComboBar bar = new QuickSearchComboBar(caller);
    bar.setRepository(repository);
    bar.setAlignmentX(0f);
    bar.setMaximumSize(new Dimension(Short.MAX_VALUE, bar.getPreferredSize().height));
    JPanel panel = new JPanel();
    BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
    panel.setLayout(layout);
    JLabel label = new JLabel();
    Mnemonics.setLocalizedText(label, message);
    panel.add(label);
    label.setLabelFor(bar.getIssueComponent());
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    int gap = layoutStyle.getPreferredGap(label, bar, LayoutStyle.ComponentPlacement.RELATED, SwingConstants.SOUTH, panel);
    panel.add(Box.createVerticalStrut(gap));
    panel.add(bar);
    panel.add(Box.createVerticalStrut(gap));
    ResourceBundle bundle = NbBundle.getBundle(QuickSearchComboBar.class);
    JLabel hintLabel = new JLabel(bundle.getString("MSG_SelectIssueHint")); // NOI18N
    hintLabel.setEnabled(false);
    panel.add(hintLabel);
    panel.add(Box.createVerticalStrut(80));
    panel.setBorder(BorderFactory.createEmptyBorder(
            layoutStyle.getContainerGap(panel, SwingConstants.NORTH, null),
            layoutStyle.getContainerGap(panel, SwingConstants.WEST, null),
            0,
            layoutStyle.getContainerGap(panel, SwingConstants.EAST, null)));
    panel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_IssueSelector"));
    Issue issue = null;
    JButton ok = new JButton(bundle.getString("LBL_Select")); // NOI18N
    ok.getAccessibleContext().setAccessibleDescription(ok.getText());
    JButton cancel = new JButton(bundle.getString("LBL_Cancel")); // NOI18N
    cancel.getAccessibleContext().setAccessibleDescription(cancel.getText());
    DialogDescriptor descriptor = new DialogDescriptor(
            panel,
            bundle.getString("LBL_Issues"), // NOI18N
            true,
            NotifyDescriptor.OK_CANCEL_OPTION,
            ok,
            null);
    descriptor.setOptions(new Object [] {ok, cancel});
    descriptor.setHelpCtx(helpCtx);
    DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
    if (descriptor.getValue() == ok) {
        issue = bar.getIssue();
    }
    return issue;
}
 
源代码12 项目: marvinproject   文件: MarvinAttributesPanel.java
public MarvinAttributesPanel(){
	super(BoxLayout.PAGE_AXIS);
	
	hashComponents = new Hashtable<String, MarvinPluginWindowComponent>(10,5);
	newComponentRow();
}
 
源代码13 项目: snap-desktop   文件: ToolAdapterEditorDialog.java
@Override
protected JPanel createVariablesPanel() {
    JPanel variablesBorderPanel = new JPanel();
    BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
    variablesBorderPanel.setLayout(layout);
    variablesBorderPanel.setBorder(BorderFactory.createTitledBorder(Bundle.CTL_Panel_SysVar_Border_TitleText()));

    AbstractButton addVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
    addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
    addVariableButton.setMaximumSize(new Dimension(150, controlHeight));

    AbstractButton addDependentVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
    addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
    addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));

    JPanel buttonsPannel = new JPanel(new SpringLayout());
    buttonsPannel.add(addVariableButton);
    buttonsPannel.add(addDependentVariableButton);
    SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
    buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(buttonsPannel);

    varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    varTable.setRowHeight(20);
    JScrollPane scrollPane = new JScrollPane(varTable);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(scrollPane);
    variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    Dimension variablesPanelDimension = new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
    variablesBorderPanel.setMinimumSize(variablesPanelDimension);
    variablesBorderPanel.setMaximumSize(variablesPanelDimension);
    variablesBorderPanel.setPreferredSize(variablesPanelDimension);

    addVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
        varTable.revalidate();
    });

    addDependentVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
        varTable.revalidate();
    });

    return variablesBorderPanel;
}
 
@Override
protected JPanel createVariablesPanel() {
    JPanel variablesBorderPanel = new JPanel();
    BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
    variablesBorderPanel.setLayout(layout);

    AbstractButton addVariableButton =
            ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
    addVariableButton.setMaximumSize(new Dimension(150, controlHeight));
    addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);

    AbstractButton addDependentVariableButton =
            ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
    addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));
    addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);

    JPanel buttonsPannel = new JPanel(new SpringLayout());
    buttonsPannel.add(addVariableButton);
    buttonsPannel.add(addDependentVariableButton);
    SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
    buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(buttonsPannel);

    varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    varTable.setRowHeight(controlHeight);
    int widths[] = {controlHeight, 3 * controlHeight, 10 * controlHeight};
    for (int i = 0; i < widths.length; i++) {
        TableColumn column = varTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(widths[i]);
        column.setWidth(widths[i]);

    }
    JScrollPane scrollPane = new JScrollPane(varTable);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(scrollPane);
    variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    Dimension variablesPanelDimension =
            new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
    variablesBorderPanel.setMinimumSize(variablesPanelDimension);
    variablesBorderPanel.setMaximumSize(variablesPanelDimension);
    variablesBorderPanel.setPreferredSize(variablesPanelDimension);

    addVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
        varTable.revalidate();
    });

    addDependentVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
        varTable.revalidate();
    });

    return variablesBorderPanel;
}
 
 方法所在类