Java Code Examples for javax.swing.AbstractButton#setAlignmentY()

The following examples show how to use javax.swing.AbstractButton#setAlignmentY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolAdapterEditorDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@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;
}