List of usage examples for javax.swing SpringLayout putConstraint
public void putConstraint(String e1, Component c1, Spring s, String e2, Component c2)
e1
of component c1
to edge e2
of component c2
. From source file:layout.SpringDemo2.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.//from w ww .j ava2s. co m */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("SpringDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringDemo2.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//* w ww. j av a2s . c o m*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:layout.SpringDemo3.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.//from ww w . j a va 2 s. c o m */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("SpringDemo3"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the content pane: Its right //edge should be 5 pixels beyond the text field's right //edge, and its bottom edge should be 5 pixels beyond //the bottom edge of the tallest component (which we'll //assume is textField). layout.putConstraint(SpringLayout.EAST, contentPane, 5, SpringLayout.EAST, textField); layout.putConstraint(SpringLayout.SOUTH, contentPane, 5, SpringLayout.SOUTH, textField); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringDemo3.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w w w .j ava2 s . com*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo3"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the content pane: Its right //edge should be 5 pixels beyond the text field's right //edge, and its bottom edge should be 5 pixels beyond //the bottom edge of the tallest component (which we'll //assume is textField). layout.putConstraint(SpringLayout.EAST, contentPane, 5, SpringLayout.EAST, textField); layout.putConstraint(SpringLayout.SOUTH, contentPane, 5, SpringLayout.SOUTH, textField); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:com.awesomecoding.minetestlauncher.Main.java
private void initialize() { fileGetter = new FileGetter(userhome + "\\minetest\\temp\\"); latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true); currentVersion = latest.split("\n")[0]; changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false); try {//from w ww. j a v a2s . c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } frmMinetestLauncherV = new JFrame(); frmMinetestLauncherV.setResizable(false); frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit() .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png"))); frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)"); frmMinetestLauncherV.setBounds(100, 100, 720, 480); frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpringLayout springLayout = new SpringLayout(); frmMinetestLauncherV.getContentPane().setLayout(springLayout); final JProgressBar progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(progressBar); final JButton btnDownloadPlay = new JButton("Play!"); springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar); springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(btnDownloadPlay); final JLabel label = new JLabel("Ready to play!"); springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label); springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label); frmMinetestLauncherV.getContentPane().add(label); JTextPane txtpnNewFeatures = new JTextPane(); txtpnNewFeatures.setBackground(SystemColor.window); springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay); springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay); txtpnNewFeatures.setEditable(false); txtpnNewFeatures.setContentType("text/html"); txtpnNewFeatures.setText(changelog); txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures); File file = new File(userhome + "\\minetest\\version.txt"); if (!file.exists()) newVersion = true; else { String version = fileGetter.getLocalContents(file, false); if (!version.equals(currentVersion)) newVersion = true; } if (newVersion) { label.setText("New Version Available! (" + currentVersion + ")"); btnDownloadPlay.setText("Download & Play"); btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Thread t = new Thread() { public void run() { File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); try { FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version)); } catch (Exception e) { e.printStackTrace(); } fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\", "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion); try { label.setText("Cleaning up..."); btnDownloadPlay.setText("Cleaning up..."); FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp")); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } }; t.start(); } }); } else { btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { label.setText("Launching..."); btnDownloadPlay.setEnabled(false); btnDownloadPlay.setText("Launching..."); File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); Runtime.getRuntime() .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe"); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } }); progressBar.setValue(100); } }
From source file:MainClass.java
public SpringLayoutPanel() { SpringLayout layout = new SpringLayout(); setLayout(layout);// ww w .j ava2 s . com JButton[] buttons = new JButton[6]; for (int i = 0; i < buttons.length; i++) { buttons[i] = new JButton("Press " + (i + 1)); add(buttons[i]); } Spring xSpring = Spring.constant(5, 15, 25); Spring ySpring = Spring.constant(10, 30, 50); Spring wSpring = Spring.constant(30, 80, 130); SpringLayout.Constraints buttonConstr = layout.getConstraints(buttons[0]); buttonConstr.setX(xSpring); buttonConstr.setY(ySpring); for (int i = 0; i < buttons.length; i++) { buttonConstr = layout.getConstraints(buttons[i]); buttonConstr.setHeight(ySpring); buttonConstr.setWidth(wSpring); if (i > 0) { layout.putConstraint(SpringLayout.WEST, buttons[i], xSpring, SpringLayout.EAST, buttons[i - 1]); layout.putConstraint(SpringLayout.NORTH, buttons[i], ySpring, SpringLayout.SOUTH, buttons[i - 1]); } } SpringLayout.Constraints constr = layout.getConstraints(this); constr.setConstraint(SpringLayout.EAST, Spring.sum(buttonConstr.getConstraint(SpringLayout.EAST), Spring.constant(15))); constr.setConstraint(SpringLayout.SOUTH, Spring.sum(buttonConstr.getConstraint(SpringLayout.SOUTH), Spring.constant(10))); }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildSimulationPanel() { simulationPanel = new JPanel(); SpringLayout springLayout = new SpringLayout(); simulationPanel.setLayout(springLayout); // chart data simulationDataset = new SimulationDataset(service); simulationDataset.setInitial(0D);/*from ww w . j a v a2s. c om*/ simulationDataset.setStart(new LocalDate()); simulationDataset.setEnd(new LocalDate().plus(Years.ONE)); simulationDataset.setPeriod(Period.months(1)); simulationDataset.updateDataset(); transactionModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { simulationDataset.updateDataset(); } }); reconciliationModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { simulationDataset.updateDataset(); } }); // initial amount label JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel); simulationPanel.add(amountLbl); // initial amount field amountFld = new JFormattedTextField( new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()), new NumberFormatter(NumberFormat.getCurrencyInstance()))); amountFld.setColumns(8); amountFld.setValue(simulationDataset.getInitial()); amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER, amountFld); springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl); springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(amountFld); // start date label JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld); simulationPanel.add(fromLbl); // start date field fromFld = new JFormattedTextField(new JodaLocalDateFormat()); fromFld.setColumns(8); fromFld.setValue(simulationDataset.getStart()); fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setStart((LocalDate) fromFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld); springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl); springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(fromFld); // end date label JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld); simulationPanel.add(toLbl); // end date field toFld = new JFormattedTextField(new JodaLocalDateFormat()); toFld.setColumns(8); toFld.setValue(simulationDataset.getEnd()); toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setEnd((LocalDate) toFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld); springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl); springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(toFld); // period label JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld); simulationPanel.add(periodLbl); // period field periodFld = new JFormattedTextField(new JodaPeriodFormat()); periodFld.setColumns(5); periodFld.setValue(simulationDataset.getPeriod()); periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER, periodFld); springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl); springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(periodFld); // chart panel JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$ Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$ PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(true); renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service)); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDismissDelay(3600000); chartPanel.setInitialDelay(0); springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld); springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel); springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel); springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel); simulationPanel.add(chartPanel); }
From source file:org.gumtree.vis.awt.AbstractPlotEditor.java
private JPanel createHelpPanel() { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = plot.getHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);// w w w . j av a2 s . com listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:forms.frDados.java
/** * Inicializa o grfico de intensidade de sinal dos satlites. *///from w ww.j av a2 s . c o m private void initSatGrafico() { dadosGraficoSats.clear(); plot = ChartFactory.createBarChart("Intensidade do sinal", "PRN", "SNR", dadosGraficoSats, PlotOrientation.VERTICAL, false, true, true); plot.getTitle().setFont(Font.decode("arial-16")); plot.getTitle().setPadding(5, 20, 5, 20); plot.setPadding(new RectangleInsets(10, 10, 0, 10)); //plot.setBackgroundPaint(new Color(255,255,255,0)); BarRenderer br = (BarRenderer) plot.getCategoryPlot().getRenderer(); br.setSeriesPaint(0, Color.BLUE); br.setMaximumBarWidth(0.05); plot.getCategoryPlot().getRangeAxis().setRange(new Range(0, 50), true, true); br.setBaseItemLabelsVisible(true); br.setSeriesItemLabelFont(0, Font.decode("arial-12")); br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); br.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); SpringLayout lm = new SpringLayout(); ChartPanel cp = new ChartPanel(plot); cp.setBorder(LineBorder.createGrayLineBorder()); lm.putConstraint(SpringLayout.EAST, pnlSatPlot, 10, SpringLayout.EAST, cp); lm.putConstraint(SpringLayout.WEST, cp, 10, SpringLayout.WEST, pnlSatPlot); lm.putConstraint(SpringLayout.SOUTH, pnlSatPlot, 10, SpringLayout.SOUTH, cp); lm.putConstraint(SpringLayout.NORTH, cp, 10, SpringLayout.NORTH, pnlSatPlot); pnlSatPlot.setLayout(lm); pnlSatPlot.add(cp); }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Builds the side panel with all the options for this StatViw * //from w ww . j av a 2 s . c o m * @return the formatted side panel */ public JPanel buildSidePanel() { final int VERTICAL_PADDING = 5; final int HORIZONTAL_PADDING = 5; final int FAR = 5; final SpringLayout sidePanelLayout = new SpringLayout(); final JPanel sidePanel = new JPanel(sidePanelLayout); final JLabel lblStatisticType = new JLabel("Statistic Type"); final String[] availableStatisticTypes = { "Status", "Assignees", "Iterations", "Velocity" }; // TODO: Add Estimates, Effort, Tasks charts for future use. comboBoxStatisticType = new JComboBox(availableStatisticTypes); comboBoxStatisticType.addActionListener(this); makePieRadio = new JRadioButton("Pie Chart"); makePieRadio.setMnemonic(KeyEvent.VK_P); makePieRadio.setActionCommand("Pie Chart"); makePieRadio.addActionListener(this); makeBarRadio = new JRadioButton("Bar Chart"); makeBarRadio.setMnemonic(KeyEvent.VK_B); makeBarRadio.setActionCommand("Bar Chart"); makeBarRadio.addActionListener(this); makeLineRadio = new JRadioButton("Line Chart"); makeLineRadio.setMnemonic(KeyEvent.VK_B); makeLineRadio.setActionCommand("Line Chart"); makeLineRadio.addActionListener(this); makeLineRadio.setEnabled(false); final ButtonGroup group = new ButtonGroup(); group.add(makePieRadio); group.add(makeBarRadio); group.add(makeLineRadio); updateSelectedItems(); final JPanel radioPanel = new JPanel(new GridLayout(3, 1)); radioPanel.add(makePieRadio); radioPanel.add(makeBarRadio); radioPanel.add(makeLineRadio); radioPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart Type")); sidePanel.add(lblStatisticType); sidePanel.add(comboBoxStatisticType); sidePanel.add(radioPanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, lblStatisticType, VERTICAL_PADDING, SpringLayout.NORTH, sidePanel); sidePanelLayout.putConstraint(SpringLayout.WEST, lblStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, comboBoxStatisticType, VERTICAL_PADDING, SpringLayout.SOUTH, lblStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, comboBoxStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, radioPanel, VERTICAL_PADDING + FAR, SpringLayout.SOUTH, comboBoxStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, radioPanel, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); return sidePanel; }