Java Code Examples for javax.swing.BoxLayout

The following examples show how to use javax.swing.BoxLayout. These examples are extracted from open source projects. 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 Project: netbeans   Source File: QBNodeComponent.java    License: Apache License 2.0 6 votes vote down vote up
public QBNodeComponent(String nodeName, QueryBuilderTableModel queryBuilderTableModel)
   {
       // Set some private variables
       _queryBuilderTableModel = queryBuilderTableModel;
_nodeName = nodeName;

       // Create a JTable component, with the specified TableModel behind it
       _qbTable = new QueryBuilderTable(_queryBuilderTableModel);
       _qbTable.setBackground(Color.white); 
       
       // Wrap the JTable in a JScrollPane
       JScrollPane sp = new JScrollPane(_qbTable);
       sp.getViewport().setBackground(Color.white); 
       
       // Wrap the JScrollPane in a JPanel
       this.add(sp,BorderLayout.CENTER);
       this.setBackground(Color.white);
       this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setPreferredSize(new Dimension(175,80));

// Only applies to JInternalFrame
       // setResizable(true);
       
       // setVisible(true);
   }
 
Example 2
Source Project: jdk8u-jdk   Source File: Test4903007.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected JPanel getObject() {
    Box vBox = Box.createVerticalBox();
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));
    vBox.add(Box.createVerticalGlue());
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));

    Box hBox = Box.createHorizontalBox();
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));
    hBox.add(Box.createHorizontalGlue());
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(vBox);
    panel.add(Box.createGlue());
    panel.add(hBox);
    return panel;
}
 
Example 3
public EditPacketBlackList(Gui gui) {
    super("PacketLogger blacklist");
    this.gui = gui;
    this.setLayout(new BoxLayout(this.getContentPane(), 1));
    this.buttonsPanel.setLayout(new FlowLayout());
    this.construct();
    this.addToLists();
    this.reset.addActionListener(this);
    this.accept.addActionListener(this);
    this.buttonsPanel.add(this.reset);
    this.buttonsPanel.add(this.accept);
    this.add(this.buttonsPanel);
    this.pack();
    this.setLocationRelativeTo(null);
    this.setResizable(false);
    this.setAlwaysOnTop(true);
    this.setVisible(true);
}
 
Example 4
Source Project: jadx   Source File: ProgressPanel.java    License: Apache License 2.0 6 votes vote down vote up
public ProgressPanel(final MainWindow mainWindow, boolean showCancelButton) {
	this.showCancelButton = showCancelButton;

	progressLabel = new JLabel();
	progressBar = new JProgressBar(0, 100);
	progressBar.setIndeterminate(true);
	progressBar.setStringPainted(false);
	progressLabel.setLabelFor(progressBar);

	setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
	setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
	setVisible(false);
	add(progressLabel);
	add(progressBar);

	cancelButton = new JButton(ICON_CANCEL);
	cancelButton.setPreferredSize(new Dimension(ICON_CANCEL.getIconWidth(), ICON_CANCEL.getIconHeight()));
	cancelButton.setToolTipText("Cancel background jobs");
	cancelButton.setBorderPainted(false);
	cancelButton.setFocusPainted(false);
	cancelButton.setContentAreaFilled(false);
	cancelButton.addActionListener(e -> mainWindow.cancelBackgroundJobs());
	cancelButton.setVisible(showCancelButton);
	add(cancelButton);
}
 
Example 5
Source Project: jdal   Source File: SeparatorTitled.java    License: Apache License 2.0 6 votes vote down vote up
public SeparatorTitled(String title, boolean bold) {

	super(BoxLayout.LINE_AXIS);
	JLabel titleLabel = new JLabel(title);
	
	if (bold)
		FormUtils.setBold(titleLabel);
	
	titleLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
	this.add(titleLabel);
	this.add(Box.createHorizontalStrut(5));
	JSeparator separator = new JSeparator();
	separator.setAlignmentY(Container.TOP_ALIGNMENT);
	this.add(separator);
	this.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
}
 
