List of usage examples for javax.swing JProgressBar JProgressBar
public JProgressBar()
From source file:net.pandoragames.far.ui.swing.FileListPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BorderLayout()); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); tableModel = componentRepository.getTableModel(); componentRepository.getResetDispatcher().addResetable(tableModel); componentRepository.getSearchBaseListener().addResetable(tableModel); componentRepository.getUndoListener().setTableModel(tableModel); JTable fileListTable = componentRepository.getFileSetTable(); int totalWidth = fileListTable.getPreferredSize().width; fileListTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); fileListTable.setColumnSelectionAllowed(true); fileListTable.getTableHeader().addMouseListener(new TableHeaderMouseListener()); fileListTable.getTableHeader().getColumnModel().getColumn(0) .setHeaderRenderer(new TableHeaderCheckBoxColumnRenderer()); fileListPopupMenu = new FileListPopupMenu(fileListTable, tableModel, componentRepository, config); fileListTable.setComponentPopupMenu(fileListPopupMenu); fileListTable.addMouseListener(new FileViewOpener(fileListTable, componentRepository.getRootWindow(), config, componentRepository)); fileListTable.getColumnModel().getColumn(0).setPreferredWidth(20); fileListTable.getColumnModel().getColumn(0).setMaxWidth(20); fileListTable.getColumnModel().getColumn(1).setCellRenderer(new TargetFileListTableCellRenderer()); fileListTable.getColumnModel().getColumn(1).setPreferredWidth(2 * totalWidth / 5); fileListTable.getColumnModel().getColumn(2).setCellRenderer(new PathColumnRenderer()); fileListTable.getColumnModel().getColumn(3).setCellRenderer(new InfoColumnRenderer(config)); JScrollPane scrollPane = new JScrollPane(fileListTable); this.add(scrollPane, BorderLayout.CENTER); SelectCounter fileCounter = new SelectCounter(); fileCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); fileCounter.setForeground(Color.GRAY); ErrorCounter errorCounter = new ErrorCounter(); errorCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); JPanel counterLine = new JPanel(); counterLine.setLayout(new BorderLayout()); counterLine.add(fileCounter, BorderLayout.WEST); counterLine.add(errorCounter, BorderLayout.EAST); JProgressBar progressBar = new JProgressBar(); progressBar.setEnabled(false);/* w w w .ja va 2 s . co m*/ progressBar.setMaximumSize(new Dimension(100, 20)); progressBar.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); componentRepository.getProgressBarUpdater().setProgressBar(progressBar); JPanel progressBarPanel = new JPanel(); progressBarPanel.add(progressBar); counterLine.add(progressBarPanel, BorderLayout.CENTER); counterLine.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); this.add(counterLine, BorderLayout.SOUTH); tableModel.addTableModelListener(new ColumnCountListener(fileCounter)); tableModel.addTableModelListener(errorCounter); componentRepository.getResetDispatcher().addResetable(fileCounter); componentRepository.getSearchBaseListener().addResetable(fileCounter); componentRepository.getOperationCallBackListener().addComponentStartReseted(fileCounter, OperationType.FIND); componentRepository.getResetDispatcher().addResetable(errorCounter); componentRepository.getSearchBaseListener().addResetable(errorCounter); viewAction = new ActionView(componentRepository, config); }
From source file:jmemorize.gui.swing.panels.CardCounterPanel.java
private void initComponents(int target) { removeAll();/*from w w w .j a va2 s . c o m*/ setLayout(new BorderLayout()); // if there is a card limit show a progess bar or pie chart if (m_cardsTarget > -1) { if (USE_PIECHART) { m_pieDataset = new DefaultPieDataset(); m_pieDataset.setValue(Localization.get(LC.STATUS_LEARNED), 0); m_pieDataset.setValue(Localization.get(LC.STATUS_PARTIAL), 0); m_pieDataset.setValue(Localization.get(LC.STATUS_UNLEARNED), m_cardsTarget); add(buildPiePanel(), BorderLayout.CENTER); } else { if (USE_EXTENT_BAR) m_bar = buildExtentProgressBar(); else if (USE_PARTIAL_BAR) m_bar = buildPartialProgressBar(); else m_bar = new JProgressBar(); m_bar.setMaximum(target); m_bar.setMinimum(0); m_bar.setStringPainted(true); m_bar.setString(getCardString()); m_bar.setValue(0); add(m_bar, BorderLayout.CENTER); } } // otherwise show a textfield else { m_textField.setText(getCardString()); m_textField.setHorizontalAlignment(JTextField.CENTER); m_textField.setEditable(false); add(m_textField, BorderLayout.CENTER); } setPreferredSize(new Dimension(140, USE_PIECHART ? 140 : 22)); }
From source file:edu.harvard.mcz.imagecapture.BulkMediaFrame.java
private void init() { thisFrame = this; setTitle("BulkMedia Preparation"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 902, 174);/*w ww.j a va 2 s . c o m*/ JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic(KeyEvent.VK_F); menuBar.add(mnFile); JMenuItem mntmPrepareDirectory = new JMenuItem("Prepare Directory"); mntmPrepareDirectory.setMnemonic(KeyEvent.VK_D); mntmPrepareDirectory.addActionListener(new PrepareDirectoryAction()); mnFile.add(mntmPrepareDirectory); JMenuItem mntmNewMenuItem = new JMenuItem("Exit"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); JMenuItem mntmNewMenuItem_1 = new JMenuItem("Edit Properties"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PropertiesEditor p = new PropertiesEditor(); p.pack(); p.setVisible(true); } }); mnFile.add(mntmNewMenuItem_1); mntmNewMenuItem.setMnemonic(KeyEvent.VK_X); mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); mnFile.add(mntmNewMenuItem); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(3, 2, 0, 0)); JLabel lblBaseUri = new JLabel("Base URI (first part of path to images on the web)"); lblBaseUri.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblBaseUri, "2, 2"); textField = new JTextField(); textField.setEditable(false); textField.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASEURI)); panel.add(textField); textField.setColumns(10); JLabel lblNewLabel = new JLabel("Local Path To Base (local mount path that maps to base URI)"); lblNewLabel.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblNewLabel); textField_1 = new JTextField(); textField_1.setEditable(false); textField_1.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASE)); panel.add(textField_1); textField_1.setColumns(10); JLabel lblBeforeExitingWait = new JLabel( "Before exiting wait for both the Done and Thumbnails Built messages."); panel.add(lblBeforeExitingWait); JLabel lblThumbnailGenerationIs = new JLabel("Thumbnail generation is not reported on the progress bar."); panel.add(lblThumbnailGenerationIs); progressBar = new JProgressBar(); progressBar.setStringPainted(false); contentPane.add(progressBar, BorderLayout.NORTH); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.SOUTH); JButton btnPrepareDirectory = new JButton("Run"); btnPrepareDirectory.setToolTipText("Select a directory and prepare a bulk media file for images therein."); panel_1.add(btnPrepareDirectory); btnPrepareDirectory.addActionListener(new PrepareDirectoryAction()); btnPrepareDirectory.setPreferredSize(new Dimension(80, 25)); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); panel_1.add(btnExit); }
From source file:net.mitnet.tools.pdf.book.publisher.ui.gui.BookPublisherGUI2.java
/** * Initialise widgets./*from w ww . ja va2 s . co m*/ */ protected void initComponents() { // frame this.frame = new JFrame(); this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.frame.setTitle(FRAME_TITLE); // input dir panel inputDirLabel = new JLabel(); inputDirLabel.setText("Input Folder:"); inputDirField = new JTextField(); inputDirField.setColumns(FILE_TEXTFIELD_WIDTH); inputDirButton = new JButton(); inputDirButton.setText("Browse ..."); inputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { inputDirButtonActionHandler(event); } }); JPanel inputDirPanel = new JPanel(); // inputDirPanel.setLayout( new BoxLayout( inputDirPanel, BoxLayout.X_AXIS ) ); inputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); inputDirPanel.add(inputDirLabel); inputDirPanel.add(inputDirField); inputDirPanel.add(inputDirButton); // output dir panel outputDirLabel = new JLabel(); outputDirLabel.setText("Output Folder:"); outputDirField = new JTextField(); outputDirField.setColumns(FILE_TEXTFIELD_WIDTH); outputDirButton = new JButton(); outputDirButton.setText("Browse ..."); outputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { outputDirButtonActionHandler(event); } }); JPanel outputDirPanel = new JPanel(); // outputDirPanel.setLayout( new BoxLayout( outputDirPanel, BoxLayout.X_AXIS ) ); outputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); outputDirPanel.add(outputDirLabel); outputDirPanel.add(outputDirField); outputDirPanel.add(outputDirButton); // document control panel docControlPanel = new JPanel(); docControlPanel.setLayout(new BoxLayout(docControlPanel, BoxLayout.Y_AXIS)); docControlPanel.add(inputDirPanel); docControlPanel.add(outputDirPanel); // Border docControlPanelBorder = BorderFactory.createTitledBorder("Documents"); Border docControlPanelBorder = BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Documents"), BorderFactory.createEmptyBorder(5, 5, 5, 5)); docControlPanel.setBorder(docControlPanelBorder); // publish button publishButton = new JButton(); publishButton.setText("Publish"); publishButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { publishButtonActionHandler(event); } }); // status message label statusMessageLabel = new JLabel(); // String statusMessageText = "Press " + publishButton.getText() + " to start."; String statusMessageText = ""; statusMessageLabel.setText(statusMessageText); // statusMessageLabel.setVisible(false); // progress bar progressBar = new JProgressBar(); // exit button exitButton = new JButton(); exitButton.setText("Exit"); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { exitButtonActionHandler(event); } }); // build main panel JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(docControlPanel); // mainPanel.add(new Spacer()); mainPanel.add(publishButton); // mainPanel.add(new Spacer()); mainPanel.add(progressBar); // mainPanel.add(new Spacer()); mainPanel.add(statusMessageLabel); // mainPanel.add(new Spacer()); mainPanel.add(exitButton); // add main panel to frame this.frame.getContentPane().setLayout(new BoxLayout(this.frame.getContentPane(), BoxLayout.Y_AXIS)); this.frame.getContentPane().add(mainPanel); // this.frame.setSize(800,600); this.frame.pack(); }
From source file:org.pmedv.core.app.SplashScreen.java
/** * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *//*from w w w . ja v a2 s . c o m*/ public void afterPropertiesSet() throws Exception { if (context.containsBean("lookAndFeelConfigurer")) { context.getBean("lookAndFeelConfigurer"); progressBar = new JProgressBar(); } Assert.state(StringUtils.hasText(imageResourcePath), "The splash screen image resource path is required"); if (showProgressLabel) { progressBar.setStringPainted(true); progressBar.setString("Loading context"); } progressBar.setMinimum(0); progressBar.setMaximum(context.getBeanDefinitionCount() - NUM_OF_NON_SINGLETON_BEANS); splash(); }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
public JProgressBar getToleranceBar() { if (toleranceBar == null) { toleranceBar = new JProgressBar(); toleranceBar.setPreferredSize(new Dimension(200, 25)); toleranceBar.setValue(10);// w w w . j av a 2s. c om toleranceBar.setMaximum(100); toleranceBar.setStringPainted(true); toleranceBar.addMouseListener(new MouseAdapter() { public boolean mouseEntered = false; @Override public void mouseReleased(MouseEvent e) { if (mouseEntered) { JProgressBar pb = (JProgressBar) e.getComponent(); pb.setValue((int) ((((double) e.getX()) / pb.getSize().getWidth()) * 100d)); pb.updateUI(); } } @Override public void mouseEntered(MouseEvent e) { this.mouseEntered = true; } @Override public void mouseExited(MouseEvent e) { this.mouseEntered = false; } }); } return toleranceBar; }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
JFrame showProgress(String message) { JFrame f = new JFrame("Info"); f = new JFrame("Info"); f.setUndecorated(true);// ww w .j av a 2 s .c om JPanel p = new JPanel(); Border margin = new EmptyBorder(30, 20, 20, 20); p.setBorder(new TitledBorder( new TitledBorder(margin, "", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)), message, TitledBorder.LEADING, TitledBorder.TOP, null, null)); p.setLayout(new BorderLayout(30, 30)); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); p.add(progressBar, BorderLayout.CENTER); f.getContentPane().add(p); f.setSize(360, 80); f.setLocationRelativeTo(null); f.setVisible(true); return f; }
From source file:com.fratello.longevity.smooth.AppGUI.java
private void initialize() { LabelMaxSize = 0;/* w ww. java 2 s .c om*/ ActiveGUI = true; GUI_Start = false; GUI_Pause = true; GUI_Stop = false; ran_at_least_once = false; execute(); initializeFields(); frmFileSystemSearch = new JFrame(); frmFileSystemSearch.setTitle("Smooth Longevity Fratello"); frmFileSystemSearch.setBounds(100, 100, 450, 300); frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmFileSystemSearch.setResizable(false); UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1)); JMenuBar menuBar = new JMenuBar(); frmFileSystemSearch.setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("File"); menuBar.add(mnNewMenu); JMenuItem mntmFirst = new JMenuItem("Open Directory"); mntmFirst.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(mntmFirst); } }); mnNewMenu.add(mntmFirst); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { frmFileSystemSearch.dispose(); } }); mnNewMenu.add(mntmExit); JMenu mnHelp = new JMenu("Help"); menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem("About"); mnHelp.add(mntmAbout); JMenuItem mntmTutorials = new JMenuItem("Tutorials"); mnHelp.add(mntmTutorials); JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates"); mnHelp.add(mntmCheckForUpdates); String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business=" + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name=" + "Personal%20funds%20for%20programming%20at%20university" + "¤cy_code=" + "USD" + "&bn=" + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted"; JButton btnDonate = new JButton("Donate"); btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>"); btnDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); btnDonate.setBounds(159, 176, 90, 25); menuBar.add(btnDonate); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER); // ---------------------------- JPanels ------------------------------ JPanel panel = new JPanel(); tabbedPane.addTab("Start Directory", null, panel, null); JPanel panel_1 = new JPanel(); tabbedPane.addTab("Search Setup", null, panel_1, null); panel_1.setLayout(null); JPanel panel_2 = new JPanel(); tabbedPane.addTab("Run Program", null, panel_2, null); panel_2.setLayout(null); JPanel panel_3 = new JPanel(); tabbedPane.addTab("Information", null, panel_3, null); panel_3.setBounds(10, 11, 409, 154); GridBagLayout gbl_panel_3 = new GridBagLayout(); gbl_panel_3.columnWidths = new int[] { 0, 0, 0 }; gbl_panel_3.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 }; gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel_3.setLayout(gbl_panel_3); // ------------- Dynamic Update - Swingworker Components ------------- SentinelProgressBar = new JProgressBar(); SentinelProgressBar.setMaximumSize(new Dimension(146, 14)); SentinelProgressBar.setMaximum(1000); SentinelProgressBar.setBounds(74, 187, 146, 14); panel_2.add(SentinelProgressBar); SentinelProgressLabel = new JLabel(); SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress"); SentinelProgressLabel.setBounds(333, 181, 86, 20); panel_2.add(SentinelProgressLabel); // ------------------------------------------------------------------- // ------------------------ JPanel Components ------------------------ JLabel lblCurrentDirectory = new JLabel("Current Directory"); panel.add(lblCurrentDirectory); userSelectedDirectories = new JTextField(); panel.add(userSelectedDirectories); userSelectedDirectories.setColumns(35); JButton btnBrowse = new JButton("Browse"); btnBrowse.setToolTipText("Locate directory in system"); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(btnBrowse); } }); panel.add(btnBrowse); JButton btnClear = new JButton("Clear"); btnClear.setToolTipText("Deletes the current directory shown"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { userSelectedDirectories.setText(""); clearSourceDirectory(); } }); panel.add(btnClear); // ------------------------------------------------------------------- // ----------------------- JPanel_1 Components ----------------------- // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Extension :: [Check Box] chckbxExt = new JCheckBox("Extension"); chckbxExt.setToolTipText("Check to ignore file extensions"); chckbxExt.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Ext", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Ext", false); } }); chckbxExt.setBounds(8, 15, 97, 23); panel_1.add(chckbxExt); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Hash :: [Check Box] chckbxHash = new JCheckBox("Hash"); chckbxHash.setToolTipText("Check to compare by hashing files (FAST)"); chckbxHash.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Hash", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Hash", false); } }); chckbxHash.setBounds(8, 45, 97, 23); panel_1.add(chckbxHash); // Hash :: [Combo Box] comboBoxHash = new JComboBox<String>(); comboBoxHash.setToolTipText( "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>"); comboBoxHash.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setHashString(UIselect); } }); comboBoxHash .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" })); comboBoxHash.setBounds(150, 44, 75, 25); panel_1.add(comboBoxHash); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Name :: [Check Box] chckbxName = new JCheckBox("Name"); chckbxName.setToolTipText("Name tool-tip goes here"); chckbxName.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Name", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Name", false); } }); chckbxName.setBounds(8, 75, 97, 23); panel_1.add(chckbxName); // Name :: [Text Field] namePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]"); namePercentMatchTextField.setBounds(150, 74, 110, 25); panel_1.add(namePercentMatchTextField); namePercentMatchTextField.setColumns(10); // Name :: [Combo Box] comboBoxNames = new JComboBox<String>(); comboBoxNames.setToolTipText("Algorithm to compare names"); comboBoxNames.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMatchingAlgorithm(UIselect); } }); comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine", "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming", "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman", "SorensenSimilarityIndex", "WagnerFischer" })); comboBoxNames.setBounds(265, 74, 150, 25); panel_1.add(comboBoxNames); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Size :: [Check Box] chckbxSize = new JCheckBox("Size"); chckbxSize.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Size", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Size", false); } }); chckbxSize.setBounds(8, 105, 97, 23); panel_1.add(chckbxSize); // Size :: [Text Field] sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); sizePercentMatchTextField.setBounds(150, 104, 110, 25); panel_1.add(sizePercentMatchTextField); sizePercentMatchTextField.setColumns(10); // Size :: [Combo Box] comboBoxSize = new JComboBox<String>(); comboBoxSize.setToolTipText("Specify byte grouping"); comboBoxSize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMetricSize(UIselect); } }); comboBoxSize.setModel( new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" })); comboBoxSize.setBounds(265, 104, 150, 25); panel_1.add(comboBoxSize); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Thorough :: [Check Box] chckbxThorough = new JCheckBox("Thorough"); chckbxThorough.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Thorough", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Thorough", false); } }); chckbxThorough.setToolTipText("Check byte by byte"); chckbxThorough.setBounds(8, 135, 97, 23); panel_1.add(chckbxThorough); // Thorough :: [Text Field] thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d)); thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); thoroughPercentMatchTextField.setBounds(150, 134, 110, 25); panel_1.add(thoroughPercentMatchTextField); thoroughPercentMatchTextField.setColumns(10); // Thorough :: [Check Box] chckbxExitFast = new JCheckBox("Exit Fast"); chckbxExitFast.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setThoroughExitFirstByteMisMatch(true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setThoroughExitFirstByteMisMatch(false); } }); chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>"); chckbxExitFast.setBounds(265, 138, 105, 16); panel_1.add(chckbxExitFast); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ JButton btnSaveSearchSettings = new JButton("Save Search Settings"); btnSaveSearchSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { pollSearchSettings(); cf.saveObject(); // System.out.println(cf.toString()); // debug } }); btnSaveSearchSettings.setBounds(292, 181, 140, 25); panel_1.add(btnSaveSearchSettings); JButton btnLoadSettings = new JButton("Load Settings"); btnLoadSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!cf.loadObject()) cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnLoadSettings.setBounds(148, 181, 140, 25); panel_1.add(btnLoadSettings); JButton btnDefaultSettings = new JButton("Use Default Settings"); btnDefaultSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnDefaultSettings.setBounds(4, 181, 140, 25); panel_1.add(btnDefaultSettings); // ------------------------------------------------------------------- // ----------------------- JPanel_2 Components ----------------------- JLabel labelStatus = new JLabel("Progress"); labelStatus.setBounds(10, 187, 54, 14); panel_2.add(labelStatus); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pollSearchSettings(); if (!ran_at_least_once) ran_at_least_once = true; else { SentinelProgressBar.setValue(0); SentinelProgressLabel.setText("Waiting..."); } try { if (multiSelection == null) { JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.", "Press OK to continue", JOptionPane.PLAIN_MESSAGE); return; } setSourceDirectory(multiSelection); GUI_Start = true; } catch (Exception err) { err.printStackTrace(); } } }); btnStart.setBounds(40, 153, 89, 23); panel_2.add(btnStart); JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Stop = true; } }); btnStop.setBounds(169, 153, 89, 23); panel_2.add(btnStop); JButton btnNewButton = new JButton("Pause"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Pause = true; } }); btnNewButton.setBounds(298, 153, 89, 23); panel_2.add(btnNewButton); JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files"); chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { deleteCopyResults = true; } }); chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16); panel_2.add(chckbxDeleteDuplicateFiles); JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file"); chckbxLogDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { saveCopyResults = true; } }); chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16); panel_2.add(chckbxLogDuplicateFiles); // ------------------------------------------------------------------- // ----------------------- JPanel_3 Components ----------------------- JLabel lblAbout = new JLabel("About"); GridBagConstraints gbc_lblAbout = new GridBagConstraints(); gbc_lblAbout.insets = new Insets(0, 0, 5, 5); gbc_lblAbout.gridx = 0; gbc_lblAbout.gridy = 0; panel_3.add(lblAbout, gbc_lblAbout); JLabel lblTutorials = new JLabel("Tutorials"); GridBagConstraints gbc_lblTutorials = new GridBagConstraints(); gbc_lblTutorials.insets = new Insets(0, 0, 5, 5); gbc_lblTutorials.gridx = 1; gbc_lblTutorials.gridy = 0; panel_3.add(lblTutorials, gbc_lblTutorials); JLabel lblUpdates = new JLabel("Updates"); GridBagConstraints gbc_lblUpdates = new GridBagConstraints(); gbc_lblUpdates.insets = new Insets(0, 0, 5, 0); gbc_lblUpdates.gridx = 2; gbc_lblUpdates.gridy = 0; panel_3.add(lblUpdates, gbc_lblUpdates); JButton btnInformation = new JButton("Information"); btnInformation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnInformation = new GridBagConstraints(); gbc_btnInformation.insets = new Insets(0, 0, 0, 5); gbc_btnInformation.gridx = 0; gbc_btnInformation.gridy = 1; panel_3.add(btnInformation, gbc_btnInformation); JButton btnExamples = new JButton("Examples"); btnExamples.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnExamples = new GridBagConstraints(); gbc_btnExamples.insets = new Insets(0, 0, 0, 5); gbc_btnExamples.gridx = 1; gbc_btnExamples.gridy = 1; panel_3.add(btnExamples, gbc_btnExamples); JButton btnCheckNow = new JButton("Check Now"); btnCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnCheckNow = new GridBagConstraints(); gbc_btnCheckNow.gridx = 2; gbc_btnCheckNow.gridy = 1; panel_3.add(btnCheckNow, gbc_btnCheckNow); }
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 ww w. j ava 2 s. c om 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:marytts.tools.voiceimport.DatabaseImportMain.java
/** * Run the selected components in a different thread. * *///from w ww .j a v a 2 s .c o m protected void runSelectedComponents() { new Thread("RunSelectedComponentsThread") { public void run() { try { runButton.setEnabled(false); for (int i = 0; i < components.length; i++) { if (checkboxes[i].isSelected()) { boolean success = false; Container parent = checkboxes[i].getParent(); final JProgressBar progress = new JProgressBar(); final VoiceImportComponent oneComponent = components[i]; if (oneComponent.getProgress() != -1) { progress.setStringPainted(true); new Thread("ProgressThread") { public void run() { int percent = 0; while (progress.isVisible()) { progress.setValue(percent); try { Thread.sleep(500); } catch (InterruptedException ie) { } percent = oneComponent.getProgress(); } } }.start(); } else { progress.setIndeterminate(true); } parent.add(progress, BorderLayout.EAST); progress.setVisible(true); parent.validate(); try { success = oneComponent.compute(); } catch (Exception exc) { checkboxes[i].setBackground(Color.RED); throw new Exception("The component " + checkboxes[i].getText() + " produced the following exception: ", exc); } finally { checkboxes[i].setSelected(false); progress.setVisible(false); } if (success) { checkboxes[i].setBackground(Color.GREEN); } else { checkboxes[i].setBackground(Color.RED); } } } } catch (Throwable e) { e.printStackTrace(); } finally { runButton.setEnabled(true); } } }.start(); }