List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java
/** * This method initializes jPanel /*from ww w .j ava2 s . c o m*/ * * @return javax.swing.JPanel */ private JPanel getJPanelSourceCode() { if (jPanelSourceCode == null) { GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); gridBagConstraints5.fill = GridBagConstraints.BOTH; gridBagConstraints5.weighty = 1.0; gridBagConstraints5.weightx = 1.0; jPanelSourceCode = new JPanel(); jPanelSourceCode.setLayout(new GridBagLayout()); jPanelSourceCode.add(getJScrollPaneSourceCode(), gridBagConstraints5); } return jPanelSourceCode; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createLocationsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;/* w ww .j a v a 2 s . co m*/ JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Working folder")); folderField = new JTextField(); folderField.setText((new File("").getAbsolutePath())); folderField.setToolTipText("The folder where all output will be written"); folderPanel.add(folderField); JButton pickButton = new JButton("Pick folder"); pickButton.setToolTipText("Pick a different working folder"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickFolder(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel sourcePanel = new JPanel(); sourcePanel.setLayout(new GridLayout(0, 2)); sourcePanel.setBorder(BorderFactory.createTitledBorder("Source data location")); sourcePanel.add(new JLabel("Data type")); sourceType = new JComboBox<String>(new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL", "MS Access", "PDW", "Redshift", "Teradata" }); sourceType.setToolTipText("Select the type of source data available"); sourceType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { sourceIsFiles = arg0.getItem().toString().equals("Delimited text files"); sourceServerField.setEnabled(!sourceIsFiles); sourceUserField.setEnabled(!sourceIsFiles); sourcePasswordField.setEnabled(!sourceIsFiles); sourceDatabaseField.setEnabled(!sourceIsFiles); sourceDelimiterField.setEnabled(sourceIsFiles); addAllButton.setEnabled(!sourceIsFiles); if (!sourceIsFiles && arg0.getItem().toString().equals("Oracle")) { sourceServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); sourceUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); sourcePasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); sourceDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!sourceIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { sourceServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!sourceIsFiles) { sourceServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) sourceUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); sourcePanel.add(sourceType); sourcePanel.add(new JLabel("Server location")); sourceServerField = new JTextField("127.0.0.1"); sourceServerField.setEnabled(false); sourcePanel.add(sourceServerField); sourcePanel.add(new JLabel("User name")); sourceUserField = new JTextField(""); sourceUserField.setEnabled(false); sourcePanel.add(sourceUserField); sourcePanel.add(new JLabel("Password")); sourcePasswordField = new JPasswordField(""); sourcePasswordField.setEnabled(false); sourcePanel.add(sourcePasswordField); sourcePanel.add(new JLabel("Database name")); sourceDatabaseField = new JTextField(""); sourceDatabaseField.setEnabled(false); sourcePanel.add(sourceDatabaseField); sourcePanel.add(new JLabel("Delimiter")); sourceDelimiterField = new JTextField(","); sourceDelimiterField.setToolTipText("The delimiter that separates values. Enter 'tab' for tab."); sourcePanel.add(sourceDelimiterField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(sourcePanel, c); JPanel testConnectionButtonPanel = new JPanel(); testConnectionButtonPanel.setLayout(new BoxLayout(testConnectionButtonPanel, BoxLayout.X_AXIS)); testConnectionButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getSourceDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); testConnectionButtonPanel.add(testConnectionButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(testConnectionButtonPanel, c); return panel; }
From source file:dmh.kuebiko.view.NoteStackFrame.java
/** * Initialize the contents of the frame. The contents of this method was * generated by Window Builder Pro./*from w w w. j a v a 2 s.c o m*/ */ private void initialize() { setTitle(buildTitle()); setBounds(100, 100, 450, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE }; getContentPane().setLayout(gridBagLayout); horizontalStrut = Box.createHorizontalStrut(20); horizontalStrut.setMinimumSize(new Dimension(3, 0)); horizontalStrut.setPreferredSize(new Dimension(3, 0)); horizontalStrut.setSize(new Dimension(3, 0)); GridBagConstraints gbc_horizontalStrut = new GridBagConstraints(); gbc_horizontalStrut.insets = new Insets(0, 0, 0, 0); gbc_horizontalStrut.gridx = 0; gbc_horizontalStrut.gridy = 0; getContentPane().add(horizontalStrut, gbc_horizontalStrut); GridBagConstraints gbc_stateImageLabel = new GridBagConstraints(); gbc_stateImageLabel.insets = new Insets(0, 0, 0, 0); gbc_stateImageLabel.anchor = GridBagConstraints.EAST; gbc_stateImageLabel.gridx = 1; gbc_stateImageLabel.gridy = 0; stateImageLabel.setBorder(null); stateImageLabel.setHorizontalAlignment(SwingConstants.CENTER); getContentPane().add(stateImageLabel, gbc_stateImageLabel); searchText = new JTextField(); GridBagConstraints gbc_searchText = new GridBagConstraints(); gbc_searchText.insets = new Insets(0, 0, 0, 0); gbc_searchText.fill = GridBagConstraints.HORIZONTAL; gbc_searchText.gridx = 2; gbc_searchText.gridy = 0; getContentPane().add(searchText, gbc_searchText); searchText.setColumns(10); if (SystemUtils.IS_OS_MAC_OSX) { // Make the text field look like the standard Mac OS X search // box control. searchText.putClientProperty("JTextField.variant", "search"); } splitPane = new JSplitPane(); splitPane.setBorder(null); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); GridBagConstraints gbc_splitPane = new GridBagConstraints(); gbc_splitPane.gridwidth = 3; gbc_splitPane.gridheight = 4; gbc_splitPane.insets = new Insets(0, 0, 0, 0); gbc_splitPane.fill = GridBagConstraints.BOTH; gbc_splitPane.gridx = 0; gbc_splitPane.gridy = 1; getContentPane().add(splitPane, gbc_splitPane); notePanel = new NotePanel(); notePanel.getHuxleyUiManager().setOnTextChangeCallback(new Callback<Boolean>() { @Override public void callback(Boolean input) { toggleUnsavedChangeIndicator(input); } }); splitPane.setRightComponent(notePanel); noteTableScroll = new JScrollPane(); noteTableScroll.setMinimumSize(new Dimension(23, 100)); splitPane.setLeftComponent(noteTableScroll); noteTable = newNoteTable(); noteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); noteTableScroll.setViewportView(noteTable); ActionObserverUtil.registerEnMass(actionMngr, observable, notePanel.getHuxleyUiManager().getTextAction(TextAction.INSERT_DATE)); insertDateMenuItem = new JMenuItem(actionMngr.getAction(InsertDynamicTextAction.class)); insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); textMenu.add(insertDateMenuItem); }
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
public static void showErrorDialog(Component parent, String title, String textMessage, Throwable cause) { final String stacktrace; if (cause == null) { stacktrace = null;//from w w w.j a va 2 s.c o m } else { final ByteArrayOutputStream stackTrace = new ByteArrayOutputStream(); cause.printStackTrace(new PrintStream(stackTrace)); stacktrace = new String(stackTrace.toByteArray()); } final JDialog dialog = new JDialog((Window) null, title); dialog.setModal(true); final JTextArea message = createMultiLineLabel(textMessage); final DialogResult[] outcome = { DialogResult.CANCEL }; final JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { outcome[0] = DialogResult.YES; dialog.dispose(); } }); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(okButton); final JPanel messagePanel = new JPanel(); messagePanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 0.1; cnstrs.gridheight = 1; messagePanel.add(message, cnstrs); if (stacktrace != null) { final JTextArea createMultiLineLabel = new JTextArea(stacktrace); createMultiLineLabel.setBackground(null); createMultiLineLabel.setEditable(false); createMultiLineLabel.setBorder(null); createMultiLineLabel.setLineWrap(false); createMultiLineLabel.setWrapStyleWord(false); final JScrollPane pane = new JScrollPane(createMultiLineLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); cnstrs = constraints(0, 1, true, true, GridBagConstraints.BOTH); cnstrs.weightx = 1.0; cnstrs.weighty = 0.9; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; messagePanel.add(pane, cnstrs); } final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 1.0; cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right panel.add(messagePanel, cnstrs); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right panel.add(buttonPanel, cnstrs); dialog.getContentPane().add(panel); dialog.setMinimumSize(new Dimension(600, 400)); dialog.setPreferredSize(new Dimension(600, 400)); dialog.setMaximumSize(new Dimension(600, 400)); dialog.pack(); dialog.setVisible(true); }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.dialogs.RepositoryTreeDialog.java
/** * @noinspection ReuseOfLocalVariable//ww w . j av a2s. c o m */ protected Component createContentPane() { final JScrollPane treeView = new JScrollPane(repositoryBrowser); final JPanel newFolderButtonPanel = new JPanel(new BorderLayout()); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); if (addNewButtonPanel) { final JButton newFolder = new JButton(new NewFolderAction()); newFolder.setBorder(BorderFactory.createEmptyBorder()); final JLabel label = new JLabel( Messages.getInstance().getString("SolutionRepositoryTreeDialog.SelectLocation")); label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80)); newFolderButtonPanel.add(label, BorderLayout.CENTER); newFolderButtonPanel.add(newFolder, BorderLayout.EAST); c.insets = new Insets(2, 10, 0, 10); c.anchor = GridBagConstraints.WEST; c.gridx = 0; c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; panel.add(newFolderButtonPanel, c); } c = new GridBagConstraints(); c.insets = new Insets(0, 10, 5, 10); c.gridx = 0; c.gridy = 1; c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; panel.add(treeView, c); c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 10, 5, 10); c.gridx = 0; c.gridy = 2; c.fill = GridBagConstraints.HORIZONTAL; panel.add(new JCheckBox(new ShowHiddenFilesAction())); return panel; }
From source file:org.executequery.gui.editor.QueryEditor.java
private void init() throws Exception { // construct the two query text area and results panels statusBar = new QueryEditorStatusBar(); statusBar.setBorder(BorderFactory.createEmptyBorder(0, -1, -2, -2)); editorPanel = new QueryEditorTextPanel(this); resultsPanel = new QueryEditorResultsPanel(this); delegate = new QueryEditorDelegate(this); popup = new QueryEditorPopupMenu(delegate); editorPanel.addEditorPaneMouseListener(popup); baseEditorPanel = new JPanel(new BorderLayout()); baseEditorPanel.add(editorPanel, BorderLayout.CENTER); baseEditorPanel.add(statusBar, BorderLayout.SOUTH); baseEditorPanel//from w w w.j a va2 s . c o m .setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, GUIUtilities.getDefaultBorderColour())); // add to a base panel - when last tab closed visible set // to false on the tab pane and split collapses - want to avoid this resultsBase = new JPanel(new BorderLayout()); resultsBase.add(resultsPanel, BorderLayout.CENTER); if (new SplitPaneFactory().usesCustomSplitPane()) { splitPane = new EditorSplitPane(JSplitPane.VERTICAL_SPLIT, baseEditorPanel, resultsBase); } else { splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, baseEditorPanel, resultsBase); } splitPane.setDividerSize(4); splitPane.setResizeWeight(0.5); // --------------------------------------- // the tool bar and conn combo toolBar = new QueryEditorToolBar(editorPanel.getTextPaneActionMap(), editorPanel.getTextPaneInputMap()); Vector<DatabaseConnection> connections = ConnectionManager.getActiveConnections(); connectionsCombo = new OpenConnectionsComboBox(this, connections); maxRowCountCheckBox = new JCheckBox(); maxRowCountCheckBox.setToolTipText("Enable/disable max records"); maxRowCountCheckBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { maxRowCountCheckBoxSelected(); } }); maxRowCountField = new MaxRowCountField(this); toolsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(0, 0, 0, 0); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy++; gbc.gridx++; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; toolsPanel.add(toolBar, gbc); gbc.gridy++; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 7; gbc.insets.left = 5; gbc.insets.right = 10; toolsPanel.add(createLabel("Connection:", 'C'), gbc); gbc.gridx++; gbc.weightx = 1.0; gbc.insets.top = 2; gbc.insets.bottom = 2; gbc.insets.left = 0; gbc.insets.right = 0; toolsPanel.add(connectionsCombo, gbc); gbc.gridx++; gbc.weightx = 0; gbc.insets.left = 0; gbc.insets.top = 7; gbc.insets.right = 10; gbc.insets.left = 10; toolsPanel.add(createLabel("Filter:", 'l'), gbc); gbc.gridx++; gbc.weightx = 0.8; gbc.insets.top = 2; gbc.insets.bottom = 2; gbc.insets.right = 2; gbc.insets.left = 0; gbc.fill = GridBagConstraints.BOTH; toolsPanel.add(createResultSetFilterTextField(), gbc); gbc.gridx++; gbc.weightx = 0; gbc.insets.top = 5; gbc.insets.left = 10; toolsPanel.add(maxRowCountCheckBox, gbc); gbc.gridx++; gbc.insets.left = 0; gbc.insets.top = 7; gbc.insets.right = 10; toolsPanel.add(createLabel("Max Rows:", 'R'), gbc); gbc.gridx++; gbc.weightx = 0.3; gbc.insets.top = 2; gbc.insets.bottom = 2; gbc.insets.right = 2; gbc.fill = GridBagConstraints.BOTH; toolsPanel.add(maxRowCountField, gbc); splitPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3)); JPanel base = new JPanel(new BorderLayout()); base.add(toolsPanel, BorderLayout.NORTH); base.add(splitPane, BorderLayout.CENTER); gbc.gridy = 1; gbc.gridx = 1; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.insets.top = 0; gbc.insets.bottom = 0; gbc.insets.left = 0; gbc.insets.right = 0; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.SOUTHEAST; add(base, gbc); // register for connection and keyword events EventMediator.registerListener(this); addDeleteLineActionMapping(); setEditorPreferences(); statusBar.setCaretPosition(1, 1); statusBar.setInsertionMode("INS"); }
From source file:es.emergya.ui.base.LoginWindow.java
private void initialize() { ventana.getContentPane().removeAll(); ventana.setLayout(new BorderLayout()); ventana.setSize(new Dimension(800, 600)); JPanel panel = new JPanel(new GridBagLayout()); panel.setBackground(Color.WHITE); JPanel logos = new JPanel(new GridLayout(2, 1)); logos.add(new JLabel(LogicConstants.getIcon("login_logo_cliente"))); logos.add(new JLabel(LogicConstants.getIcon("login_logo"))); logos.setBackground(Color.WHITE); JLabel label = new JLabel(); label.setText(i18n.getString("11")); //$NON-NLS-1$ JLabel labelUsuario = new JLabel(); labelUsuario.setText(i18n.getString("12")); //$NON-NLS-1$ JLabel lablep = new JLabel(); lablep.setText(i18n.getString("13")); //$NON-NLS-1$ panel.add(logos, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(error, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(labelUsuario, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(usuario, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(lablep, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(pass, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(conectando, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(login, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); panel.setBorder(new EmptyBorder(100, 100, 100, 100)); ventana.add(panel, BorderLayout.CENTER); JPanel abajo = new JPanel(); abajo.setLayout(new FlowLayout(FlowLayout.RIGHT)); abajo.add(version);// www. j a v a2 s .c o m abajo.setOpaque(false); ventana.add(abajo, BorderLayout.SOUTH); try { label.setFont(LogicConstants.deriveBoldFont(20.0f)); labelUsuario.setFont(LogicConstants.deriveBoldFont(20.0f)); lablep.setFont(LogicConstants.deriveBoldFont(20.0f)); login.setFont(LogicConstants.deriveBoldFont(20.0f)); error.setFont(LogicConstants.getBoldFont()); } catch (Exception e) { LOG.error("Error al inicializar el login", e); } ventana.setLocationRelativeTo(null); // ventana.pack(); }
From source file:com.hccl.nlip.GUIMainPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Super Fan bestActionChartPanel = new JPanel(); consolePanel = new JPanel(); RLCaptionPanel = new JPanel(); RLCaption = new JLabel(); discountLabel = new JLabel(); discountPanel = new JPanel(); discountDec = new JButton(); discountField = new JTextField(); discountInc = new JButton(); rewardCollisionLabel = new JLabel(); rewardCollisionPanel = new JPanel(); rewardCollisionDec = new JButton(); rewardCollisionField = new JTextField(); rewardCollisionInc = new JButton(); rewadGoalLabel = new JLabel(); rewardGoalPanel = new JPanel(); rewardGoalDec = new JButton(); rewardGoalField = new JTextField(); rewardGoalInc = new JButton(); rewardOneStepLabel = new JLabel(); rewardOneStepPanel = new JPanel(); rewardOneStepDec = new JButton(); rewardOneStepField = new JTextField(); rewardOneStepInc = new JButton(); fixedEpsilonCheckBox = new JCheckBox(); fixedEpsilonPanel = new JPanel(); fixedEpsilonField = new JTextField(); sepPanel1 = new JPanel(); separator1 = new JSeparator(); envCaptionPanel = new JPanel(); envLabel = new JLabel(); obstaclesLabel = new JLabel(); obstaclesPanel = new JPanel(); obstaclesComboBox = new JComboBox(); goalsLabel = new JLabel(); goalsPanel = new JPanel(); goalsComboBox = new JComboBox(); sepPanel2 = new JPanel(); separator2 = new JSeparator(); controlCaptionPanel = new JPanel(); controlLabel = new JLabel(); displayActionsPanel = new JPanel(); displayActionsCheckBox = new JCheckBox(); controlActionsPanel = new JPanel(); stepBtn = new JButton(); episodeBtn = new JButton(); animateBtn = new JButton(); resetBtn = new JButton(); controlEpisodesPanel = new JPanel(); performEpisodesBtn = new JButton(); numberEpisodesField = new JTextField(); numberEpisodesLabel = new JLabel(); episodesProgressBar = new JProgressBar(); sepPanel3 = new JPanel(); separator3 = new JSeparator(); totalStepsLabel = new JLabel(); totalStepsField = new JLabel(); totalEpisodesLabel = new JLabel(); totalEpisodesFields = new JLabel(); totalRewardLabel = new JLabel(); totalRewardField = new JLabel(); dicSizeField = new JLabel(); dicSizeLabel = new JLabel(); //======== this ======== setPreferredSize(new Dimension(700, 500)); setMinimumSize(new Dimension(780, 580)); setLayout(new GridBagLayout()); ((GridBagLayout) getLayout()).columnWidths = new int[] { 396, 239, 0 }; ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0 }; ((GridBagLayout) getLayout()).columnWeights = new double[] { 1.0, 0.0, 1.0E-4 }; ((GridBagLayout) getLayout()).rowWeights = new double[] { 1.0, 1.0E-4 }; //======== bestActionChartPanel ======== {/*from www .ja va 2 s . c o m*/ bestActionChartPanel.setPreferredSize(new Dimension(250, 250)); bestActionChartPanel.setLayout(new BorderLayout()); } add(bestActionChartPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); //======== consolePanel ======== { consolePanel.setLayout(new GridBagLayout()); ((GridBagLayout) consolePanel.getLayout()).columnWidths = new int[] { 108, 129, 0 }; ((GridBagLayout) consolePanel.getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ((GridBagLayout) consolePanel.getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) consolePanel.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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; //======== RLCaptionPanel ======== { RLCaptionPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); //---- RLCaption ---- RLCaption.setText("RL Parameters"); RLCaption.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 16)); RLCaptionPanel.add(RLCaption); } consolePanel.add(RLCaptionPanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- discountLabel ---- discountLabel.setText("Discount:"); consolePanel.add(discountLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== discountPanel ======== { discountPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); //---- discountDec ---- discountDec.setText("-"); discountDec.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { discountDecActionPerformed(e); } }); discountPanel.add(discountDec); //---- discountField ---- discountField.setText("000.00"); discountField.setColumns(6); discountPanel.add(discountField); //---- discountInc ---- discountInc.setText("+"); discountInc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { discountIncActionPerformed(e); } }); discountPanel.add(discountInc); } consolePanel.add(discountPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- rewardCollisionLabel ---- rewardCollisionLabel.setText("Reward collision:"); consolePanel.add(rewardCollisionLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== rewardCollisionPanel ======== { rewardCollisionPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); //---- rewardCollisionDec ---- rewardCollisionDec.setText("-"); rewardCollisionDec.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardCollisionDecActionPerformed(e); } }); rewardCollisionPanel.add(rewardCollisionDec); //---- rewardCollisionField ---- rewardCollisionField.setText("000.00"); rewardCollisionField.setColumns(6); rewardCollisionPanel.add(rewardCollisionField); //---- rewardCollisionInc ---- rewardCollisionInc.setText("+"); rewardCollisionInc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardCollisionIncActionPerformed(e); } }); rewardCollisionPanel.add(rewardCollisionInc); } consolePanel.add(rewardCollisionPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- rewadGoalLabel ---- rewadGoalLabel.setText("Reward goal:"); consolePanel.add(rewadGoalLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== rewardGoalPanel ======== { rewardGoalPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); //---- rewardGoalDec ---- rewardGoalDec.setText("-"); rewardGoalDec.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardGoalDecActionPerformed(e); } }); rewardGoalPanel.add(rewardGoalDec); //---- rewardGoalField ---- rewardGoalField.setText("000.00"); rewardGoalField.setColumns(6); rewardGoalPanel.add(rewardGoalField); //---- rewardGoalInc ---- rewardGoalInc.setText("+"); rewardGoalInc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardGoalIncActionPerformed(e); } }); rewardGoalPanel.add(rewardGoalInc); } consolePanel.add(rewardGoalPanel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- rewardOneStepLabel ---- rewardOneStepLabel.setText("Reward one step:"); consolePanel.add(rewardOneStepLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== rewardOneStepPanel ======== { rewardOneStepPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); //---- rewardOneStepDec ---- rewardOneStepDec.setText("-"); rewardOneStepDec.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardOneStepDecActionPerformed(e); } }); rewardOneStepPanel.add(rewardOneStepDec); //---- rewardOneStepField ---- rewardOneStepField.setText("000.00"); rewardOneStepField.setColumns(6); rewardOneStepPanel.add(rewardOneStepField); //---- rewardOneStepInc ---- rewardOneStepInc.setText("+"); rewardOneStepInc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rewardOneStepIncActionPerformed(e); } }); rewardOneStepPanel.add(rewardOneStepInc); } consolePanel.add(rewardOneStepPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- fixedEpsilonCheckBox ---- fixedEpsilonCheckBox.setText("Fixed Epsilon:"); fixedEpsilonCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fixedEpsilonCheckBoxActionPerformed(e); } }); consolePanel.add(fixedEpsilonCheckBox, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== fixedEpsilonPanel ======== { fixedEpsilonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); //---- fixedEpsilonField ---- fixedEpsilonField.setText("00.10"); fixedEpsilonField.setColumns(6); fixedEpsilonPanel.add(fixedEpsilonField); } consolePanel.add(fixedEpsilonPanel, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0)); //======== sepPanel1 ======== { sepPanel1.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); //---- separator1 ---- separator1.setPreferredSize(new Dimension(210, 2)); sepPanel1.add(separator1); } consolePanel.add(sepPanel1, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== envCaptionPanel ======== { envCaptionPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); //---- envLabel ---- envLabel.setText("Environment"); envLabel.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 16)); envCaptionPanel.add(envLabel); } consolePanel.add(envCaptionPanel, new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- obstaclesLabel ---- obstaclesLabel.setText("Obstacles:"); consolePanel.add(obstaclesLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== obstaclesPanel ======== { obstaclesPanel.setLayout(new FlowLayout()); //---- obstaclesComboBox ---- obstaclesComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { obstaclesComboBoxActionPerformed(e); } }); obstaclesPanel.add(obstaclesComboBox); } consolePanel.add(obstaclesPanel, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0)); //---- goalsLabel ---- goalsLabel.setText("Goals:"); consolePanel.add(goalsLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //======== goalsPanel ======== { goalsPanel.setLayout(new FlowLayout()); //---- goalsComboBox ---- goalsComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goalsComboBoxActionPerformed(e); } }); goalsPanel.add(goalsComboBox); } consolePanel.add(goalsPanel, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0)); //======== sepPanel2 ======== { sepPanel2.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); //---- separator2 ---- separator2.setPreferredSize(new Dimension(210, 2)); sepPanel2.add(separator2); } consolePanel.add(sepPanel2, new GridBagConstraints(0, 10, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== controlCaptionPanel ======== { controlCaptionPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); //---- controlLabel ---- controlLabel.setText("Control"); controlLabel.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 16)); controlCaptionPanel.add(controlLabel); } consolePanel.add(controlCaptionPanel, new GridBagConstraints(0, 11, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== displayActionsPanel ======== { displayActionsPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); //---- displayActionsCheckBox ---- displayActionsCheckBox.setText("Display action vectors"); displayActionsCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayActionsCheckBoxActionPerformed(e); } }); displayActionsPanel.add(displayActionsCheckBox); } consolePanel.add(displayActionsPanel, new GridBagConstraints(0, 12, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== controlActionsPanel ======== { controlActionsPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0)); //---- stepBtn ---- stepBtn.setText("1 Step"); stepBtn.setMargin(new Insets(2, 2, 2, 2)); stepBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stepBtnActionPerformed(e); } }); controlActionsPanel.add(stepBtn); //---- episodeBtn ---- episodeBtn.setText("1 Episode"); episodeBtn.setMargin(new Insets(2, 4, 2, 4)); episodeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { episodeBtnActionPerformed(e); } }); controlActionsPanel.add(episodeBtn); //---- animateBtn ---- animateBtn.setText("Animate"); animateBtn.setMargin(new Insets(2, 2, 2, 2)); animateBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { animateBtnActionPerformed(e); } }); controlActionsPanel.add(animateBtn); //---- resetBtn ---- resetBtn.setText("Reset"); resetBtn.setMargin(new Insets(2, 2, 2, 2)); resetBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetBtnActionPerformed(e); } }); controlActionsPanel.add(resetBtn); } consolePanel.add(controlActionsPanel, new GridBagConstraints(0, 13, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== controlEpisodesPanel ======== { controlEpisodesPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0)); //---- performEpisodesBtn ---- performEpisodesBtn.setText("Perform"); performEpisodesBtn.setMargin(new Insets(2, 2, 2, 2)); performEpisodesBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performEpisodesBtnActionPerformed(e); } }); controlEpisodesPanel.add(performEpisodesBtn); //---- numberEpisodesField ---- numberEpisodesField.setText("100"); numberEpisodesField.setColumns(5); controlEpisodesPanel.add(numberEpisodesField); //---- numberEpisodesLabel ---- numberEpisodesLabel.setText("episodes"); controlEpisodesPanel.add(numberEpisodesLabel); //---- episodesProgressBar ---- episodesProgressBar.setMinimumSize(new Dimension(5, 10)); episodesProgressBar.setPreferredSize(new Dimension(80, 20)); controlEpisodesPanel.add(episodesProgressBar); } consolePanel.add(controlEpisodesPanel, new GridBagConstraints(0, 14, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //======== sepPanel3 ======== { sepPanel3.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); //---- separator3 ---- separator3.setPreferredSize(new Dimension(210, 2)); sepPanel3.add(separator3); } consolePanel.add(sepPanel3, new GridBagConstraints(0, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- totalStepsLabel ---- totalStepsLabel.setText("Total steps:"); consolePanel.add(totalStepsLabel, new GridBagConstraints(0, 16, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //---- totalStepsField ---- totalStepsField.setText("0000000"); consolePanel.add(totalStepsField, new GridBagConstraints(1, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- totalEpisodesLabel ---- totalEpisodesLabel.setText("Total episodes:"); consolePanel.add(totalEpisodesLabel, new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //---- totalEpisodesFields ---- totalEpisodesFields.setText("0000000"); consolePanel.add(totalEpisodesFields, new GridBagConstraints(1, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- totalRewardLabel ---- totalRewardLabel.setText("Total reward:"); consolePanel.add(totalRewardLabel, new GridBagConstraints(0, 18, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); //---- totalRewardField ---- totalRewardField.setText("00000000.00000000"); consolePanel.add(totalRewardField, new GridBagConstraints(1, 18, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- dicSizeField ---- dicSizeField.setText("00000000.00000000"); consolePanel.add(dicSizeField, new GridBagConstraints(1, 19, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- dicSizeLabel ---- dicSizeLabel.setText("Dictionary size:"); consolePanel.add(dicSizeLabel, new GridBagConstraints(0, 19, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0)); } add(consolePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); // JFormDesigner - End of component initialization //GEN-END:initComponents mazeEnv = new MazeEnvironment(); controller = (GPSARSASparseController) mazeEnv.controller(); JFreeChart jFreeChart = mazeEnv.genGraph(); //Put the jFreeChart in a chartPanel ChartPanel chartPanel = new ChartPanel(jFreeChart); chartPanel.setPreferredSize(new Dimension(250, 250)); syncParamsToGUI(); syncStatusToGUI(); bestActionChartPanel.add(chartPanel, BorderLayout.CENTER); }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI */// ww w . j a v a 2 s . co m protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:org.jivesoftware.sparkimpl.updater.CheckUpdates.java
public void downloadUpdate(final File downloadedFile, final SparkVersion version) { final java.util.Timer timer = new java.util.Timer(); // Prepare HTTP post final GetMethod post = new GetMethod(version.getDownloadURL()); // Get HTTP client Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443)); final HttpClient httpclient = new HttpClient(); String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) { try {/*from ww w . ja v a 2 s. c om*/ httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); } catch (NumberFormatException e) { Log.error(e); } } // Execute request try { int result = httpclient.executeMethod(post); if (result != 200) { return; } long length = post.getResponseContentLength(); int contentLength = (int) length; bar = new JProgressBar(0, contentLength); } catch (IOException e) { Log.error(e); } final JFrame frame = new JFrame(Res.getString("title.downloading.im.client")); frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage()); titlePanel = new TitlePanel(Res.getString("title.upgrading.client"), Res.getString("message.version", version.getVersion()), SparkRes.getImageIcon(SparkRes.SEND_FILE_24x24), true); final Thread thread = new Thread(new Runnable() { public void run() { try { InputStream stream = post.getResponseBodyAsStream(); long size = post.getResponseContentLength(); ByteFormat formater = new ByteFormat(); sizeText = formater.format(size); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText)); downloadedFile.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(downloadedFile); copy(stream, out); out.close(); if (!cancel) { downloadComplete = true; promptForInstallation(downloadedFile, Res.getString("title.download.complete"), Res.getString("message.restart.spark")); } else { out.close(); downloadedFile.delete(); } UPDATING = false; frame.dispose(); } catch (Exception ex) { // Nothing to do } finally { timer.cancel(); // Release current connection to the connection pool once you are done post.releaseConnection(); } } }); frame.getContentPane().setLayout(new GridBagLayout()); frame.getContentPane().add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); frame.getContentPane().add(bar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); JEditorPane pane = new JEditorPane(); boolean displayContentPane = version.getChangeLogURL() != null || version.getDisplayMessage() != null; try { pane.setEditable(false); if (version.getChangeLogURL() != null) { pane.setEditorKit(new HTMLEditorKit()); pane.setPage(version.getChangeLogURL()); } else if (version.getDisplayMessage() != null) { pane.setText(version.getDisplayMessage()); } if (displayContentPane) { frame.getContentPane().add(new JScrollPane(pane), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } } catch (IOException e) { Log.error(e); } frame.getContentPane().setBackground(Color.WHITE); frame.pack(); if (displayContentPane) { frame.setSize(600, 400); } else { frame.setSize(400, 100); } frame.setLocationRelativeTo(SparkManager.getMainWindow()); GraphicUtils.centerWindowOnScreen(frame); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { thread.interrupt(); cancel = true; UPDATING = false; if (!downloadComplete) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.updating.cancelled"), Res.getString("title.cancelled"), JOptionPane.ERROR_MESSAGE); } } }); frame.setVisible(true); thread.start(); timer.scheduleAtFixedRate(new TimerTask() { int seconds = 1; public void run() { ByteFormat formatter = new ByteFormat(); long value = bar.getValue(); long average = value / seconds; String text = formatter.format(average) + "/Sec"; String total = formatter.format(value); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText) + "\n" + Res.getString("message.transfer.rate") + ": " + text + "\n" + Res.getString("message.total.downloaded") + ": " + total); seconds++; } }, 1000, 1000); }