Example 6
Source Project: osv   Source File: MapPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
public MapPanel(MainWindow mw) {

		this.mw = mw;
		this.setOpaque(false);

		cp = new JPanel();
		cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
		cp.setOpaque(false);
		verticalSpace = new OSVEmptyPanel(mw, 0, 0.28f);
		cp.add(verticalSpace);

		mapDisplay = new MapDisplay();
		mapDisplay.setOpaque(false);

		cp.add(mapDisplay);

		add(cp);
	}
 
Example 7
@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;
}
 
Example 8
Source Project: opensim-gui   Source File: MeasurementSetPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    measurementSetWithTitlePanel = new javax.swing.JPanel();

    measurementSetWithTitlePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    measurementSetWithTitlePanel.setLayout(new javax.swing.BoxLayout(measurementSetWithTitlePanel, javax.swing.BoxLayout.Y_AXIS));

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
            .addContainerGap()
            .add(measurementSetWithTitlePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(layout.createSequentialGroup()
            .addContainerGap()
            .add(measurementSetWithTitlePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
            .addContainerGap())
    );
}
 
Example 9
Source Project: sldeditor   Source File: ExpressionSubPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/** Sets the up literal panel. */
protected void setUpLiteralPanel() {
    panelLiteral = new JPanel();
    panelLiteral.setBorder(null);
    panelLiteral.setLayout(new BoxLayout(panelLiteral, BoxLayout.X_AXIS));

    rdbtnLiteral =
            new JRadioButton(
                    Localisation.getString(
                            ExpressionPanelv2.class, "ExpressionPanelv2.literal"));
    rdbtnLiteral.setMinimumSize(new Dimension(100, 20));
    rdbtnLiteral.setPreferredSize(new Dimension(100, 20));
    panelLiteral.add(rdbtnLiteral);
    rdbtnLiteral.setActionCommand(LITERAL);
    buttonGroup.add(rdbtnLiteral);
    box.add(panelLiteral);
}
 
