Example usage for javax.swing Box createRigidArea

List of usage examples for javax.swing Box createRigidArea

Introduction

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

Prototype

public static Component createRigidArea(Dimension d) 

Source Link

Document

Creates an invisible component that's always the specified size.

Usage

From source file:HtmlDemo.java

public HtmlDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    String initialText = "<html>\n" + "Color and font test:\n" + "<ul>\n" + "<li><font color=red>red</font>\n"
            + "<li><font color=blue>blue</font>\n" + "<li><font color=green>green</font>\n"
            + "<li><font size=-2>small</font>\n" + "<li><font size=+2>large</font>\n" + "<li><i>italic</i>\n"
            + "<li><b>bold</b>\n" + "</ul>\n";

    htmlTextArea = new JTextArea(10, 20);
    htmlTextArea.setText(initialText);//from ww  w  .ja  v a  2 s  . co  m
    JScrollPane scrollPane = new JScrollPane(htmlTextArea);

    JButton changeTheLabel = new JButton("Change the label");
    changeTheLabel.setMnemonic(KeyEvent.VK_C);
    changeTheLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    changeTheLabel.addActionListener(this);

    theLabel = new JLabel(initialText) {
        public Dimension getPreferredSize() {
            return new Dimension(200, 200);
        }

        public Dimension getMinimumSize() {
            return new Dimension(200, 200);
        }

        public Dimension getMaximumSize() {
            return new Dimension(200, 200);
        }
    };
    theLabel.setVerticalAlignment(SwingConstants.CENTER);
    theLabel.setHorizontalAlignment(SwingConstants.CENTER);

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    leftPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Edit the HTML, then click the button"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    leftPanel.add(scrollPane);
    leftPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    leftPanel.add(changeTheLabel);

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
    rightPanel
            .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("A label with HTML"),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    rightPanel.add(theLabel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(leftPanel);
    add(Box.createRigidArea(new Dimension(10, 0)));
    add(rightPanel);
}

From source file:ComboBoxDemo2.java

public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z",
            "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);/*from  w ww.j  a v a 2  s .  c om*/
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // ==
                                                                          // LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

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

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(/*  www.  j  a  v a 2s . co m*/
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}

From source file:org.fhaes.fhrecorder.view.GraphPanel.java

/**
 * Constructor for the Graphics Panel. Sets up layout and settings of all components.
 *///w w w  .  j  ava2  s  . c  om
public GraphPanel() {

    data = FileController.getYearSummaryList();
    setLayout(new MigLayout("", "[grow,right]", "[fill][300px,grow,fill][][]"));

    JButton customizeButton = new JButton("Customize");
    customizeButton.setIcon(Builder.getImageIcon("configure.png"));
    customizeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            showCustomizeWindow();
        }
    });

    zoomOutButton = new JButton("");
    zoomOutButton.setIcon(Builder.getImageIcon("zoom_out.png"));
    zoomOutButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            setZoomLevel(zoomLevel + 1);
        }

    });
    add(zoomOutButton, "flowx,cell 0 0");

    zoomInButton = new JButton("");
    zoomInButton.setIcon(Builder.getImageIcon("zoom_in.png"));
    zoomInButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            setZoomLevel(zoomLevel - 1);
        }

    });
    add(zoomInButton, "cell 0 0");
    add(customizeButton, "cell 0 0,alignx right");

    rigidArea = Box.createRigidArea(new Dimension(20, 20));
    rigidArea.setMaximumSize(new Dimension(200, 20));
    rigidArea.setMinimumSize(new Dimension(1, 20));
    add(rigidArea, "cell 0 1");
    colorPane = new ColorBarGraph(data);

    colorPane.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            int notches = e.getWheelRotation();
            setZoomLevel(zoomLevel + notches);
        }

    });

    add(colorPane, "cell 0 1,growx");

    scrollBar = new JScrollBar();
    scrollBar.setMinimum(0);
    scrollBar.setMaximum(data.size());
    scrollBar.addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent event) {

            setChartsFirstCategoryIndex(event.getValue());
        }
    });

    overlayPane = new GraphSummaryOverlay(data);

    overlayPane.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            int notches = e.getWheelRotation();
            setZoomLevel(zoomLevel + notches);
        }

    });
    add(overlayPane, "cell 0 2,growx");
    scrollBar.setOrientation(JScrollBar.HORIZONTAL);
    add(scrollBar, "cell 0 3,growx");

    refreshCharts(false);
}

From source file:org.opendatakit.briefcase.ui.ScrollingStatusListDialog.java

private ScrollingStatusListDialog(Frame frame, String title, IFormDefinition form, String statusHtml) {
    super(frame, title + form.getFormName(), true);
    this.form = form;
    AnnotationProcessor.process(this);
    // Create and initialize the buttons.
    JButton cancelButton = new JButton("Close");
    cancelButton.addActionListener(this);
    getRootPane().setDefaultButton(cancelButton);

    editorArea = new JEditorPane("text/plain", statusHtml);
    editorArea.setEditable(false);//from ww  w .  j  a v a2 s  .  c o m
    //Put the editor pane in a scroll pane.
    JScrollPane editorScrollPane = new JScrollPane(editorArea);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 300));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    // Create a container so that we can add a title around
    // the scroll pane. Can't add a title directly to the
    // scroll pane because its background would be white.
    // Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(editorScrollPane);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Lay out the buttons from left to right.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);

    // Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    // Initialize values.
    pack();
    setLocationRelativeTo(null);
}

From source file:wef.articulab.view.ui.CombinedBNXYPlot.java

/**
 * Creates a new demo instance./*from w  w  w  .ja  v a2  s. c om*/
 */
