Example usage for javax.swing BoxLayout BoxLayout

List of usage examples for javax.swing BoxLayout BoxLayout

Introduction

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

Prototype

@ConstructorProperties({ "target", "axis" })
public BoxLayout(Container target, int axis) 

Source Link

Document

Creates a layout manager that will lay out components along the given axis.

Usage

From source file:components.SliderDemo.java

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

    delay = 1000 / FPS_INIT;/*from  ww w  . j a v  a2  s  . co m*/

    //Create the label.
    JLabel sliderLabel = new JLabel("Frames Per Second", JLabel.CENTER);
    sliderLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    //Create the slider.
    JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT);

    framesPerSecond.addChangeListener(this);

    //Turn on labels at major tick marks.

    framesPerSecond.setMajorTickSpacing(10);
    framesPerSecond.setMinorTickSpacing(1);
    framesPerSecond.setPaintTicks(true);
    framesPerSecond.setPaintLabels(true);
    framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    Font font = new Font("Serif", Font.ITALIC, 15);
    framesPerSecond.setFont(font);

    //Create the label that displays the animation.
    picture = new JLabel();
    picture.setHorizontalAlignment(JLabel.CENTER);
    picture.setAlignmentX(Component.CENTER_ALIGNMENT);
    picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    updatePicture(0); //display first frame

    //Put everything together.
    add(sliderLabel);
    add(framesPerSecond);
    add(picture);
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    //Set up a timer that calls this object's action handler.
    timer = new Timer(delay, this);
    timer.setInitialDelay(delay * 7); //We pause animation twice per cycle
                                      //by restarting the timer
    timer.setCoalesce(true);
}

From source file:AnimatedButton.java

public AnimatedButton(String buttonText, boolean useBgImage, Color defaultForeground, boolean allowAnimate) {
    this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    button.setText(buttonText);/*from w ww.  j  ava2  s  .  c  om*/
    this.foreground = defaultForeground;
    this.allowAnimate = allowAnimate;
    setOpaque(false);
    add(button);
    if (allowAnimate)
        runThread.start();
}

From source file:components.LayeredPaneDemo2.java

public LayeredPaneDemo2() {
    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);

    //Add several labels to the layered pane.
    layeredPane.setLayout(new GridLayout(2, 3));
    for (int i = 0; i < layerStrings.length; i++) {
        JLabel label = createColoredLabel(layerStrings[i], layerColors[i]);
        layeredPane.add(label, new Integer(i));
    }/* w w  w  .  j ava2  s . c  o  m*/

    //Create and add the Duke label to the layered pane.
    dukeLabel = new JLabel(icon);
    if (icon == null) {
        System.err.println("Duke icon not found; using black rectangle instead.");
        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:SelectionDemo.java

private void buildUI(Container container, ImageIcon image) {
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    SelectionArea area = new SelectionArea(image, this);
    container.add(area);//w  ww  .j  ava 2s . co  m

    label = new JLabel("Drag within the image.");
    label.setLabelFor(area);
    container.add(label);

    //Align the left edges of the components.
    area.setAlignmentX(Component.LEFT_ALIGNMENT);
    label.setAlignmentX(Component.LEFT_ALIGNMENT); //redundant
}

From source file:Main.java

public Main() {
    super(new BorderLayout());

    listModel = new DefaultListModel();
    listModel.addElement("Debbie Scott");
    listModel.addElement("Scott Hommel");
    listModel.addElement("Sharon Zakhour");

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);//from w  w w.  jav a  2s  .c  om
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(hireString);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(hireString);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
}

From source file:SwingTypeTester9.java

private void initComponents() {
    parent = this;
    handler = new CharacterEventHandler();
    producer = new RandomCharacterGenerator();
    producer.setDone(true);//from   w  w w. j ava2  s  .c  o m
    producer.start();
    displayCanvas = new AnimatedCharacterDisplayCanvas(producer);
    feedbackCanvas = new CharacterDisplayCanvas(this);
    quitButton = new JButton();
    startButton = new JButton();
    stopButton = new JButton();
    score = new ScoreLabel(producer, this);

    Container pane = getContentPane();
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.PAGE_AXIS));
    p1.add(displayCanvas);
    p1.add(feedbackCanvas);

    JPanel p2 = new JPanel();
    score.setText("      ");
    score.setFont(new Font("MONOSPACED", Font.BOLD, 30));
    p2.add(score);
    startButton.setText("Start");
    p2.add(startButton);
    stopButton.setText("Stop");
    stopButton.setEnabled(false);
    p2.add(stopButton);
    quitButton.setText("Quit");
    p2.add(quitButton);
    p1.add(p2);
    pane.add(p1, BorderLayout.NORTH);
    pack();

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            quit();
        }
    });
    feedbackCanvas.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent ke) {
            char c = ke.getKeyChar();
            if (c != KeyEvent.CHAR_UNDEFINED)
                newCharacter((int) c);
        }
    });
    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            new FeedbackFrame(parent).show();
        }
    });
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startButton.setEnabled(true);
            stopButton.setEnabled(false);
            producer.setDone(true);
            displayCanvas.setDone(true);
            feedbackCanvas.setEnabled(false);
        }
    });
    quitButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            quit();
        }
    });
}