Example 10
public PeakSelectionComponent() {

    super(new BorderLayout());

    selectionListModel = new DefaultListModel<PeakSelection>();
    selectionList = new JList<>(selectionListModel);
    selectionList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    selectionList.setPreferredSize(new Dimension(200, 50));
    JScrollPane scrollPane = new JScrollPane(selectionList);
    add(scrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
    addButton = GUIUtils.addButton(buttonPanel, "Add", null, this);
    removeButton = GUIUtils.addButton(buttonPanel, "Remove", null, this);
    allButton = GUIUtils.addButton(buttonPanel, "Set to all", null, this);
    clearButton = GUIUtils.addButton(buttonPanel, "Clear", null, this);

    add(buttonPanel, BorderLayout.EAST);
  }
 
Example 11
Source Project: pega-tracerviewer   Source File: TracerDataMainPanel.java    License: Apache License 2.0 6 votes vote down vote up
private JPanel getTracerInfoJPanel() {

        JPanel infoJPanel = new JPanel();

        LayoutManager layout = new BoxLayout(infoJPanel, BoxLayout.X_AXIS);
        infoJPanel.setLayout(layout);

        // Dimension preferredSize = new Dimension(300, 30);
        // infoJPanel.setPreferredSize(preferredSize);

        JPanel incompleteTracerJPanel = getIncompleteTracerJPanel();
        JPanel charsetJPanel = getCharsetJPanel();
        JPanel sizeJPanel = getSizeJPanel();

        infoJPanel.add(incompleteTracerJPanel);
        infoJPanel.add(charsetJPanel);
        infoJPanel.add(sizeJPanel);

        return infoJPanel;
    }
 
Example 12
Source Project: arcusplatform   Source File: MockActionsDialog.java    License: Apache License 2.0 5 votes vote down vote up
private Component createActions(List<MockAction> actions) {
   JPanel panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
   for (MockAction mockAction : actions) {
      Action action = Actions.build(mockAction.getName(), new DoItDammit(mockAction));
      panel.add(new JButton(action));
   }
   return panel;
}
 
Example 13
Source Project: arcusplatform   Source File: Wizard.java    License: Apache License 2.0 5 votes vote down vote up
protected Wizard(WizardStep<I, ?> first, WizardStep<?, O> last) {
   this.first = first;
   this.current = first;
   this.last = last;

   GridBagConstraints gbc = new GridBagConstraints();
   
   gbc.gridx = 0;
   gbc.gridy = 0;
   gbc.fill = GridBagConstraints.BOTH;
   gbc.weightx = 1.0;
   gbc.weighty = 1.0;
   contents.add(new JLabel(), gbc.clone());
   
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.weightx = 1.0;
   gbc.weighty = 0.0;
   gbc.gridy++;
   contents.add(new JSeparator(JSeparator.HORIZONTAL), gbc.clone());
   
   JPanel buttons = new JPanel();
   buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
   buttons.add(back);
   buttons.add(Box.createHorizontalGlue());
   buttons.add(next);
   
   gbc.gridy++;
   contents.add(buttons, gbc.clone());
}
 
Example 14
Source Project: niftyeditor   Source File: FileChooserEditor.java    License: Apache License 2.0 5 votes vote down vote up
private JPanel createAccessor(){
    JPanel result = new JPanel();
    BoxLayout layout = new BoxLayout(result, BoxLayout.Y_AXIS);
    result.setLayout(layout);
    absolute = new JRadioButton("Absolute path");
    relative = new JRadioButton("Relative to Assets folder");
    copy = new JRadioButton("Copy file in Assets folder");
    copy.addActionListener(this);
    JTextField absText = new JTextField();
    absText.setEditable(false);
    JTextField relText = new JTextField();
    relText.setEditable(false);
    copyText = new JTextField();
    copyText.setMaximumSize(new Dimension(400, 25));
    copyText.setEnabled(false);
    group = new ButtonGroup();
    group.add(copy);
    group.add(relative);
    group.add(absolute);
    absolute.setSelected(true);
    result.add(new ImagePreview(jFileChooser1));
    result.add(absolute);
    result.add(relative);
    result.add(copy);
    result.add(copyText);
    result.add(new JPanel());
    return result;
}
 
Example 15
Source Project: jdk8u-jdk   Source File: TestBox.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    TestEncoder.test(
            new Box(BoxLayout.LINE_AXIS),
            new Box(BoxLayout.PAGE_AXIS) {
                @Override
                public FlowLayout getLayout() {
                    return new FlowLayout() {
                        private final Object axis = OBJECT;
                    };
                }
            },
            OBJECT
    );
}
 
Example 16
private JPanel createColourSpaceButtons() {
	final JPanel colourspacesPanel = new JPanel();
	colourspacesPanel.setOpaque(false);
	colourspacesPanel.setLayout(new BoxLayout(colourspacesPanel, BoxLayout.X_AXIS));
	colourspacesPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
	final ButtonGroup group = new ButtonGroup();
	createRadioButton(colourspacesPanel, group, ColourSpace.HUE);
	createRadioButton(colourspacesPanel, group, ColourSpace.HS);
	createRadioButton(colourspacesPanel, group, ColourSpace.H1H2);
	return colourspacesPanel;
}
 