public CombinedBNXYPlot(String name1, String name2, String title1, String title2, String[] series1,
        String[] series2, boolean shouldPlot) {
    super("Social Reasoner");
    Container content = getContentPane();
    content.setLayout(new GridBagLayout());
    JPanel chartCSPanel = null;
    JPanel chartPhasePanel = null;

    if (shouldPlot) {
        chartContainer1 = new ChartContainer(name1, title1, series1);
        chartCSPanel = createChartPanel(chartContainer1);
        if (name2 != null) {
            chartContainer2 = new ChartContainer(name2, title2, series2);
            chartPhasePanel = createChartPanel(chartContainer2);
        } else {
            chartCSPanel.setPreferredSize(new Dimension(970, 750));
        }
    }
    inputPanel = createInputPanel();
    outputPanel = createOutputPanel();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    add(outputPanel, gbc);
    add(Box.createRigidArea(new Dimension(0, 40)));

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    add(inputPanel, gbc);

    if (shouldPlot) {
        if (chartPhasePanel != null) {
            gbc = new GridBagConstraints();
            gbc.gridx = 1;
            gbc.gridy = 0;
            add(chartCSPanel, gbc);

            gbc = new GridBagConstraints();
            gbc.gridx = 1;
            gbc.gridy = 1;
            add(chartPhasePanel, gbc);
        } else {
            gbc = new GridBagConstraints();
            gbc.gridx = 1;
            gbc.gridy = 0;
            gbc.gridheight = 2;
            add(chartCSPanel, gbc);
        }
    }

    pack();
    setVisible(true);
    setResizable(false);
}

From source file:components.LayeredPaneDemo.java

public LayeredPaneDemo() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    //Create and load the duke icon.
    final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif");

    //Create and set up the layered pane.
    layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(300, 310));
    layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke"));
    layeredPane.addMouseMotionListener(this);

    //This is the origin of the first label added.
    Point origin = new Point(10, 20);

    //This is the offset for computing the origin for the next label.
    int offset = 35;

    //Add several overlapping, colored labels to the layered pane
    //using absolute positioning/sizing.
    for (int i = 0; i < layerStrings.length; i++) {
        JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin);
        layeredPane.add(label, new Integer(i));
        origin.x += offset;/*from ww w  .j ava 2s.  co  m*/
        origin.y += offset;
    }

    //Create and add the Duke label to the layered pane.
    dukeLabel = new JLabel(icon);
    if (icon != null) {
        dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight());
    } else {
        System.err.println("Duke icon not found; using black square instead.");
        dukeLabel.setBounds(15, 225, 30, 30);
        dukeLabel.setOpaque(true);
        dukeLabel.setBackground(Color.BLACK);
    }
    layeredPane.add(dukeLabel, new Integer(2), 0);

    //Add control pane and layered pane to this JPanel.
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(createControlPanel());
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(layeredPane);
}

From source file:ComboBoxDemo2.java

public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z",
            "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" };

    currentPattern = patternExamples[0];

    //Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);//from w  w w .j  a v  a 2 s .  co m
    patternList.addActionListener(this);

    //Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //==
    // LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
}

From source file:BRHInit.java

public void showLoginPrompt() {
    if (login_window == null) {
        login_window = new JFrame("BRH Console");
        login_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel top_panel = new JPanel();
        login_window.getContentPane().add(top_panel);

        top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS));
        top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        JPanel p = new JPanel();
        top_panel.add(p);//from  w  ww.  j a va  2s  .co m
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        JPanel col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(new JLabel("email"));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(new JLabel("password"));

        p.add(Box.createRigidArea(new Dimension(5, 0)));

        col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(email = new JTextField(20));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(password = new JPasswordField());

        if (email_arg != null)
            email.setText(email_arg);
        if (password_arg != null)
            password.setText(password_arg);

        top_panel.add(Box.createRigidArea(new Dimension(0, 10)));

        p = new JPanel();
        top_panel.add(p);
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        p.add(Box.createHorizontalGlue());
        p.add(login_ok = new JButton("OK"));
        p.add(Box.createRigidArea(new Dimension(5, 0)));
        p.add(login_cancel = new JButton("Cancel"));
        p.add(Box.createHorizontalGlue());

        login_ok.addActionListener(this);
        login_cancel.addActionListener(this);

        login_window.pack();
    }

    cookie = null;
    login_window.setVisible(true);
}

From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java

private void start() throws Exception {
    SwingUtilities.invokeLater(() -> {
        jd = new ViewerParameterDialog("Launch Android App");

        JPanel jpParameters = new JPanel();
        jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS));
        jd.setParameterPanel(jpParameters);
        {//from w ww .  j  a  v a2  s .c  o  m
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Devices"));
            jp.add(jcbDevices);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("App Package Name"));
            jp.add(jtfApp);
            if (StringUtils.isNotEmpty(appPackageName)) {
                jtfApp.setText(appPackageName);
            }

            jtfApp.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        jbLaunch.doClick();
                    }
                }
            });
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Interaction time (minute)"));
            jsDebugMinutes.getEditor().setEnabled(false);
            jp.add(jsDebugMinutes);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(Box.createRigidArea(new Dimension(518, 2)));
        }

        JPanel jpAction = new JPanel();
        jd.setActionPanel(jpAction);
        jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD));
        jbLaunch.setBorder(BorderFactory.createEtchedBorder());
        jbLaunch.setEnabled(false);
        jpAction.add(jbLaunch);
        jbLaunch.addActionListener(event -> {
            new Thread() {
                @Override
                public void run() {
                    launchApp();
                }
            }.start();
        });

        jd.showDialog();

        new Thread() {
            @Override
            public void run() {
                try {
                    detectDevices();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }.start();
    });
}