From source file:gdt.jgui.tool.JTextEditor.java

/**
 * The default constructor./*  w  w w  .j  a v  a  2 s.c o m*/
 */
public JTextEditor() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    editorPane = new JEditorPane();
    add(editorPane);
}

From source file:com.std.StockPanel.java

public void setHistoricalData() {
    this.setLayout(new BorderLayout());
    nameAndChangePanel.setLayout(new BoxLayout(nameAndChangePanel, BoxLayout.PAGE_AXIS));
    nameAndChangePanel.add(nameLbl);/*w w  w . j  ava2 s  .  co m*/
    nameAndChangePanel.add(priceChangePercentLbl);

    data = new Object[30][2];
    String[] colnames = { "1", "2" };

    GridBagConstraints c = new GridBagConstraints();
    dataAndGraph.setLayout(new GridBagLayout());
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0;
    c.gridheight = 1;
    c.insets = new Insets(0, 20, 0, 20);
    dataAndGraph.add(nameAndChangePanel, c);
    c.weightx = 0;
    c.weighty = 1;
    c.insets = new Insets(0, 20, 0, 0);
    //c.ipady = 20;
    c.gridx = 0;
    c.gridy = 1;
    remainingInfoTable = new StockTable(data, colnames);
    remainingInfoTable.setShowGrid(false);
    remainingInfoTable.setTableHeader(null);
    remainingInfoTable.setBackground(this.getBackground());
    remainingInfoTable.setFocusable(false);
    remainingInfoTable.setColumnSelectionAllowed(false);
    remainingInfoTable.setRowSelectionAllowed(false);
    remainingInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    dataAndGraph.add(remainingInfoTable, c);
    this.add(dataAndGraph, BorderLayout.CENTER);

    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0;
    c.gridheight = 2;
    //c.ipady = 20;
    c.gridx = 1;
    c.gridy = 0;
    dataAndGraph.add(chartPane, c);
    chartPane.setVisible(false);
    this.add(dataAndGraph, BorderLayout.CENTER);

    Test.show_hist_data(currentStock, b);
    currentStock.calculate_beta(sp500, 1200);

    nameLbl.setText(currentStock.get_name() + " (" + currentStock.get_symbol() + ")");
    nameLbl.setFont(new Font(nameLbl.getName(), Font.BOLD, 24));
    priceChangePercentLbl.setText(currentStock.get_price() + " ");
    String message = currentStock.get_change() + " " + currentStock.get_percent_change();
    if (Double.parseDouble(currentStock.get_change()) < 0)
        priceChangePercentLbl.setText(String.format("<html>%s<font color='red'>%s</font></html>",
                priceChangePercentLbl.getText(), message));
    else
        priceChangePercentLbl.setText(String.format("<html>%s<font color='green'>%s</font></html>",
                priceChangePercentLbl.getText(), message));
    priceChangePercentLbl.setFont(new Font(priceChangePercentLbl.getName(), Font.PLAIN, 15));

    data[0][0] = "Prev Close: " + currentStock.get_prev_close();
    data[1][0] = "Open: " + currentStock.get_open_price();
    data[2][0] = "Bid: " + currentStock.get_bid();
    data[3][0] = "Ask: " + currentStock.get_ask();
    data[4][0] = "One Year Target: " + currentStock.get_one_year_target();
    data[5][0] = "Ebita: " + currentStock.get_ebitda();
    data[0][1] = "Day Range: " + currentStock.get_days_range();
    data[1][1] = "52 Week Range: " + currentStock.get_year_range();
    data[2][1] = "Volume: " + currentStock.get_volume();
    data[3][1] = "Average Daily Volume: " + currentStock.get_avg_daily_volume();
    data[4][1] = "Market Cap: " + currentStock.get_market_cap();
    data[5][1] = "P/E: " + currentStock.get_pe();
    data[6][1] = "EPS: " + currentStock.get_earnings_per_share();
    data[7][1] = "Dividend (Yield): " + currentStock.get_dividend_per_share() + "("
            + currentStock.get_dividend_yield() + ")";
    data[6][0] = "Reveune:" + currentStock.get_revenue();
    data[7][0] = "Earnings Estimate: " + currentStock.get_earnings_estimate_current_year();
    data[8][0] = "Beta: " + currentStock.get_beta();
    data[8][1] = "PEG Ratio: " + currentStock.get_peg_ratio();
    data[9][0] = "Short Ratio: " + currentStock.get_short_ratio();

    data[11][0] = "50 Day MA: " + currentStock.get_fiftyday_moving_avg();
    data[12][0] = "200 Day MA: " + currentStock.get_twohundredday_moving_avg();
    if (currentStock.get_change_from_fiftyday_moving_avg() != null
            && currentStock.get_change_from_fiftyday_moving_avg().contains("-")) {
        data[13][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 50 Day MA: ",
                currentStock.get_change_from_fiftyday_moving_avg());
        data[14][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 50 Day MA: ",
                currentStock.get_percent_change_from_fiftyday_moving_avg());

    } else {
        data[13][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 50 Day MA: ",
                currentStock.get_change_from_fiftyday_moving_avg());
        data[14][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 50 Day MA: ",
                currentStock.get_percent_change_from_fiftyday_moving_avg());
    }
    if (currentStock.get_change_from_twohundredday_moving_avg() != null
            && currentStock.get_change_from_twohundredday_moving_avg().contains("-")) {
        data[15][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 200 Day MA: ",
                currentStock.get_change_from_twohundredday_moving_avg());
        data[16][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 200 Day MA: ",
                currentStock.get_percent_change_from_twohundredday_moving_avg());
    } else {
        data[15][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 200 Day MA: ",
                currentStock.get_change_from_twohundredday_moving_avg());
        data[16][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 200 Day MA: ",
                currentStock.get_percent_change_from_twohundredday_moving_avg());
    }
    data[17][0] = "Year High: " + currentStock.get_year_high();
    data[18][0] = "Year Low: " + currentStock.get_year_low();
    if (currentStock.get_change_from_year_high() != null
            && currentStock.get_change_from_year_high().contains("-")) {
        data[19][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Change: ",
                currentStock.get_change_from_year_high());
        data[20][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Percent: ",
                currentStock.get_percent_change_from_year_high());
    } else {
        data[19][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Change: ",
                currentStock.get_change_from_year_high());
        data[20][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Percent: ",
                currentStock.get_percent_change_from_year_high());
    }
    if (currentStock.get_change_from_year_low() != null
            && currentStock.get_change_from_year_low().contains("-")) {
        data[21][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Change: ",
                currentStock.get_change_from_year_low());
        data[22][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Percent:  ",
                currentStock.get_percent_change_from_year_low());
    } else {
        data[21][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Change: ",
                currentStock.get_change_from_year_low());
        data[22][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Percent:  ",
                currentStock.get_percent_change_from_year_low());
    }
    if (currentStock.get_five_day_change()[0] != null && currentStock.get_five_day_change()[0].contains("-"))
        data[11][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5D Change: ",
                currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")");
    else
        data[11][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5D Change: ",
                currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")");
    if (currentStock.get_one_month_change()[0] != null && currentStock.get_one_month_change()[0].contains("-"))
        data[12][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1M Change: ",
                currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")");
    else
        data[12][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1M Change: ",
                currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")");
    if (currentStock.get_three_month_change()[0] != null
            && currentStock.get_three_month_change()[0].contains("-"))
        data[13][1] = String.format("<html>%s<font color='red'>%s</font></html>", "3M Change: ",
                currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1]
                        + ")");
    else
        data[13][1] = String.format("<html>%s<font color='green'>%s</font></html>", "3M Change: ",
                currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1]
                        + ")");
    if (currentStock.get_six_month_change()[0] != null && currentStock.get_six_month_change()[0].contains("-"))
        data[14][1] = String.format("<html>%s<font color='red'>%s</font></html>", "6M Change: ",
                currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")");
    else
        data[14][1] = String.format("<html>%s<font color='green'>%s</font></html>", "6M Change: ",
                currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")");
    if (currentStock.get_ytd_change()[0] != null && currentStock.get_ytd_change()[0].contains("-"))
        data[15][1] = String.format("<html>%s<font color='red'>%s</font></html>", "YTD Change: ",
                currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")");
    else
        data[15][1] = String.format("<html>%s<font color='green'>%s</font></html>", "YTD Change: ",
                currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")");
    if (currentStock.get_one_year_change()[0] != null && currentStock.get_one_year_change()[0].contains("-"))
        data[16][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1Y Change: ",
                currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")");
    else
        data[16][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1Y Change: ",
                currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")");
    if (currentStock.get_five_year_change()[0] != null && currentStock.get_five_year_change()[0].contains("-"))
        data[17][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5Y Change: ",
                currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")");
    else
        data[17][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5Y Change: ",
                currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")");
    if (currentStock.get_ten_year_change()[0] != null && currentStock.get_ten_year_change()[0].contains("-"))
        data[18][1] = String.format("<html>%s<font color='red'>%s</font></html>", "10Y Change: ",
                currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")");
    else
        data[18][1] = String.format("<html>%s<font color='green'>%s</font></html>", "10Y Change: ",
                currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")");
    if (currentStock.get_max_year_change()[0] != null && currentStock.get_max_year_change()[0].contains("-"))
        data[19][1] = String.format("<html>%s<font color='red'>%s</font></html>", "Max Change: ",
                currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")");
    else
        data[19][1] = String.format("<html>%s<font color='green'>%s</font></html>", "Max Change: ",
                currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")");

    data[24][0] = "Earnings Est Next Quarter: " + currentStock.get_earnings_estimate_next_quarter();
    data[25][0] = "Earnings Est Current Year: " + currentStock.get_earnings_estimate_current_year();
    data[26][0] = "Earnings Est Next Year: " + currentStock.get_earnings_estimate_next_year();
    data[24][1] = "P/E Est Current Year: " + currentStock.get_price_eps_estimate_current_year();
    data[25][1] = "P/E Est Next Year: " + currentStock.get_price_eps_estimate_next_year();
    remainingInfoTable.setFont(new Font(remainingInfoTable.getName(), Font.PLAIN, 15));
    remainingInfoTable.packColumn(0, 4);
    remainingInfoTable.packColumn(1, 4);

    try {
        dataAndGraph.remove(chartPane);
        chartPane = new JTabbedPane();
        chartPane.setVisible(true);
        ChartPanel intradayChart = new IntradayChart(currentStock).getChartPanel();
        intradayChart.setPopupMenu(graphMenu);
        chartPane.addTab("1d", intradayChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_1);

        ChartPanel fivedayChart = new FiveDayChart(currentStock).getChartPanel();
        fivedayChart.setPopupMenu(graphMenu);
        chartPane.addTab("5d", fivedayChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_2);

        ChartPanel onemonthChart = new OneMonthChart(currentStock).getChartPanel();
        onemonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("1m", onemonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_3);

        ChartPanel threemonthChart = new ThreeMonthChart(currentStock).getChartPanel();
        threemonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("3m", threemonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_4);

        ChartPanel sixmonthChart = new SixMonthChart(currentStock).getChartPanel();
        sixmonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("6m", sixmonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_5);

        ChartPanel ytdChart = new YTDChart(currentStock).getChartPanel();
        ytdChart.setPopupMenu(graphMenu);
        chartPane.addTab("ytd", ytdChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_6);

        ChartPanel oneyearChart = new OneYearChart(currentStock).getChartPanel();
        oneyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("1y", oneyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_7);

        ChartPanel fiveyearChart = new FiveYearChart(currentStock).getChartPanel();
        fiveyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("5y", fiveyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_8);

        ChartPanel tenyearChart = new TenYearChart(currentStock).getChartPanel();
        tenyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("10y", tenyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_9);

        ChartPanel maxChart = new MaxChart(currentStock).getChartPanel();
        maxChart.setPopupMenu(graphMenu);
        chartPane.addTab("max", maxChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_0);

        c = new GridBagConstraints();
        c.anchor = GridBagConstraints.NORTHWEST;
        c.fill = GridBagConstraints.BOTH;
        c.weightx = 1;
        c.weighty = 0;
        c.gridheight = 2;
        //c.ipady = 20;
        c.gridx = 1;
        c.gridy = 0;
        dataAndGraph.add(chartPane, c);

    } catch (ParseException ex) {
        Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
    }
    chartPane.revalidate();
    chartPane.repaint();
    revalidate();
    repaint();
    finished = true;
}

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 .ja  va2 s  .com*/
    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:com.l2jfree.config.gui.Configurator.java

public Configurator(ConfigClassInfo configClassInfo) {
    _configClassInfo = configClassInfo;/*from  www  . j  a va 2s.c o m*/

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    {
        final JMenuBar jMenuBar = new JMenuBar();

        {
            jMenuBar.add(getLoadJButton());
        }
        {
            jMenuBar.add(getRefreshJButton());
        }
        {
            jMenuBar.add(Box.createHorizontalGlue());
        }
        {
            jMenuBar.add(getSaveJButton());
        }
        {
            jMenuBar.add(getStoreJButton());
        }

        setJMenuBar(jMenuBar);
    }

    {
        final JPanel jPanel = new JPanel();

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

        {
            for (ConfigFieldInfo info : _configClassInfo.getConfigFieldInfos()) {
                final ConfigFieldInfoView view = new ConfigFieldInfoView(info);

                // LOW implement

                jPanel.add(view);
            }
        }

        add(new JScrollPane(jPanel));
    }

    pack();
    setSize(600, 400);
    setLocationByPlatform(true);
    setVisible(true);
}