Example 17
Source Project: sldeditor   Source File: ExpressionSubPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** Sets the up maths panel. */
protected void setUpMathsPanel() {
    JPanel panelMaths = new JPanel();
    panelMaths.setBorder(null);
    panelMaths.setLayout(new BoxLayout(panelMaths, BoxLayout.X_AXIS));
    rdbtnMaths =
            new JRadioButton(
                    Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.maths"));
    panelMaths.add(rdbtnMaths);
    rdbtnMaths.setMinimumSize(new Dimension(100, 20));
    rdbtnMaths.setPreferredSize(new Dimension(100, 20));
    rdbtnMaths.setActionCommand(MATHS);
    buttonGroup.add(rdbtnMaths);

    mathsExpressionPanel =
            new MathsExpressionPanel(
                    new SubPanelUpdatedInterface() {
                        @Override
                        public void updateSymbol() {
                            buttonGroup.setSelected(rdbtnMaths.getModel(), true);
                            updateButtonState(true);
                        }

                        @Override
                        public void parameterAdded() {
                            // Do nothing
                        }
                    });

    panelMaths.add(mathsExpressionPanel);
    box.add(panelMaths);
}
 
Example 18
Source Project: Repeat   Source File: SwingUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get input from a number of fields from user
 * @param titles titles of the fields that requires input
 * @return a list of input values entered by user, or null if user cancels input windows
 */
public static String[] getInputs(String[] titles) {
	if (titles.length == 0) {
		return null;
	}

	JTextField[] textFields = new JTextField[titles.length];
	String[] output = new String[titles.length];

	JPanel mainPanel = new JPanel();
	mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

	for (int i = 0; i < titles.length; i++) {
		JPanel myPanel = new JPanel();
		if (titles[i] != null) {
			myPanel.add(new JLabel(titles[i]));
		} else {
			myPanel.add(new JLabel(i + ")"));
		}
		textFields[i] = new JTextField(10);
		textFields[i].setText("");
		myPanel.add(textFields[i]);
		mainPanel.add(myPanel);
	}

	int result = JOptionPane.showConfirmDialog(null, mainPanel,
			"Enter values", JOptionPane.OK_CANCEL_OPTION);

	if (result == JOptionPane.OK_OPTION) {
		for (int i = 0; i < titles.length; i++) {
			output[i] = textFields[i].getText();
		}
		return output;
	} else {
		return null;
	}
}
 
Example 19
Source Project: PacketProxy   Source File: GUIOptionListenPortDialog.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent label_and_object(String label_name, JComponent object) {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
	JLabel label = new JLabel(label_name);
	label.setPreferredSize(new Dimension(150, label.getMaximumSize().height));
	panel.add(label);
	object.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMaximumSize().height * 2));
	panel.add(object);
	return panel;
}
 
Example 20
Source Project: PacketProxy   Source File: GUIOptionListenPortDialog.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent buttons() {
	JPanel panel_button = new JPanel();
	panel_button.setLayout(new BoxLayout(panel_button, BoxLayout.X_AXIS));
	panel_button.setMaximumSize(new Dimension(Short.MAX_VALUE, button_set.getMaximumSize().height));
	panel_button.add(button_cancel);
	panel_button.add(button_set);
	return panel_button;
}
 
Example 21
public void addLayer(String title, Font font, RenderedImage image) {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
	RenderedImageIcon icon = new RenderedImageIcon(image,
			LegendGraphicMetadata.DEFAULT_WIDTH, LegendGraphicMetadata.DEFAULT_HEIGHT);
	JLabel label = new JLabel(icon);
	label.setBorder(new EmptyBorder(ICON_PADDING, ICON_PADDING, ICON_PADDING, ICON_PADDING));
	panel.add(label);
	panel.add(Box.createRigidArea(new Dimension(MEMBER_MARGIN, 0)));
	JLabel itemText = new JLabel(title);
	itemText.setFont(font);
	panel.add(itemText);
	panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
	legendPanel.add(panel);
}
 
Example 22
Source Project: PacketProxy   Source File: GUIFilterConfigEditDialog.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent label_and_object(String label_name, JComponent object, int height) {
	JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    JLabel label = new JLabel(label_name);
    label.setPreferredSize(new Dimension(150, label.getMaximumSize().height));
    panel.add(label);
    object.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMaximumSize().height * height));
    panel.add(object);
	return panel;
}
 
Example 23
Source Project: netbeans   Source File: SettingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private static int defaultHeight() {
    if (DEFAULT_HEIGHT == -1) {
        JPanel ref = new JPanel(null);
        ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS));
        ref.setOpaque(false);
        
        ref.add(new JLabel("XXX")); // NOI18N
        
        ref.add(new JButton("XXX")); // NOI18N
        ref.add(new PopupButton("XXX")); // NOI18N
        
        ref.add(new JCheckBox("XXX")); // NOI18N
        ref.add(new JRadioButton("XXX")); // NOI18N
        
        ref.add(new JTextField("XXX")); // NOI18N
        
        ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1)));
        
        Component separator = Box.createHorizontalStrut(1);
        Dimension d = separator.getMaximumSize(); d.height = 20;
        separator.setMaximumSize(d);
        ref.add(separator);
        
        DEFAULT_HEIGHT = ref.getPreferredSize().height;
    }
    return DEFAULT_HEIGHT;
}
 
