List of usage examples for java.awt BorderLayout PAGE_END
String PAGE_END
To view the source code for java.awt BorderLayout PAGE_END.
Click Source Link
From source file:layout.BoxLayoutDemo2.java
public void populateContentPane(Container contentPane) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); //Create the rectangles. int shortSideSize = 15; for (int i = 0; i < NUM_COMPONENTS; i++) { if (sizeIsRandom) { shortSideSize = (int) (30.0 * Math.random()) + 30; } else {//from w w w. j a va2 s . c om shortSideSize += 10; } bldComponent[i] = new BLDComponent(xAlignment[i], hue[i], shortSideSize, restrictSize, sizeIsRandom, String.valueOf(i)); panel.add(bldComponent[i]); } //Create the instructions. JLabel label = new JLabel("Click a rectangle to " + "change its X alignment."); JCheckBox cb = new JCheckBox("Restrict maximum rectangle size."); cb.setSelected(restrictSize); cb.addItemListener(this); panel.setBorder(BorderFactory.createLineBorder(Color.red)); Box box = Box.createVerticalBox(); box.add(label); box.add(cb); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(box, BorderLayout.PAGE_END); }
From source file:KeyEventDemo.java
public KeyEventDemo() { super(new BorderLayout()); JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); //Uncomment this if you wish to turn off focus //traversal. The focus subsystem consumes //focus traversal keys, such as Tab and Shift Tab. //If you uncomment the following line of code, this //disables focus traversal and the Tab events will //become available to the key event listener. //typingArea.setFocusTraversalKeysEnabled(false); displayArea = new JTextArea(); displayArea.setEditable(false);//from w ww . j av a 2 s. c om JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setPreferredSize(new Dimension(375, 125)); add(typingArea, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); add(button, BorderLayout.PAGE_END); }
From source file:Main.java
private void addComponentsToPane() { JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); // Uncomment this if you wish to turn off focus // traversal. The focus subsystem consumes // focus traversal keys, such as Tab and Shift Tab. // If you uncomment the following line of code, this // disables focus traversal and the Tab events will // become available to the key event listener. // typingArea.setFocusTraversalKeysEnabled(false); displayArea = new JTextArea(); displayArea.setEditable(false);/* www . j av a 2 s. c o m*/ JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setPreferredSize(new Dimension(375, 125)); getContentPane().add(typingArea, BorderLayout.PAGE_START); getContentPane().add(scrollPane, BorderLayout.CENTER); getContentPane().add(button, BorderLayout.PAGE_END); }
From source file:historyView.HistoryJFrame.java
/** * Creates new form HistoryJFrame/*from www . j a v a 2 s .c o m*/ */ public HistoryJFrame() { initComponents(); //set window in the center of the screen //Get the size of the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); //Determine the new location of the window int w = this.getSize().width; int h = this.getSize().height; int x = (dim.width - w) / 2; int y = (dim.height - h) / 2; //Move the window this.setLocation(x, y); XYSeries breathingSeries = new XYSeries("Breathing Rate"); XYSeries oxygenSeries = new XYSeries("Oxygen"); XYSeries temperatureSeries = new XYSeries("Temperature"); XYSeries bloodPressureSeries = new XYSeries("Blood Pressure"); XYSeries heartRateSeries = new XYSeries("Heart Rate"); // add date to all the series for (Map.Entry<String, PatientData> entry : model.getSelectedPatient().data.entrySet()) { breathingSeries.add(Double.parseDouble(entry.getKey()), entry.getValue().getBreathing()); oxygenSeries.add(Double.parseDouble(entry.getKey()), entry.getValue().getOxygen()); temperatureSeries.add(Double.parseDouble(entry.getKey()), entry.getValue().getTemperature()); bloodPressureSeries.add(Double.parseDouble(entry.getKey()), entry.getValue().getBloodPressure()); heartRateSeries.add(Double.parseDouble(entry.getKey()), entry.getValue().getHeartRate()); } // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(breathingSeries); dataset.addSeries(oxygenSeries); dataset.addSeries(temperatureSeries); dataset.addSeries(bloodPressureSeries); dataset.addSeries(heartRateSeries); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title "time(s)", // x-axis Label "Rate", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); this.setLayout(new java.awt.BorderLayout()); ChartPanel CP = new ChartPanel(chart); chart.getPlot().setBackgroundAlpha(1); chart.getPlot().setBackgroundPaint(Color.BLUE); HistoryButtonsJPanel buttonPanel = new HistoryButtonsJPanel(); ChartUtilities.applyCurrentTheme(chart); this.add(CP, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.PAGE_END); this.validate(); }
From source file:components.ColorChooserDemo2.java
public ColorChooserDemo2() { super(new BorderLayout()); //Set up banner to use as custom preview panel banner = new JLabel("Welcome to the Tutorial Zone!", JLabel.CENTER); banner.setForeground(Color.yellow); banner.setBackground(Color.blue); banner.setOpaque(true);/*from w w w .j ava2 s . c om*/ banner.setFont(new Font("SansSerif", Font.BOLD, 24)); banner.setPreferredSize(new Dimension(100, 65)); JPanel bannerPanel = new JPanel(new BorderLayout()); bannerPanel.add(banner, BorderLayout.CENTER); bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner")); //Set up color chooser for setting background color JPanel panel = new JPanel(); //use FlowLayout JButton bcc = new JButton("Show Color Chooser..."); bcc.addActionListener(this); panel.add(bcc); panel.setBorder(BorderFactory.createTitledBorder("Choose Background Color")); //Set up color chooser for setting text color tcc = new JColorChooser(); tcc.getSelectionModel().addChangeListener(this); tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color")); //Remove the preview panel tcc.setPreviewPanel(new JPanel()); //Override the chooser panels with our own AbstractColorChooserPanel panels[] = { new CrayonPanel() }; tcc.setChooserPanels(panels); tcc.setColor(banner.getForeground()); add(bannerPanel, BorderLayout.PAGE_START); add(panel, BorderLayout.CENTER); add(tcc, BorderLayout.PAGE_END); }
From source file:FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); JTextField tf1 = new JTextField("Field 1"); JTextField tf2 = new JTextField("A Bigger Field 2"); JTextField tf3 = new JTextField("Field 3"); JTextField tf4 = new JTextField("A Bigger Field 4"); JTextField tf5 = new JTextField("Field 5"); JTextField tf6 = new JTextField("A Bigger Field 6"); JTable table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); // Remove it from the focus cycle. // Note that HTML is allowed and will break this run of text // across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); Vector<Component> order = new Vector<Component>(7); order.add(tf1);//ww w. j a v a 2s.c o m order.add(tf2); order.add(tf3); order.add(tf4); order.add(tf5); order.add(tf6); order.add(table); newPolicy = new MyOwnFocusTraversalPolicy(order); }
From source file:misc.TrackFocusDemo.java
public TrackFocusDemo() { super(new BorderLayout()); JPanel mugshots = new JPanel(new GridLayout(2, 3)); pic1 = new Picture(createImageIcon("images/" + mayaString + ".jpg", mayaString).getImage()); pic1.setName("1"); mugshots.add(pic1);/*from w w w.j av a 2 s.c o m*/ pic2 = new Picture(createImageIcon("images/" + anyaString + ".jpg", anyaString).getImage()); pic2.setName("2"); mugshots.add(pic2); pic3 = new Picture(createImageIcon("images/" + laineString + ".jpg", laineString).getImage()); pic3.setName("3"); mugshots.add(pic3); pic4 = new Picture(createImageIcon("images/" + cosmoString + ".jpg", cosmoString).getImage()); pic4.setName("4"); mugshots.add(pic4); pic5 = new Picture(createImageIcon("images/" + adeleString + ".jpg", adeleString).getImage()); pic5.setName("5"); mugshots.add(pic5); pic6 = new Picture(createImageIcon("images/" + alexiString + ".jpg", alexiString).getImage()); pic6.setName("6"); mugshots.add(pic6); info = new JLabel("Nothing selected"); setPreferredSize(new Dimension(450, 350)); add(mugshots, BorderLayout.CENTER); add(info, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (("focusOwner".equals(prop)) && ((e.getNewValue()) instanceof Picture)) { Component comp = (Component) e.getNewValue(); String name = comp.getName(); Integer num = new Integer(name); int index = num.intValue(); if (index < 0 || index > comments.length) { index = 0; } info.setText(comments[index]); } } }); }
From source file:net.vanosten.dings.swing.SummaryView.java
protected void initializeMainP() { mainP = new JPanel(); BorderLayout bl = new BorderLayout(); bl.setVgap(DingsSwingConstants.SP_V_G); mainP.setLayout(bl);// w ww . j ava2s .c om initComponents(); initializeChartPropertiesPanel(); mainP.add(chartP, BorderLayout.CENTER); mainP.add(chartPropertiesP, BorderLayout.PAGE_END); }
From source file:FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); newPolicy = new MyOwnFocusTraversalPolicy(); tf1 = new JTextField("Field 1"); tf2 = new JTextField("A Bigger Field 2"); tf3 = new JTextField("Field 3"); tf4 = new JTextField("A Bigger Field 4"); tf5 = new JTextField("Field 5"); tf6 = new JTextField("A Bigger Field 6"); table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); //Remove it from the focus cycle. //Note that HTML is allowed and will break this run of text //across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:components.ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Jane Doe"); listModel.addElement("John Smith"); listModel.addElement("Kathy Green"); //Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);/* w ww .j a v a 2 s . co m*/ 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); }