List of usage examples for javax.swing BoxLayout PAGE_AXIS
int PAGE_AXIS
To view the source code for javax.swing BoxLayout PAGE_AXIS.
Click Source Link
From source file:org.kepler.gui.PlotsEditorPanel.java
public PlotsEditorPanel(TableauFrame parent, String title) { super();// w ww . ja v a 2 s .co m _title = title; _frame = parent; setBackground(TabManager.BGCOLOR); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); plotsPanel = new JPanel(); plotsPanel.setLayout(new BoxLayout(plotsPanel, BoxLayout.PAGE_AXIS)); fixGraphics(); JScrollPane scrollPane = new JScrollPane(plotsPanel); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); this.add(scrollPane, BorderLayout.CENTER); JButton addPlotButton = createAddPlotButton(); this.add(addPlotButton, BorderLayout.PAGE_END); // This thread will try to wait until the PlotsPanel is available // before adding a plot to it. If a plot is added before the // applicable tab pane is available, an NPE will be triggered. // The thread will poll for tab pane setup completion every 100 ms, // up to a maximum of 10 seconds (100 iterations). If after 10 seconds // the tab pane is not available, something has probably gone wrong, // and further attempts would do no good. new Thread(new Runnable() { private void pause(long l) { try { Thread.sleep(l); } catch (InterruptedException ignored) { } } public void run() { int maxIterations = 100; for (int i = 0; i < maxIterations; i++) { log.debug("PlotsEditorPanel thread waiting " + "for TabPane to become available..."); pause(100); if (canAddPlot()) { log.debug("PlotsEditorPanel thread got TabPane, adding Plot."); addPlot(); return; } } } }).start(); }
From source file:components.SliderDemo.java
public SliderDemo() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); delay = 1000 / FPS_INIT;/*from w w w . j ava2 s . c o 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: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 ww . jav a 2 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);//from w ww . j a v a 2s. c o 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:SwingTypeTester9.java
private void initComponents() { parent = this; handler = new CharacterEventHandler(); producer = new RandomCharacterGenerator(); producer.setDone(true);//from w w w . j ava 2 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:com.std.StockPanel.java
public void setHistoricalData() { this.setLayout(new BorderLayout()); nameAndChangePanel.setLayout(new BoxLayout(nameAndChangePanel, BoxLayout.PAGE_AXIS)); nameAndChangePanel.add(nameLbl);//from ww w .j a va2s .c om 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);/* www .j a v a 2s . c o 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: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 w w w .j a v a2s . c o 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:com.idealista.solrmeter.view.statistic.OperationTimeLineChartPanel.java
@Inject public OperationTimeLineChartPanel(OperationTimeHistory statistic) { super();//from w w w . j a v a 2 s.c o m this.statistic = statistic; this.xyDataset = new DefaultXYDataset(); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(this.createChartPanel()); this.add(this.createCheckBoxPanel()); }
From source file:QandE.LunarPhasesRB.java
public LunarPhasesRB() { //Create the phase selection and display panels. selectPanel = new JPanel(); displayPanel = new JPanel(); //Add various widgets to the sub panels. addWidgets();//from w w w . j av a2 s. c om //Create the main panel to contain the two sub panels. mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //Add the select and display panels to the main panel. mainPanel.add(selectPanel); mainPanel.add(displayPanel); }