Example 24
Source Project: netbeans   Source File: ExpandableMessage.java    License: Apache License 2.0 5 votes vote down vote up
ExpandableMessage(String topMsgKey,
                  Collection<String> messages,
                  String bottomMsgKey,
                  JButton toggleButton) {
    super(null);
    this.messages = messages;
    this.toggleButton = toggleButton;
    lblTopMsg = new JLabel(getMessage(topMsgKey));
    lblBotMsg = (bottomMsgKey != null)
                ? new JLabel(getMessage(bottomMsgKey))
                : null;

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(lblTopMsg);
    lblTopMsg.setAlignmentX(LEFT_ALIGNMENT);

    if (lblBotMsg != null) {
        add(makeVerticalStrut(lblTopMsg, lblBotMsg));
        add(lblBotMsg);
        lblBotMsg.setAlignmentX(LEFT_ALIGNMENT);
    }

    Mnemonics.setLocalizedText(toggleButton,
                               getMessage("LBL_ShowMoreInformation")); //NOI18N
    toggleButton.addActionListener(this);
}
 
Example 25
/**
   * Constructor
   * @param manager the settlement construction manager.
   */
  public ConstructionSitesPanel(ConstructionManager manager) {
      // Use JPanel constructor.
      super();
      
      this.manager = manager;
      
      setLayout(new BorderLayout());
      setBorder(new MarsPanelBorder());
      
      JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
      add(titlePanel, BorderLayout.NORTH);
      
      JLabel titleLabel = new JLabel("Construction Sites");
titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
      titlePanel.add(titleLabel);
      
      // Create scroll panel for sites list pane.
      sitesScrollPane = new JScrollPane();
      sitesScrollPane.setPreferredSize(new Dimension(200, 75));
      sitesScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      add(sitesScrollPane, BorderLayout.CENTER);  
      
      // Prepare sites outer list pane.
      JPanel sitesOuterListPane = new JPanel(new BorderLayout(0, 0));
      sitesScrollPane.setViewportView(sitesOuterListPane);
      
      // Prepare sites list pane.
      sitesListPane = new JPanel();
      sitesListPane.setLayout(new BoxLayout(sitesListPane, BoxLayout.Y_AXIS));
      sitesOuterListPane.add(sitesListPane, BorderLayout.NORTH);
      
      // Create the site panels.
      sitesCache = manager.getConstructionSites();
      Iterator<ConstructionSite> i = sitesCache.iterator();
      while (i.hasNext()) sitesListPane.add(new ConstructionSitePanel(i.next()));
  }
 
Example 26
private AbstractAdapterEditor(AppContext appContext, JDialog parent, String title) {
    super(parent.getOwner(), title, ID_OK_CANCEL_HELP, new Object[] { new JButton(Bundle.CTL_Button_Export_Text()) }, helpID);
    this.context = appContext;
    this.logger = Logger.getLogger(ToolAdapterEditorDialog.class.getName());
    this.registerButton(ID_OTHER, new JButton(Bundle.CTL_Button_Export_Text()));
    controlHeight = (getJDialog().getFont().getSize() + 1) * 2;
    errorPanel = new JPanel();
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.Y_AXIS));
    getButtonPanel().add(errorPanel, 0);
}
 
