List of usage examples for java.awt GridBagConstraints CENTER
int CENTER
To view the source code for java.awt GridBagConstraints CENTER.
Click Source Link
From source file:org.sonarlint.intellij.config.global.SonarQubeServerEditor.java
private void createRootPanel() { JPanel form = createForm();// w w w.j av a 2s. com GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; gbc.gridx = 0; gbc.weightx = 1.0; rootPanel.add(form, gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.gridy = 1; gbc.gridx = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; rootPanel.add(testButton, gbc); }
From source file:org.nyu.edu.dlts.CodeViewerDialog.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license dialogPane = new JPanel(); contentPanel = new JPanel(); scrollPane1 = new JScrollPane(); messageTextArea = new JTextArea(); buttonBar = new JPanel(); recordTestPanel = new JPanel(); openButton = new JButton(); saveButton = new JButton(); updateButton = new JButton(); evaluateButton = new JButton(); okButton = new JButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setTitle("Code Viewer"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== {//from ww w . j a v a 2 s . com dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { contentPanel.setLayout(new BorderLayout()); //======== scrollPane1 ======== { //---- messageTextArea ---- messageTextArea.setRows(6); messageTextArea.setEditable(false); scrollPane1.setViewportView(messageTextArea); } contentPanel.add(scrollPane1, BorderLayout.SOUTH); } dialogPane.add(contentPanel, BorderLayout.CENTER); //======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 80 }; ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0 }; //======== recordTestPanel ======== { recordTestPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC }, RowSpec.decodeSpecs("default"))); //---- openButton ---- openButton.setText("Open"); openButton.setEnabled(false); recordTestPanel.add(openButton, cc.xy(1, 1)); //---- saveButton ---- saveButton.setText("Save"); saveButton.setEnabled(false); recordTestPanel.add(saveButton, cc.xy(3, 1)); //---- updateButton ---- updateButton.setText("Update"); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateButtonActionPerformed(); } }); recordTestPanel.add(updateButton, cc.xy(5, 1)); //---- evaluateButton ---- evaluateButton.setText("Evaluate Syntax"); evaluateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { evaluateButtonActionPerformed(); } }); recordTestPanel.add(evaluateButton, cc.xy(9, 1)); } buttonBar.add(recordTestPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); //---- okButton ---- okButton.setText("Close"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonActionPerformed(); } }); buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:MainProgram.MainProgram.java
private void initComponents() throws InterruptedException { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents welcomeMessage = new JLabel(); welcomeMessage2 = new JLabel(); pennIDLabel = new JLabel(); pennIDTextField = new JTextField(); pennPassLabel = new JLabel(); pennPassField = new JPasswordField(); emailLabel = new JLabel(); emailTextField = new JTextField(); emailDomainLabel = new JLabel(); emailPassLabel = new JLabel(); emailPassField = new JPasswordField(); semesterLabel = new JLabel(); semesterComboBox = new JComboBox(semestersString); credentials = new JLabel(); dropLabel = new JLabel(); dropCheckBox = new JCheckBox(); button = new JButton(); stopWatchLabel = new JLabel(); checkMail = false;//from ww w .ja v a 2s.c om testConnection = false; mailCheckTimeInitializer(); StopWatchInitializer(); try { setUIFont(new javax.swing.plaf.FontUIResource("Segoe UI", Font.ROMAN_BASELINE, 12)); } catch (Exception e) { e.printStackTrace(MainProgram.errorLog); } String lcOSName = System.getProperty("os.name").toLowerCase(); boolean IS_MAC = lcOSName.startsWith("mac os x"); //======== this ======== setLayout(new GridBagLayout()); ((GridBagLayout) getLayout()).columnWidths = new int[] { 81, 5, 119, 5, 0, 0 }; if (!IS_MAC) { ((GridBagLayout) getLayout()).rowHeights = new int[] { 17, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0, 0, 0 }; } ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.fill = GridBagConstraints.HORIZONTAL; //---- welcomeMessage ---- welcomeMessage.setText("Course Registration"); welcomeMessage.setHorizontalAlignment(SwingConstants.CENTER); add(welcomeMessage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- welcomeMessage2 ---- welcomeMessage2.setText("for Penn State (BETA)"); welcomeMessage2.setHorizontalAlignment(SwingConstants.CENTER); add(welcomeMessage2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- pennIDLabel ---- pennIDLabel.setText("Penn State ID: "); pennIDLabel.setHorizontalAlignment(SwingConstants.RIGHT); add(pennIDLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- pennIDTextField ---- pennIDTextField.setText("xxx123"); add(pennIDTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- pennPassLabel ---- pennPassLabel.setText("Penn State Password: "); pennPassLabel.setHorizontalAlignment(SwingConstants.RIGHT); add(pennPassLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(pennPassField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- emailLabel ---- emailLabel.setText("Email: "); emailLabel.setHorizontalAlignment(SwingConstants.RIGHT); add(emailLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- emailTextField ---- emailTextField.setText("myEmail"); add(emailTextField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- emailDomainLabel ---- emailDomainLabel.setText("@mail.com"); add(emailDomainLabel, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- emailPassLabel ---- emailPassLabel.setText("Email Password: "); emailPassLabel.setHorizontalAlignment(SwingConstants.RIGHT); add(emailPassLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(emailPassField, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); //---- Semester label ---- semesterLabel.setText("Semester/Drop Option: "); semesterLabel.setHorizontalAlignment(SwingConstants.RIGHT); add(semesterLabel, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- Semester ComboBox ---- add(semesterComboBox, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- Drop CheckBox ---- add(dropCheckBox, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- button ---- button.setText("Start"); add(button, new GridBagConstraints(1, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- stopWatchLabel ---- stopWatchLabel.setText(" " + stopWatchSplitting[0]); stopWatchLabel.setHorizontalAlignment(SwingConstants.LEFT); add(stopWatchLabel, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- label11 ---- credentials.setText(" Created by Daniyar Yeralin"); credentials.setForeground(Color.gray); credentials.setHorizontalAlignment(SwingConstants.RIGHT); credentials.setFont(new Font("Cambria", Font.ITALIC, 12)); add(credentials, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); /*button.registerKeyboardAction(button.getActionForKeyStroke( KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED); button.registerKeyboardAction(button.getActionForKeyStroke( KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true), JComponent.WHEN_FOCUSED);*/ StartButtonHandler buttonListener = new StartButtonHandler(); button.addActionListener(buttonListener); }
From source file:pcgui.SetupVisualizationPanel.java
/** * Create the frame.// ww w . ja v a 2 s.c o m * * @param switcher * * @param rootFrame */ public SetupVisualizationPanel(final PanelSwitcher switcher, JFrame rootFrame) { this.rootFrame = rootFrame; setLayout(new BorderLayout()); if (trackedVariables == null) { trackedVariables = new ArrayList<String>(); trackedVariables.add(""); } JLabel headingLabel = new JLabel("Setup Visualization"); headingLabel.setFont(new Font("Tahoma", Font.BOLD, 16)); add(headingLabel, BorderLayout.NORTH); JLabel chartTypeLabel = new JLabel("Chart Type"); chartTypeLabel.setPreferredSize(new Dimension(140, 30)); chartTypeCB = new JComboBox<String>(chartTypes); chartTypeCB.setPreferredSize(new Dimension(140, 30)); JLabel xAxisLabel = new JLabel("X Axis"); xAxisLabel.setPreferredSize(new Dimension(140, 30)); // xAxisTF = new JTextField(); // xAxisTF.setPreferredSize(new Dimension(100, 20)); xAxisCB = new JComboBox<String>(new DefaultComboBoxModel(trackedVariables.toArray())); xAxisCB.setPreferredSize(new Dimension(140, 30)); JLabel yAxisLabel = new JLabel("Y Axis"); yAxisLabel.setPreferredSize(new Dimension(140, 30)); // yAxisTF = new JTextField(); // yAxisTF.setPreferredSize(new Dimension(100, 20)); yAxisCB = new JComboBox<String>(new DefaultComboBoxModel(trackedVariables.toArray())); yAxisCB.setPreferredSize(new Dimension(140, 30)); JLabel iterationAsXLabel = new JLabel("Use Iteration Number as X Axis"); iterationAsXLabel.setPreferredSize(new Dimension(250, 30)); useIterationNumAsXChkBox = new JCheckBox("Use Iteration Count as X Axis"); useIterationNumAsXChkBox.setPreferredSize(new Dimension(250, 30)); addVisualizationBtn = new JButton("Add"); addVisualizationBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<Object> visRow = new ArrayList<Object>(4); visRow.add(chartTypeCB.getSelectedItem()); visRow.add(xAxisCB.getSelectedItem()); visRow.add(yAxisCB.getSelectedItem()); visRow.add(useIterationNumAsXChkBox.isSelected()); visRow.add("");//for Delete model.addRow(visRow); } }); drawVisualizationBtn = new JButton("Draw Visualizations"); drawVisualizationBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<ArrayList<Object>> visList = getVisualizationConfig(); boolean successOnCharts = true; for (ArrayList<Object> row : visList) { Visualization vis = new Visualization(); vis.setChartType((String) row.get(0)); vis.setXAxis((String) row.get(1)); vis.setYAxis((String) row.get(2)); vis.setUsingIterationNumAsX((boolean) row.get(3)); switch (vis.getChartType()) { case "LineChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawLineChart(null, vis.getYAxis()); } else { ModelSaver.drawLineChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing LineChart to Excel", exc.toString()); exc.printStackTrace(); } break; case "ScatterPlot": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawScatterPlot(null, vis.getYAxis()); } else { ModelSaver.drawScatterPlot(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing ScatterPlot to Excel", exc.toString()); exc.printStackTrace(); } break; case "BarChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawBarChart(null, vis.getYAxis()); } else { ModelSaver.drawBarChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing BarChart to Excel", exc.toString()); exc.printStackTrace(); } break; case "PieChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawPieChart(null, vis.getYAxis()); } else { ModelSaver.drawPieChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing PieChart to Excel", exc.toString()); exc.printStackTrace(); } break; } } if (successOnCharts) JOptionPane.showMessageDialog(new JFrame("Success"), "Visualization completed.\nOutput charts added to excel file : " + ModelSaver.excelFileName); } }); JPanel runConfig = new JPanel(); runConfig.setLayout(new GridLayout(3, 2)); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.CENTER; JPanel configLabel = new JPanel(new FlowLayout()); JPanel configCount = new JPanel(new FlowLayout()); JPanel configButtons = new JPanel(new FlowLayout()); configLabel.setAlignmentX(LEFT_ALIGNMENT); configLabel.add(chartTypeLabel); configLabel.add(xAxisLabel); configLabel.add(yAxisLabel); configLabel.add(iterationAsXLabel); configCount.setAlignmentX(LEFT_ALIGNMENT); configCount.add(chartTypeCB); configCount.add(xAxisCB); configCount.add(yAxisCB); configCount.add(useIterationNumAsXChkBox); configButtons.add(addVisualizationBtn); configButtons.add(drawVisualizationBtn); runConfig.add(configLabel); runConfig.add(configCount); runConfig.add(configButtons); add(runConfig, BorderLayout.SOUTH); setVisible(true); }
From source file:org.jfree.chart.demo.CompassDemo.java
/** * Initialises the user interface./* w ww.ja va 2s. c o m*/ * * @throws Exception if there are any exceptions. */ void jbInit() throws Exception { this.titledBorder1 = new TitledBorder(""); this.titledBorder2 = new TitledBorder(""); this.titledBorder3 = new TitledBorder(""); setLayout(this.gridLayout1); this.panelCompassHolder.setLayout(this.borderLayout); this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING); this.windNullCheckBox.setText("Null"); this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkWindNullActionPerformed(e); } }); this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); this.shipNullCheckBox.setText("Null"); this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkShipNullActionPerformed(e); } }); this.spinShip.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinShipPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { shipData.setValue(new Double(spinner.getValue())); } } }); this.spinWind.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinWindPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { compassData.setValue(new Double(spinner.getValue())); } } }); this.jPanel12.setLayout(this.gridLayout2); this.jPanel2.setBorder(this.titledBorder1); this.jPanel2.setLayout(this.gridBagLayout2); this.jPanel1.setBorder(this.titledBorder2); this.jPanel1.setLayout(this.gridBagLayout1); this.titledBorder1.setTitle("Second Pointer"); this.titledBorder2.setTitle("First Pointer"); this.titledBorder3.setTitle("Plot Options"); this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick2PointerActionPerformed(e); } }); this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick1PointerActionPerformed(e); } }); add(this.panelCompassHolder, null); this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH); this.jPanel12.add(this.jPanel1, null); this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel12.add(this.jPanel2, null); this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER); }
From source file:it.illinois.adsc.ema.softgrid.monitoring.ui.SPMainFrame.java
private void setupGUI() throws Exception { this.getContentPane().setLayout(new GridBagLayout()); chartPanel = getChartPanel();/* w w w. j a va2 s. c om*/ this.setPreferredSize(new Dimension(800, 700)); alertPanel.setPreferredSize(new Dimension(200, 700)); alertPanel.setMinimumSize(new Dimension(200, 700)); alertPanel.setMaximumSize(new Dimension(200, 700)); transientPanel.setPreferredSize(new Dimension(200, 700)); transientPanel.setMinimumSize(new Dimension(200, 700)); transientPanel.setMaximumSize(new Dimension(200, 700)); queryTextArea.setPreferredSize(new Dimension(300, 100)); queryTextArea.setMinimumSize(new Dimension(300, 100)); queryTextArea.setMaximumSize(new Dimension(300, 100)); monitorButton.setPreferredSize(new Dimension(30, 30)); monitorButton.setMinimumSize(new Dimension(30, 30)); monitorButton.setMaximumSize(new Dimension(30, 30)); monitorButton.setToolTipText("Execute and Monitor"); exitButton.setPreferredSize(new Dimension(30, 30)); exitButton.setMinimumSize(new Dimension(30, 30)); exitButton.setMaximumSize(new Dimension(30, 30)); exitButton.setToolTipText("Close and Exit"); clearButton.setPreferredSize(new Dimension(30, 30)); clearButton.setMinimumSize(new Dimension(30, 30)); clearButton.setMaximumSize(new Dimension(30, 30)); clearButton.setToolTipText("Reset"); runButton.setPreferredSize(new Dimension(30, 30)); runButton.setMinimumSize(new Dimension(30, 30)); runButton.setMaximumSize(new Dimension(30, 30)); runButton.setToolTipText("Initialize the server...!"); alertPanel.setLayout(new VerticalFlowLayout()); transientPanel.setLayout(new BorderLayout()); // System.out.println("new File(\"../MonitorEngine/Images/execute-xxl.png\").exists() = " + new File("../MonitorEngine/Images/execute-xxl.png").exists()); // System.out.println("execute-xxl.png = " + new File("execute-xxl.png").exists()); // System.out.println("new File().getAbsolutePath() = " + new File("openmuc.jar").getAbsolutePath()); Image img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("execute-xxl.png"))) .getImage(); Image newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); ImageIcon icon = new ImageIcon(newimg); monitorButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("stop-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); exitButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("reset-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); clearButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("start-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); runButton.setIcon(icon); altertScrolPane.getViewport().add(alertPanel, null); altertScrolPane.setBorder(BorderFactory.createEtchedBorder()); logAreaScrollPane.getViewport().add(logTextArea, null); logAreaScrollPane.setBorder(BorderFactory.createEtchedBorder()); JPanel tempQueryPanel = new JPanel(); JPanel buttonPanel = new JPanel(); // tempQueryPanel.setBorder(BorderFactory.createTitledBorder("Monitor Query")); tempQueryPanel.setLayout(new GridBagLayout()); buttonPanel.setLayout(new GridBagLayout()); buttonPanel.setBorder(BorderFactory.createEtchedBorder()); buttonPanel.setOpaque(true); buttonPanel.setBackground(Color.gray); buttonPanel.add(runButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 12, 3, 12), 0, 0)); buttonPanel.add(monitorButton, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); buttonPanel.add(clearButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); buttonPanel.add(exitButton, new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); // tempQueryPanel.add(splitPane, new GridBagConstraints(0, 0, 1, 6, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); tempQueryPanel.add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); tempQueryPanel.add(queryScrolPane, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainTabbedPane.add(splitPane, "Controller"); mainTabbedPane.add(ConfigPanel.getInstance(), "Configuration"); splitPane.setTopComponent(tempQueryPanel); splitPane.setDividerLocation(152); splitPane.setBottomComponent(resultTabbedPane); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); this.getContentPane().add(mainTabbedPane, new GridBagConstraints(0, 0, 1, 2, 0.75, 0.25, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0)); // this.getContentPane().add(alertTitile, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 0, 0, 12), 0, 0)); // this.getContentPane().add(altertScrolPane, new GridBagConstraints(1, 1, 1, 2, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 12, 12), 0, 0)); // tempQueryPanel.add(queryScrolPane, new GridBagConstraints(0, 0, 1, 5, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // this.getContentPane().add(logAreaScrollPane, new GridBagConstraints(0, 2, 1, 1, 0.75, 0.75, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0)); exitButton.addActionListener(this); monitorButton.addActionListener(this); clearButton.addActionListener(this); clearButton.setEnabled(false); clearButton.setVisible(false); monitorButton.setEnabled(true); runButton.addActionListener(this); queryTextArea.setContentType("text/html"); queryTextArea.setText("select overloadrank from virtual"); messageHandler = new MessageUIHandler(logTextArea, logAreaScrollPane); ConfigPanel.getInstance().setupConfigPanel(); }
From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java
/** * Creates panel./*from w w w. j a v a 2s.com*/ */ private void createPanel() { setLayout(new BorderLayout()); // CENTER: chart ChartPanel chartPanel = new ChartPanel(createChart()); // no context menu chartPanel.setPopupMenu(null); // not zoomable chartPanel.setMouseZoomable(false); add(chartPanel, BorderLayout.CENTER); // LINE_END: series table JPanel tablePanel = new JPanel(new GridBagLayout()); String[] columnNames = { messages.getString("ModelExecutionChartPanel.Table.ColumnNames.ExtraAxis"), messages.getString("ModelExecutionChartPanel.Table.ColumnNames.LevelNode") }; final MyTableModel tableModel = new MyTableModel(columnNames, xySeriesArray.length); for (int i = 0; i < xySeriesArray.length; i++) { tableModel.addEntry((String) xySeriesArray[i].getKey()); } JTable table = new JTable(tableModel); table.setRowSelectionAllowed(false); JScrollPane tableScrollPane = new JScrollPane(table); int width = (int) Math.min(300, table.getPreferredSize().getWidth()); int height = (int) Math.min(200, table.getPreferredSize().getHeight()); tableScrollPane.getViewport().setPreferredSize(new Dimension(width, height)); tableScrollPane.setMaximumSize(tableScrollPane.getViewport().getPreferredSize()); axesButton = new JButton(messages.getString("ModelExecutionChartPanel.AxesButton.Text")); axesButton.setToolTipText(messages.getString("ModelExecutionChartPanel.AxesButton.ToolTipText")); axesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // create XYSeriesCollections (and renderer) XYSeriesCollection standardData = new XYSeriesCollection(); XYLineAndShapeRenderer standardRenderer = new XYLineAndShapeRenderer(true, false); LinkedList<XYSeriesCollection> extraDataList = new LinkedList<XYSeriesCollection>(); LinkedList<XYLineAndShapeRenderer> extraRendererList = new LinkedList<XYLineAndShapeRenderer>(); for (int i = 0; i < tableModel.getRowCount(); i++) { if (tableModel.getValueAt(i, 0).equals(Boolean.FALSE)) { standardData.addSeries(xySeriesArray[i]); standardRenderer.setSeriesPaint(standardData.getSeriesCount() - 1, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]); } else { // extra axis XYSeriesCollection extraData = new XYSeriesCollection(); extraData.addSeries(xySeriesArray[i]); extraDataList.add(extraData); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); extraRendererList.add(renderer); renderer.setSeriesPaint(0, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]); } } LinkedList<XYSeriesCollection> dataList = new LinkedList<XYSeriesCollection>(); LinkedList<XYLineAndShapeRenderer> rendererList = new LinkedList<XYLineAndShapeRenderer>(); if (!standardData.getSeries().isEmpty()) { dataList.add(standardData); rendererList.add(standardRenderer); } for (XYSeriesCollection data : extraDataList) { dataList.add(data); } for (XYLineAndShapeRenderer renderer : extraRendererList) { rendererList.add(renderer); } // creates axes LinkedList<NumberAxis> axesList = new LinkedList<NumberAxis>(); if (!standardData.getSeries().isEmpty()) { NumberAxis axis = new NumberAxis(messages.getString("ModelExecutionChartPanel.Value")); axis.setNumberFormatOverride(NumberFormat.getInstance(locale)); axesList.add(axis); } for (XYSeriesCollection data : extraDataList) { NumberAxis axis = new NumberAxis((String) data.getSeries(0).getKey()); axis.setNumberFormatOverride(NumberFormat.getInstance(locale)); axesList.add(axis); } // store data and axes in plot XYPlot plot = chart.getXYPlot(); plot.clearRangeAxes(); plot.setRangeAxes(axesList.toArray(new NumberAxis[0])); for (int i = 0; i < plot.getDatasetCount(); i++) { plot.setDataset(i, null); } int datasetIndex = 0; Iterator<XYSeriesCollection> datasetIterator = dataList.iterator(); Iterator<XYLineAndShapeRenderer> rendererIterator = rendererList.iterator(); while (datasetIterator.hasNext()) { plot.setDataset(datasetIndex, datasetIterator.next()); plot.setRenderer(datasetIndex, rendererIterator.next()); datasetIndex++; } for (int i = 0; i < plot.getDatasetCount(); i++) { plot.mapDatasetToRangeAxis(i, i); } } }); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, 0, 10, 0); tablePanel.add(tableScrollPane, c); c.gridx = 0; c.gridy = 1; tablePanel.add(axesButton, c); add(tablePanel, BorderLayout.LINE_END); // PAGE_END: number of rounds and execution button JPanel commandPanel = new JPanel(); commandPanel.add(new JLabel(messages.getString("ModelExecutionChartPanel.NumberRounds"))); final JTextField numberRoundsField = new JTextField("1", 5); numberRoundsField.addFocusListener(this); commandPanel.add(numberRoundsField); executionButton = new JButton(messages.getString("ModelExecutionChartPanel.ExecutionButton.Text")); executionButton.setToolTipText(messages.getString("ModelExecutionChartPanel.ExecutionButton.ToolTipText")); executionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int numberRounds = 0; boolean correctNumber = false; try { numberRounds = integerNumberFormatter.parse(numberRoundsField.getText()).intValue(); } catch (ParseException parseExcep) { // do nothing } if (numberRounds >= 1) { correctNumber = true; } if (correctNumber) { ModelExecutionThread executionThread = new ModelExecutionThread(numberRounds); executionThread.start(); } else { JOptionPane.showMessageDialog(null, messages.getString("ModelExecutionChartPanel.Error.Message"), messages.getString("ModelExecutionChartPanel.Error.Title"), JOptionPane.ERROR_MESSAGE); } } }); commandPanel.add(executionButton); add(commandPanel, BorderLayout.PAGE_END); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
/** * This method initializes jPanelSourceLocation * //from www .j a va 2s.com * @return javax.swing.JPanel */ private JPanel getJPanelSourceLocation() { if (jPanelSourceLocation == null) { GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridx = 1; gridBagConstraints11.insets = new Insets(10, 10, 10, 10); gridBagConstraints11.gridy = 0; GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); gridBagConstraints10.fill = GridBagConstraints.BOTH; gridBagConstraints10.gridy = 0; gridBagConstraints10.weightx = 1.0; gridBagConstraints10.insets = new Insets(10, 10, 10, 0); gridBagConstraints10.anchor = GridBagConstraints.CENTER; gridBagConstraints10.gridx = 0; jPanelSourceLocation = new JPanel(); jPanelSourceLocation.setLayout(new GridBagLayout()); jPanelSourceLocation.setBorder(BorderFactory.createTitledBorder(null, "Source Location", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelSourceLocation.setPreferredSize(new Dimension(500, 200)); jPanelSourceLocation.add(getJTextFieldSourceLocation(), gridBagConstraints10); jPanelSourceLocation.add(getJButtonBrowse(), gridBagConstraints11); } return jPanelSourceLocation; }
From source file:org.jets3t.gui.ObjectsAttributesDialog.java
/** * Initialise the GUI elements to display the given item. *//*from ww w . j a va2s .com*/ private void initGui() { this.setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel unmodifiableAttributesPanel = skinsFactory.createSkinnedJPanel("ObjectStaticAttributesPanel"); unmodifiableAttributesPanel.setLayout(new GridBagLayout()); JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataPanel"); metadataContainer.setLayout(new GridBagLayout()); metadataButtonsContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataButtonsPanel"); metadataButtonsContainer.setLayout(new GridBagLayout()); // Fields to display unmodifiable object details. JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel"); objectKeyLabel.setText("Object key:"); objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField"); objectKeyTextField.setEditable(false); JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel"); objectContentLengthLabel.setText("Size:"); objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField"); objectContentLengthTextField.setEditable(false); JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel"); objectLastModifiedLabel.setText("Last modified:"); objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField"); objectLastModifiedTextField.setEditable(false); JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel"); objectETagLabel.setText("ETag:"); objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField"); objectETagTextField.setEditable(false); JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel"); bucketNameLabel.setText("Bucket:"); bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField"); bucketLocationTextField.setEditable(false); ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel"); ownerNameLabel.setText("Owner name:"); ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField"); ownerNameTextField.setEditable(false); ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel"); ownerIdLabel.setText("Owner ID:"); ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField"); ownerIdTextField.setEditable(false); int row = 0; unmodifiableAttributesPanel.add(objectKeyLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectKeyTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectContentLengthLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectContentLengthTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectLastModifiedLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectLastModifiedTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectETagLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectETagTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(ownerNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(ownerIdLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(bucketLocationTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Build metadata table. objectMetadataTableModel = new DefaultTableModel(new Object[] { "Name", "Value" }, 0) { private static final long serialVersionUID = -3762866886166776851L; public boolean isCellEditable(int row, int column) { return isModifyMode(); } }; metadataTableSorter = new TableSorter(objectMetadataTableModel); metadataTable = skinsFactory.createSkinnedJTable("MetadataTable"); metadataTable.setModel(metadataTableSorter); metadataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && removeMetadataItemButton != null) { int row = metadataTable.getSelectedRow(); removeMetadataItemButton.setEnabled(row >= 0); } } }); metadataTableSorter.setTableHeader(metadataTable.getTableHeader()); metadataTableSorter.setSortingStatus(0, TableSorter.ASCENDING); metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsHorizontalSpace, 0, 0)); // Add/remove buttons for metadata table. removeMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); removeMetadataItemButton.setEnabled(false); removeMetadataItemButton.setToolTipText("Remove the selected metadata item(s)"); guiUtils.applyIcon(removeMetadataItemButton, "/images/nuvola/16x16/actions/viewmag-.png"); removeMetadataItemButton.addActionListener(this); removeMetadataItemButton.setActionCommand("removeMetadataItem"); addMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); addMetadataItemButton.setToolTipText("Add a new metadata item"); guiUtils.applyIcon(addMetadataItemButton, "/images/nuvola/16x16/actions/viewmag+.png"); addMetadataItemButton.setActionCommand("addMetadataItem"); addMetadataItemButton.addActionListener(this); metadataButtonsContainer.add(removeMetadataItemButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataButtonsContainer.add(addMetadataItemButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataContainer.add(metadataButtonsContainer, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); metadataButtonsContainer.setVisible(false); // OK Button. okButton = skinsFactory.createSkinnedJButton("ObjectPropertiesOKButton"); okButton.setText("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(this); // Cancel Button. cancelButton = null; cancelButton = skinsFactory.createSkinnedJButton("ObjectPropertiesCancelButton"); cancelButton.setText("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); cancelButton.setVisible(false); // Recognize and handle ENTER, ESCAPE, PAGE_UP, and PAGE_DOWN key presses. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -7768790936535999307L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_UP"), "PAGE_UP"); this.getRootPane().getActionMap().put("PAGE_UP", new AbstractAction() { private static final long serialVersionUID = -6324229423705756219L; public void actionPerformed(ActionEvent actionEvent) { previousObjectButton.doClick(); } }); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_DOWN"), "PAGE_DOWN"); this.getRootPane().getActionMap().put("PAGE_DOWN", new AbstractAction() { private static final long serialVersionUID = -5808972377672449421L; public void actionPerformed(ActionEvent actionEvent) { nextObjectButton.doClick(); } }); // Put it all together. row = 0; JPanel container = skinsFactory.createSkinnedJPanel("ObjectPropertiesPanel"); container.setLayout(new GridBagLayout()); container.add(unmodifiableAttributesPanel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); // Object previous and next buttons, if we have multiple objects. previousObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesPreviousButton"); guiUtils.applyIcon(previousObjectButton, "/images/nuvola/16x16/actions/1leftarrow.png"); previousObjectButton.addActionListener(this); previousObjectButton.setEnabled(false); nextObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesNextButton"); guiUtils.applyIcon(nextObjectButton, "/images/nuvola/16x16/actions/1rightarrow.png"); nextObjectButton.addActionListener(this); nextObjectButton.setEnabled(false); currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectPropertiesCurrentObjectLabel"); currentObjectLabel.setHorizontalAlignment(JLabel.CENTER); nextPreviousPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesNextPreviousPanel"); nextPreviousPanel.setLayout(new GridBagLayout()); nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); nextPreviousPanel.setVisible(false); row++; JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel"); metadataLabel.setText("<html><b>Metadata Attributes</b></html>"); metadataLabel.setHorizontalAlignment(JLabel.CENTER); container.add(metadataLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0)); container.add(metadataContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Destination Access Control List setting. destinationPanel = skinsFactory.createSkinnedJPanel("DestinationPanel"); destinationPanel.setLayout(new GridBagLayout()); JPanel actionButtonsPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesActionButtonsPanel"); actionButtonsPanel.setLayout(new GridBagLayout()); actionButtonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); actionButtonsPanel.add(okButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); cancelButton.setVisible(false); container.add(actionButtonsPanel, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().add(container); this.pack(); this.setSize(new Dimension(450, 500)); this.setLocationRelativeTo(this.getOwner()); }
From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java
/** * Build the student body states panel.// ww w. j a v a 2 s . co m * * @return Student body states panel. */ private JPanel buildUiStudentBodyStatesPanel() { // Create a new grid bag constraints configuration instance GridBagConstraints c = new GridBagConstraints(); // Create the panel final JPanel studentBodyStatePanel = new JPanel(new GridBagLayout()); // Add the label c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.insets = new Insets(8, 2, 2, 0); c.anchor = GridBagConstraints.SOUTHWEST; studentBodyStatePanel.add(new JLabel("Student's body states:"), c); // Create a list for the students body states this.studentBodyStates = new EntityViewComponent(Core.getInstance().getBodyStateManager()); // Add the list c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; c.weightx = 1; c.weighty = 1; c.insets = new Insets(0, 0, 0, 0); c.anchor = GridBagConstraints.CENTER; studentBodyStatePanel.add(this.studentBodyStates, c); // Update the student body state list when the selected student is changed this.studentList.addSelectionChangeListenerListener(this::updateStudentBodyStateList); // Set the minimum preferred size of the body states list this.studentBodyStates.setPreferredSize(new Dimension(200, 100)); // Return the panel return studentBodyStatePanel; }