Example 27
Source Project: AML-Project   Source File: AddClassMapping.java    License: Apache License 2.0 5 votes vote down vote up
private void buildTargetResultsPanel()
{
       //Results panel: contains the list of all classes that match que query
       tResults = new JPanel();
       tResults.setLayout(new BoxLayout(tResults, BoxLayout.PAGE_AXIS));
       //Create a label
       JLabel tLabel = new JLabel("Select a target class from the list of search results or go back to the full class list:");
       JPanel tLPanel = new JPanel();
       tLPanel.add(tLabel);
       tResults.add(tLPanel);
       Vector<String> sNames = new Vector<String>(targetRes.size());
       for(int i : targetRes)
       	sNames.add(target.getBestName(i));
       //Create the search area and button
	targetResult = new JTextArea(1,37);
	targetResult.setText(targetSearch.getText());
	targetResult.setEditable(false);
	targetResult.setBackground(Color.LIGHT_GRAY);
	backT = new JButton("Back");
	backT.setPreferredSize(new Dimension(70,28));
	backT.addActionListener(this);
	//Put them in a subpanel, side by side
	JPanel tSearchPanel = new JPanel();
	tSearchPanel.add(targetResult);
       tSearchPanel.add(backT);
       tResults.add(tSearchPanel);
       //Build the combo box with all the primary class names from the results
       targetResults = new JComboBox<String>(sNames);
       targetResults.setPreferredSize(new Dimension(500,28));
       //Put it in a subpanel so that it doesn't resize automatically
       JPanel tClassPanel = new JPanel();
       tClassPanel.add(targetResults);
       tResults.add(tClassPanel);
}
 
Example 28
Source Project: jdk8u-jdk   Source File: TableExample.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the connectionPanel, which will contain all the fields for
 * the connection information.
 */
public void createConnectionDialog() {
    // Create the labels and text fields.
    userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
    userNameField = new JTextField("app");

    passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
    passwordField = new JTextField("app");

    serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
    serverField = new JTextField("jdbc:derby://localhost:1527/sample");

    driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
    driverField = new JTextField("org.apache.derby.jdbc.ClientDriver");


    connectionPanel = new JPanel(false);
    connectionPanel.setLayout(new BoxLayout(connectionPanel,
            BoxLayout.X_AXIS));

    JPanel namePanel = new JPanel(false);
    namePanel.setLayout(new GridLayout(0, 1));
    namePanel.add(userNameLabel);
    namePanel.add(passwordLabel);
    namePanel.add(serverLabel);
    namePanel.add(driverLabel);

    JPanel fieldPanel = new JPanel(false);
    fieldPanel.setLayout(new GridLayout(0, 1));
    fieldPanel.add(userNameField);
    fieldPanel.add(passwordField);
    fieldPanel.add(serverField);
    fieldPanel.add(driverField);

    connectionPanel.add(namePanel);
    connectionPanel.add(fieldPanel);
}
 
Example 29
Source Project: astor   Source File: AgeCalculator.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void addBottomArea(Container container) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

    ItemListener listener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateResults();
        }
    };

    iFieldSets = new FieldSet[] {
        new FieldSet("Month Based", new FieldGroup[] {
            new FieldGroup(listener, "Years", YEARS),
            new FieldGroup(listener, "Months", MONTHS),
            new FieldGroup(listener, "Days", DAYS),
            new FieldGroup(listener, "Hours", HOURS),
            new FieldGroup(listener, "Minutes", MINUTES),
            new FieldGroup(listener, "Seconds", SECONDS)
        })
        ,
        new FieldSet("Week Based", new FieldGroup[] {
            new FieldGroup(listener, "Weekyears", WEEKYEARS),
            new FieldGroup(listener, "Weeks", WEEKS),
            new FieldGroup(listener, "Days", DAYS),
            new FieldGroup(listener, "Hours", HOURS),
            new FieldGroup(listener, "Minutes", MINUTES),
            new FieldGroup(listener, "Seconds", SECONDS)
        })
    };

    for (int i=0; i<iFieldSets.length; i++) {
        if (i > 0) {
            panel.add(Box.createHorizontalStrut(10));
        }
        iFieldSets[i].addTo(panel);
    }
    panel.add(Box.createVerticalGlue());

    container.add(fixedHeight(panel));
}
 
Example 30
Source Project: openjdk-8   Source File: TestBox.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    TestEncoder.test(
            new Box(BoxLayout.LINE_AXIS),
            new Box(BoxLayout.PAGE_AXIS) {
                @Override
                public FlowLayout getLayout() {
                    return new FlowLayout() {
                        private final Object axis = OBJECT;
                    };
                }
            },
            OBJECT
    );
}