List of usage examples for java.awt FlowLayout CENTER
int CENTER
To view the source code for java.awt FlowLayout CENTER.
Click Source Link
From source file:GCWrapper.java
/** * Creates and lays out components in the container. See the comments below * for an organizational overview by panel. *//*from ww w. j a v a2s. c om*/ private void initComponents(Container c) { // +=c=====================================================+ // ++=gcPanel==============================================+ // ++ [gcSelection] + // ++=capsPanel============================================+ // +++=imageCapsPanel======================================+ // +++ [imageAccelerated] + // +++ [imageTrueVolatile] + // +++=bufferCapsPanel=====================================+ // ++++=bufferAccessCapsPanel==============================+ // +++++=flippingPanel=====================================+ // +++++ [flipping] + // +++++=fsPanel===========================================+ // +++++ [indentPanel][fullScreen] + // +++++=mbPanel===========================================+ // +++++ [indentPanel][multiBuffer] + // ++++=buffersPanel=======================================+ // +++++=fbPanel===============+=bbPanel===================+ // +++++ + + // +++++ [fbAccelerated] + [bbAccelerated] + // +++++ + + // +++++ [fbTrueVolatile] + [bbTrueVolatile] + // +++++ + + // +=======================================================+ c.setLayout(new BorderLayout()); // Graphics Config JPanel gcPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(gcPanel, BorderLayout.NORTH); gcSelection.setPreferredSize(new Dimension(400, 30)); gcPanel.add(gcSelection); // Capabilities JPanel capsPanel = new JPanel(new BorderLayout()); c.add(capsPanel, BorderLayout.CENTER); // Image Capabilities JPanel imageCapsPanel = new JPanel(new GridLayout(2, 1)); capsPanel.add(imageCapsPanel, BorderLayout.NORTH); imageCapsPanel.setBorder(BorderFactory.createTitledBorder("Image Capabilities")); imageAccelerated.setEnabled(false); imageCapsPanel.add(imageAccelerated); imageTrueVolatile.setEnabled(false); imageCapsPanel.add(imageTrueVolatile); // Buffer Capabilities JPanel bufferCapsPanel = new JPanel(new BorderLayout()); capsPanel.add(bufferCapsPanel, BorderLayout.CENTER); bufferCapsPanel.setBorder(BorderFactory.createTitledBorder("Buffer Capabilities")); // Buffer Access JPanel bufferAccessCapsPanel = new JPanel(new GridLayout(3, 1)); bufferAccessCapsPanel.setPreferredSize(new Dimension(300, 88)); bufferCapsPanel.add(bufferAccessCapsPanel, BorderLayout.NORTH); // Flipping JPanel flippingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(flippingPanel); flippingPanel.add(flipping); flipping.setEnabled(false); flippingPanel.add(flippingMethod); // Full-screen JPanel fsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(fsPanel); JPanel indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); fsPanel.add(indentPanel); fsPanel.add(fullScreen); fullScreen.setEnabled(false); // Multi-buffering JPanel mbPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(mbPanel); indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); mbPanel.add(indentPanel); mbPanel.add(multiBuffer); multiBuffer.setEnabled(false); // Front and Back Buffer Capabilities JPanel buffersPanel = new JPanel(new GridLayout(1, 2)); bufferCapsPanel.add(buffersPanel, BorderLayout.CENTER); // Front Buffer JPanel fbPanel = new JPanel(new GridLayout(2, 1)); fbPanel.setBorder(BorderFactory.createTitledBorder("Front Buffer")); buffersPanel.add(fbPanel); fbPanel.add(fbAccelerated); fbAccelerated.setEnabled(false); fbPanel.add(fbTrueVolatile); fbTrueVolatile.setEnabled(false); // Back Buffer JPanel bbPanel = new JPanel(new GridLayout(2, 1)); bbPanel.setPreferredSize(new Dimension(250, 80)); bbPanel.setBorder(BorderFactory.createTitledBorder("Back and Intermediate Buffers")); buffersPanel.add(bbPanel); bbPanel.add(bbAccelerated); bbAccelerated.setEnabled(false); bbPanel.add(bbTrueVolatile); bbTrueVolatile.setEnabled(false); }
From source file:com.smart.aqimonitor.client.AqiMonitor.java
/** * Create the frame./*from ww w .j a v a 2 s . c o m*/ */ public AqiMonitor() { refSelf = this; setPreferredSize(new Dimension(640, 480)); setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B"); setIconImage(Toolkit.getDefaultToolkit() .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png"))); setMinimumSize(new Dimension(640, 480)); setMaximumSize(new Dimension(1024, 768)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 636, 412); contentPane = new JPanel(); contentPane.setPreferredSize(new Dimension(640, 480)); contentPane.setMinimumSize(new Dimension(640, 480)); contentPane.setMaximumSize(new Dimension(1024, 768)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel mainPanel = new JPanel(); contentPane.add(mainPanel, BorderLayout.CENTER); mainPanel.setLayout(new BorderLayout(0, 0)); JPanel contentPanel = new JPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); scrollPane .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(scrollPane, BorderLayout.CENTER); textPane = new AqiTextPane(); textPane.addInputMethodListener(new InputMethodListener() { public void caretPositionChanged(InputMethodEvent event) { } public void inputMethodTextChanged(InputMethodEvent event) { textPane.setCaretPosition(document.getLength() + 1); } }); textPane.setEditable(false); textPane.setOpaque(false); textPane.setForeground(Color.BLACK); scrollPane.setViewportView(textPane); document = textPane.getStyledDocument(); document.addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { if (e.getDocument() == document) { textPane.setCaretPosition(document.getLength()); } } }); JPanel buttonPanel = new JPanel(); contentPane.add(buttonPanel, BorderLayout.SOUTH); buttonPanel.setLayout(new BorderLayout(0, 0)); JLabel lblTipsLabel = new JLabel( "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00"); lblTipsLabel.setForeground(Color.BLUE); buttonPanel.add(lblTipsLabel, BorderLayout.WEST); JPanel panel = new JPanel(); buttonPanel.add(panel, BorderLayout.CENTER); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E"); panel.add(btnRetrieve); btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM); JButton btnNewButton = new JButton("\u5173\u4E8E"); btnNewButton.setToolTipText("\u5173\u4E8E"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextArea textArea = new JTextArea( "\n csv\n\n smartstudio@foxmail.com"); textArea.setColumns(35); textArea.setRows(6); textArea.setLineWrap(true);// textArea.setEditable(false);// textArea.setOpaque(false); JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE); } }); JButton btnSetting = new JButton("\u8BBE\u7F6E"); btnSetting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Point parentPos = refSelf.getLocation(); AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser()); settingDialog.setModal(true); settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150); settingDialog.init(); settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); settingDialog.setVisible(true); } }); JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E"); btnExportDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { String[] cmd = new String[5]; String filePath = pm25InDetailJob.getAqiParser().getFilePath(); File file = new File(filePath); if (!file.exists()) { FileUtil.makeDir(file); } if (!file.isDirectory()) { JOptionPane.showMessageDialog(contentPane, "", "", JOptionPane.ERROR_MESSAGE); return; } cmd[0] = "cmd"; cmd[1] = "/c"; cmd[2] = "start"; cmd[3] = " "; cmd[4] = pm25InDetailJob.getAqiParser().getFilePath(); Runtime.getRuntime().exec(cmd); } catch (IOException ex) { ex.printStackTrace(); } } }); panel.add(btnExportDir); panel.add(btnSetting); panel.add(btnNewButton); btnRetrieve.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!isRetrieving) { isRetrieving = true; Thread firstRun = new Thread(new Runnable() { @Override public void run() { pm25InDetailJob.refresh(); isRetrieving = false; } }); firstRun.start(); } } }); init(); }
From source file:org.webcat.plugintester.ui.MainFrameBuilder.java
/** * Creates and lays out the Swing components for the window. * * @param frame the JFrame instance that will contain the components *///from w ww .j a va 2s. c om private void constructFrame(JFrame frame) { GridBagConstraints gridBagConstraints; fileChooser = new JFileChooser(); bottomPanel = new JPanel(); runButton = new JButton(); mainPanel = new JPanel(); JLabel webCatHomeLabel = new JLabel(); webCatHomeField = new JTextField(); webCatHomeBrowseButton = new JButton(); JSeparator jSeparator0 = new JSeparator(); JLabel submissionLabel = new JLabel(); submissionField = new JTextField(); submissionBrowseButton = new JButton(); JSeparator jSeparator1 = new JSeparator(); JLabel pluginsLabel = new JLabel(); JPanel pluginsPanel = new JPanel(); JScrollPane pluginsScrollPane = new JScrollPane(); pluginsTable = new JTable(); pluginAddButton = new JButton(); pluginRemoveButton = new JButton(); JSeparator jSeparator2 = new JSeparator(); JTabbedPane tabPane = new JTabbedPane(); propertiesPanel = new JPanel(); JScrollPane propertiesScrollPane = new JScrollPane(); propertiesEditor = new JEditorPane(); documentationPanel = new JPanel(); JScrollPane documentationScrollPane = new JScrollPane(); documentationEditor = new JEditorPane(); // File chooser fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // Bottom panel bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4)); // Run button runButton.setText("Run Plug-ins"); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { runButtonActionPerformed(evt); } }); bottomPanel.add(runButton); frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END); // Main panel mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); mainPanel.setLayout(new GridBagLayout()); // Web-CAT Home field gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = GridBagConstraints.LINE_START; webCatHomeLabel.setText("Web-CAT Home:"); mainPanel.add(webCatHomeLabel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; webCatHomeField.setTransferHandler(new WebCATHomeTransferHandler()); mainPanel.add(webCatHomeField, gridBagConstraints); // Web-CAT Home browse button webCatHomeBrowseButton.setText("Browse..."); webCatHomeBrowseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { webCatHomeBrowseButtonActionPerformed(evt); } }); mainPanel.add(webCatHomeBrowseButton, new GridBagConstraints()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator0, gridBagConstraints); // Submission field gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = GridBagConstraints.LINE_START; submissionLabel.setText("Submission:"); mainPanel.add(submissionLabel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; submissionField.setTransferHandler(new SubmissionTransferHandler()); mainPanel.add(submissionField, gridBagConstraints); // Submission browse button submissionBrowseButton.setText("Browse..."); submissionBrowseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { submissionBrowseButtonActionPerformed(evt); } }); mainPanel.add(submissionBrowseButton, new GridBagConstraints()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator1, gridBagConstraints); // Plug-ins area pluginsLabel.setText("Plug-ins to run:"); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(pluginsLabel, gridBagConstraints); pluginsPanel.setPreferredSize(new Dimension(400, 80)); pluginsPanel.setLayout(new GridBagLayout()); pluginsModel = new PluginsTableModel(); pluginsTable.setModel(pluginsModel); pluginsTable.setColumnSelectionAllowed(true); pluginsTable.getTableHeader().setReorderingAllowed(false); pluginsScrollPane.setViewportView(pluginsTable); pluginsTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); pluginsTable.getColumnModel().getColumn(0).setResizable(false); pluginsScrollPane.setTransferHandler(new PluginsTransferHandler()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pluginsPanel.add(pluginsScrollPane, gridBagConstraints); pluginAddButton.setText("Add..."); pluginAddButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pluginAddButtonActionPerformed(evt); } }); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.PAGE_START; pluginsPanel.add(pluginAddButton, gridBagConstraints); pluginRemoveButton.setText("Remove"); pluginRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pluginRemoveButtonActionPerformed(evt); } }); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.PAGE_START; pluginsPanel.add(pluginRemoveButton, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.25; mainPanel.add(pluginsPanel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator2, gridBagConstraints); tabPane.setPreferredSize(new Dimension(466, 150)); propertiesPanel.setLayout(new GridBagLayout()); propertiesEditor.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { propertiesTimer.restart(); } }); propertiesTimer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { updateGradingProperties(); } }); propertiesScrollPane.setViewportView(propertiesEditor); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; propertiesPanel.add(propertiesScrollPane, gridBagConstraints); tabPane.addTab("Properties", propertiesPanel); documentationPanel.setLayout(new GridBagLayout()); documentationEditor.setContentType("text/html"); documentationEditor.setEditable(false); documentationScrollPane.setViewportView(documentationEditor); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; documentationPanel.add(documentationScrollPane, gridBagConstraints); tabPane.addTab("Documentation", documentationPanel); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.gridheight = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weighty = 1.0; mainPanel.add(tabPane, gridBagConstraints); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack(); }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);/* w w w .j a va 2 s .co m*/ message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:org.onesun.sdi.swing.app.views.DataServicesView.java
private void createControls() { copyDataButton.addActionListener(new ActionListener() { @Override//from ww w. ja v a2 s .c o m public void actionPerformed(ActionEvent e) { datasetModel = new DatasetModel(); final Metadata origMetadata = AppCommonsUI.PREVIEW_DATASET_MODEL.getMetadata(); Metadata metadata = new Metadata(); // copy metadata for (String key : origMetadata.keySet()) { metadata.put(key, origMetadata.get(key)); } final List<Map<String, String>> origData = AppCommonsUI.PREVIEW_DATASET_MODEL.getData(); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); // copy data for (Map<String, String> datum : origData) { Map<String, String> record = new TreeMap<String, String>(); for (String key : datum.keySet()) { record.put(key, datum.get(key)); } data.add(record); } datasetModel.setMetadata(metadata); datasetModel.setData(data); dataTable.setModel(datasetModel); rowCountLabel.setText( "Rows: " + datasetModel.getRowCount() + ", Columns: " + datasetModel.getColumnCount()); JTableUtils.packColumns(dataTable, 2); rowCountLabel.invalidate(); dataTable.invalidate(); dataTable.validate(); scrollPane.invalidate(); } }); JPanel panel = new JPanel(new BorderLayout(5, 5)); panel.add(new JLabel("Enrichment Services"), BorderLayout.NORTH); dataServicesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); dataServicesList.setListData(DataServicesFactory.getServiceNames()); dataServicesList.setPreferredSize(new Dimension(400, 300)); JScrollPane listScrollPane = new JScrollPane(dataServicesList); panel.add(listScrollPane, BorderLayout.CENTER); containerPanel.add(panel); panel = new JPanel(new BorderLayout(5, 5)); JPanel labelAndControlPanel = new JPanel(new BorderLayout(5, 5)); labelAndControlPanel.add(new JLabel("Columns to be enriched"), BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); JButton selectButton = new JButton(AppIcons.getIcon("select")); controlPanel.add(selectButton); selectButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean columnsAvailable = false; if (datasetModel != null) { Metadata metadata = datasetModel.getMetadata(); if (metadata != null) { columnsAvailable = true; int size = metadata.keySet().size(); String[] values = new String[size]; int index = 0; for (String key : metadata.keySet()) { values[index] = key; index++; } metadataSelectionDialog.setValues(values); } } if (columnsAvailable == true) { metadataSelectionDialog.setVisible(true); } else { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_METADATA); return; } } }); JButton clearButton = new JButton(AppIcons.getIcon("clear")); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedColumnList.setListData(new String[] {}); selectedColumnList.invalidate(); } }); controlPanel.add(clearButton); labelAndControlPanel.add(controlPanel, BorderLayout.EAST); panel.add(labelAndControlPanel, BorderLayout.NORTH); selectedColumnList.setPreferredSize(new Dimension(400, 300)); listScrollPane = new JScrollPane(selectedColumnList); panel.add(listScrollPane, BorderLayout.CENTER); containerPanel.add(panel); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (AppCommons.TASKLET.getConnectionProperties() == null) { JOptionPane.showMessageDialog(rootPanel, AppMessages.INFORMATION_CHOOSE_A_CONNECTION); return; } if (AppCommonsUI.PREVIEW_DATASET_MODEL == null || AppCommonsUI.PREVIEW_DATASET_MODEL.getRowCount() <= 0) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_DATA_TO_ENTRICH); return; } List<String> selectedServiceNames = dataServicesList.getSelectedValuesList(); if ((selectedServiceNames != null && selectedServiceNames.size() == 0) || (selectedColumnNames.length == 0)) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_MISSING_DATA_SERVICE_AND_COLUMNS); return; } DefaultCusor.startWaitCursor(rootPanel); List<Map<String, String>> data = datasetModel.getData(); Metadata metadata = datasetModel.getMetadata(); for (String name : selectedServiceNames) { DataService service = DataServicesFactory.getDataService(name); if (service instanceof TextAnalysisService) { TextAnalysisService taService = (TextAnalysisService) service; List<Object> objects = new ArrayList<Object>(); for (Map<String, String> datum : data) { objects.add(datum); } taService.setData(objects); taService.setMetadata(metadata); taService.setColumns(selectedColumnNames); taService.execute(); } } rowCountLabel.setText("Rows: " + data.size() + ", Columns: " + metadata.size()); rowCountLabel.invalidate(); datasetModel = new DatasetModel(); datasetModel.setMetadata(metadata); datasetModel.setData(data); datasetModel.fireTableStructureChanged(); datasetModel.fireTableDataChanged(); dataTable.setModel(datasetModel); JTableUtils.packColumns(dataTable, 2); dataTable.invalidate(); dataTable.validate(); scrollPane.invalidate(); DefaultCusor.stopWaitCursor(rootPanel); } }); computeMetricsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (datasetModel == null || datasetModel.getRowCount() == 0) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_DATA); return; } List<Map<String, String>> data = datasetModel.getData(); int upsetCount = 0; int happyCount = 0; int negativeCount = 0; int positiveCount = 0; for (Map<String, String> datum : data) { for (String k : datum.keySet()) { if (k.compareTo("uclassify_sentiment") == 0) { String text = datum.get(k); String[] tokens = text.replace("{", "").replace("}", "").split(", "); for (String token : tokens) { String[] nvp = token.split("="); Double score = Double.parseDouble(nvp[1]); if (nvp[0].compareToIgnoreCase("negative") == 0 && score > 50.0) { negativeCount++; } if (nvp[0].compareToIgnoreCase("positive") == 0 && score >= 50.0) { positiveCount++; } } } else if (k.compareTo("uclassify_mood") == 0) { String text = datum.get(k); String[] tokens = text.replace("{", "").replace("}", "").split(", "); for (String token : tokens) { String[] nvp = token.split("="); Double score = Double.parseDouble(nvp[1]); if (nvp[0].compareToIgnoreCase("upset") == 0 && score > 50.0) { upsetCount++; } if (nvp[0].compareToIgnoreCase("happy") == 0 && score >= 50.0) { happyCount++; } } } } } DefaultPieDataset moodDataset = new DefaultPieDataset(); moodDataset.setValue("upset", upsetCount); moodDataset.setValue("happy", happyCount); DefaultPieDataset sentimentDataset = new DefaultPieDataset(); sentimentDataset.setValue("negative", negativeCount); sentimentDataset.setValue("positive", positiveCount); JFreeChart moodChart = ChartFactory.createPieChart("How is mood?", moodDataset, true, true, true); JFreeChart sentimentChart = ChartFactory.createPieChart("How is sentiment?", sentimentDataset, true, true, true); ChartDialog cd = new ChartDialog(AppCommonsUI.MAIN_WINDOW, moodChart, sentimentChart); cd.setSize(new Dimension(900, 500)); cd.setVisible(true); } }); }
From source file:com.rapidminer.template.gui.RoleRequirementSelector.java
public RoleRequirementSelector(final TemplateController controller) { super(new BorderLayout()); setBorder(border);//from w ww. ja v a 2 s .c om this.controller = controller; setBackground(Color.WHITE); updateRequirement(); controller.getModel().addObserver(new Observer() { @Override public void update(Observable o, Object arg) { if (TemplateState.OBSERVER_EVENT_TEMPLATE.equals(arg)) { updateRequirement(); updateComponents(); } else if (TemplateState.OBSERVER_EVENT_ROLES.equals(arg)) { assignSelectionToCombo(); updateComponents(); attributeCombo.repaint(); } else if (TemplateState.OBSERVER_EVENT_INPUT.equals(arg)) { updateAttributes(); } } }); AutoCompleteDecorator.decorate(attributeCombo); AutoCompleteDecorator.decorate(positiveClassCombo); attributeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (areValuesAdjusting) { return; } assignRoles(); } }); positiveClassCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (areValuesAdjusting) { return; } assignRoles(); } }); helpLabel.setHorizontalAlignment(SwingConstants.CENTER); add(helpLabel, BorderLayout.PAGE_START); chartPanel = new ChartPanel(null, 250, 250, 100, 100, 360, 360, true, false, false, false, false, false); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); attributeCombo.setPreferredSize(new Dimension(100, 30)); attributeCombo.setMaximumSize(new Dimension(150, 30)); add(chartPanel, BorderLayout.CENTER); JComponent comboPanel = new JPanel(); comboPanel.setLayout(new BoxLayout(comboPanel, BoxLayout.PAGE_AXIS)); JComponent comboPanelAtt = new JPanel(); comboPanelAtt.setBackground(Color.WHITE); comboPanelAtt.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); JComponent comboPanelClass = new JPanel(); comboPanelClass.setBackground(Color.WHITE); comboPanelClass.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); positiveClassCombo.setPreferredSize(new Dimension(100, 30)); positiveClassCombo.setMaximumSize(new Dimension(150, 30)); positiveClassLabel.setLabelFor(positiveClassCombo); positiveClassLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); positiveClassLabel.setToolTipText(positiveClassLabel.getText()); positiveClassLabel.setHorizontalAlignment(SwingConstants.RIGHT); columnLabel.setLabelFor(attributeCombo); columnLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); columnLabel.setToolTipText(columnLabel.getText()); columnLabel.setHorizontalAlignment(SwingConstants.RIGHT); comboPanelAtt.add(columnLabel); comboPanelAtt.add(attributeCombo); comboPanelClass.add(positiveClassLabel); comboPanelClass.add(positiveClassCombo); comboPanel.add(comboPanelAtt); comboPanel.add(comboPanelClass); add(comboPanel, BorderLayout.SOUTH); updateComponents(); }
From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java
private void createUI() { generalPanel = new GeneralPanel(this); startupShutdownPanel = new StartupShutdownPanel(this); windowsPanel = new WindowsPanel(this); soundsPanel = new SoundsPanel(this); sourcesPanel = new SourcesPanel(this); sourceListsPanel = new SourceListsPanel(this); sourceFilteringPanel = new SourceFilteringPanel(this); conditionsPanel = new ConditionsPanel(this); loggingLevelPanel = new LoggingLevelPanel(this); accessStatusTypePanel = new AccessStatusTypePanel(this); TroubleshootingPanel troubleshootingPanel = new TroubleshootingPanel(this); comboBoxModel = new DefaultComboBoxModel<>(); for (Panes current : Panes.values()) { comboBoxModel.addElement(current); }/*w w w . j a v a 2 s. c o m*/ comboBox = new JComboBox<>(comboBoxModel); comboBox.setRenderer(new MyComboBoxRenderer()); comboBox.setEditable(false); comboBox.addItemListener(new ComboItemListener()); cardLayout = new CardLayout(); content = new JPanel(cardLayout); content.setPreferredSize(new Dimension(600, 500)); content.add(generalPanel, Panes.General.toString()); content.add(startupShutdownPanel, Panes.StartupShutdown.toString()); content.add(windowsPanel, Panes.Windows.toString()); content.add(soundsPanel, Panes.Sounds.toString()); content.add(sourcesPanel, Panes.Sources.toString()); content.add(sourceListsPanel, Panes.SourceLists.toString()); content.add(sourceFilteringPanel, Panes.SourceFiltering.toString()); content.add(conditionsPanel, Panes.Conditions.toString()); content.add(loggingLevelPanel, Panes.LoggingLevels.toString()); content.add(accessStatusTypePanel, Panes.AccessStatus.toString()); content.add(troubleshootingPanel, Panes.Troubleshooting.toString()); // Main buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); OkAction okAction = new OkAction(); buttonPanel.add(new JButton(okAction)); buttonPanel.add(new JButton(new ApplyAction())); buttonPanel.add(new JButton(new ResetAction())); CancelAction cancelAction = new CancelAction(); buttonPanel.add(new JButton(cancelAction)); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(comboBox, BorderLayout.NORTH); contentPane.add(content, BorderLayout.CENTER); contentPane.add(buttonPanel, BorderLayout.SOUTH); KeyStrokes.registerCommand(content, okAction, "OK_ACTION"); KeyStrokes.registerCommand(buttonPanel, okAction, "OK_ACTION"); KeyStrokes.registerCommand(content, cancelAction, "CANCEL_ACTION"); KeyStrokes.registerCommand(buttonPanel, cancelAction, "CANCEL_ACTION"); }
From source file:org.apache.hadoopts.app.bucketanalyser.TSOperationControlerPanel.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*w w w . ja va 2 s. co m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTextField1 = new javax.swing.JTextField(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jTextField2 = new javax.swing.JTextField(); jButton15 = new javax.swing.JButton(); jButton11 = new javax.swing.JButton(); jRadioButton1 = new javax.swing.JRadioButton(); jPanel2 = new javax.swing.JPanel(); jTextField3 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); jButton18 = new javax.swing.JButton(); jButton12 = new javax.swing.JButton(); jButton13 = new javax.swing.JButton(); jButton22 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); jtMIN = new javax.swing.JTextField(); jtMAX = new javax.swing.JTextField(); jtBINS = new javax.swing.JTextField(); jButton10 = new javax.swing.JButton(); jButton20 = new javax.swing.JButton(); jButton21 = new javax.swing.JButton(); jButton19 = new javax.swing.JButton(); jPanel6 = new javax.swing.JPanel(); jButton14 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jPanel7 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jButton16 = new javax.swing.JButton(); jPanel8 = new javax.swing.JPanel(); jButton17 = new javax.swing.JButton(); jButton23 = new javax.swing.JButton(); jButton24 = new javax.swing.JButton(); jButton25 = new javax.swing.JButton(); jButton26 = new javax.swing.JButton(); jButton27 = new javax.swing.JButton(); jTextField1.setText("jTextField1"); setBackground(new java.awt.Color(204, 204, 255)); setBounds(new java.awt.Rectangle(0, 0, 800, 150)); setMinimumSize(new java.awt.Dimension(308, 150)); setPreferredSize(new java.awt.Dimension(800, 150)); setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0)); jPanel1.setBackground(new java.awt.Color(204, 204, 255)); jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 1, 1)); jTextField2.setBackground(new java.awt.Color(204, 255, 204)); jTextField2.setColumns(45); jTextField2.setText("ChartLabel"); jPanel1.add(jTextField2); jButton15.setText("persist TSB"); jButton15.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton15ActionPerformed(evt); } }); jPanel1.add(jButton15); jButton11.setText("hide"); jButton11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton11ActionPerformed(evt); } }); jPanel1.add(jButton11); jRadioButton1.setText("show labels"); jPanel1.add(jRadioButton1); jTabbedPane1.addTab("TSB", jPanel1); jPanel2.setBackground(new java.awt.Color(204, 204, 255)); jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 1, 1)); jTextField3.setColumns(45); jTextField3.setText("/GITHUB/dissertation/main/FINAL/LATEX/semanpix/"); jTextField3.setMinimumSize(new java.awt.Dimension(40, 28)); jTextField3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField3ActionPerformed(evt); } }); jPanel2.add(jTextField3); jButton1.setBackground(new java.awt.Color(204, 204, 255)); jButton1.setText("save PN"); jButton1.setToolTipText("Save series in an Origin-Project."); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel2.add(jButton1); jButton2.setText("show PN"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel2.add(jButton2); jTabbedPane1.addTab("Pix-Node", jPanel2); jPanel3.setBackground(new java.awt.Color(255, 255, 204)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Single Time Series Transformations")); jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 1)); jButton18.setText("Shuffle"); jButton18.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton18ActionPerformed(evt); } }); jPanel3.add(jButton18); jButton12.setText("NORM max=1"); jButton12.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton12ActionPerformed(evt); } }); jPanel3.add(jButton12); jButton13.setText("NORM std=1, avg=0"); jButton13.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton13ActionPerformed(evt); } }); jPanel3.add(jButton13); jButton22.setText("Log"); jButton22.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton22ActionPerformed(evt); } }); jPanel3.add(jButton22); jButton9.setText("Returns (Rel-Diff)"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jPanel3.add(jButton9); jButton8.setText("Diffs"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jPanel3.add(jButton8); jButton7.setText("Profile"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jPanel3.add(jButton7); jButton3.setText("FFT"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel3.add(jButton3); jTabbedPane1.addTab("Transformations", jPanel3); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Univariate Analysis")); jPanel4.setPreferredSize(new java.awt.Dimension(1225, 113)); jtMIN.setText("-10"); jPanel4.add(jtMIN); jtMAX.setText("10"); jPanel4.add(jtMAX); jtBINS.setText("50"); jPanel4.add(jtBINS); jButton10.setText("Histogram per series"); jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); jPanel4.add(jButton10); jButton20.setText("Histogram cross-cut"); jButton20.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton20ActionPerformed(evt); } }); jPanel4.add(jButton20); jButton21.setText("TEST Normal Distribution"); jButton21.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton21ActionPerformed(evt); } }); jPanel4.add(jButton21); jButton19.setText("CDF"); jButton19.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton19ActionPerformed(evt); } }); jPanel4.add(jButton19); jButton14.setText("ENTROPY"); jButton14.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton14ActionPerformed(evt); } }); jPanel6.add(jButton14); jButton4.setText("Auto-Correlation"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jPanel6.add(jButton4); jButton5.setText("DFA"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jPanel6.add(jButton5); jButton6.setText("MF-DFA"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jPanel6.add(jButton6); jPanel4.add(jPanel6); jTabbedPane1.addTab("Uni-variate. Analysis", jPanel4); jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Multi-variate analysis")); jTabbedPane1.addTab("Multi-variate Analysis", jPanel7); jPanel5.setBackground(new java.awt.Color(255, 204, 204)); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Group Operations")); jButton16.setText("Sigma Band"); jButton16.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton16ActionPerformed(evt); } }); jPanel5.add(jButton16); jTabbedPane1.addTab("Group Operations", jPanel5); jPanel8.setBackground(new java.awt.Color(204, 255, 204)); jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Models")); jButton17.setText("AR"); jPanel8.add(jButton17); jButton23.setText("MA"); jPanel8.add(jButton23); jButton24.setText("ARMA"); jPanel8.add(jButton24); jButton25.setText("ARIMA"); jPanel8.add(jButton25); jButton26.setText("SARIMA"); jPanel8.add(jButton26); jButton27.setText("CARIMA"); jPanel8.add(jButton27); jTabbedPane1.addTab("TS-Model", jPanel8); add(jTabbedPane1); }
From source file:is.iclt.jcorpald.CorpaldView.java
public void createAndShowGUI() { CorpaldSettings settings = CorpaldSettings.getInstance(); //Create and set up the window. JFrame frame = new JFrame(settings.getProperty("corpus.acronym") + " " + settings.getProperty("corpus.version") + " - " + settings.getProperty("corpus.longname")); frame.setIconImage((new ImageIcon("icons/corpald.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setBounds(50, 50, 700, 450); frame.setPreferredSize(new Dimension(750, 720)); // Create the panel that has the query and the result JPanel panMainArea = new JPanel(new BorderLayout()); JPanel panQuery = new JPanel(new BorderLayout()); txtQuery = new JHighlightPane(); txtQuery.addKeyListener(this); txtQuery.setFont(new Font("Monospaced", Font.BOLD, 16)); this.updateHighlighting(); txtQuery.setPreferredSize(new Dimension(700, 150)); panQuery.add(labQuery, BorderLayout.NORTH); panQuery.add(new JScrollPane(txtQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER); panQuery.setBorder(new EmptyBorder(0, 10, 10, 10)); String welcomeMessage = ""; try {/* w w w .j a v a2 s .c o m*/ welcomeMessage = FileUtils.readFileToString(new File(settings.getProperty("corpus.welcome")), "utf-8"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } JPanel panResult = new JPanel(new BorderLayout()); txtResult = new JTextArea(welcomeMessage); txtResult.setEditable(false); txtResult.setFont(new Font("Monospaced", Font.BOLD, 14)); JScrollPane scrResult = new JScrollPane(txtResult, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrResult.setPreferredSize(new Dimension(700, 400)); panResult.add(new JLabel("Result:"), BorderLayout.NORTH); panResult.add(scrResult, BorderLayout.CENTER); panResult.setBorder(new EmptyBorder(0, 10, 0, 10)); panMainArea.add(panQuery, BorderLayout.NORTH); panMainArea.add(panResult, BorderLayout.CENTER); // Create panel at top with buttons JPanel panToolbar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // New, Open, Save // New ImageIcon icoNewQuery = new ImageIcon("icons/page_white.png"); butNewQuery = new JButton(icoNewQuery); butNewQuery.addActionListener(this); butNewQuery.setPreferredSize(new Dimension(26, 26)); butNewQuery.setToolTipText("Create a new empty query"); panToolbar.add(butNewQuery); // Open ImageIcon icoOpenQuery = new ImageIcon("icons/folder.png"); butOpenQuery = new JButton(icoOpenQuery); butOpenQuery.addActionListener(this); butOpenQuery.setPreferredSize(new Dimension(26, 26)); butOpenQuery.setToolTipText("Open a query file"); panToolbar.add(butOpenQuery); // Save ImageIcon icoSaveQuery = new ImageIcon("icons/page_save.png"); butSaveQuery = new JButton(icoSaveQuery); butSaveQuery.addActionListener(this); butSaveQuery.setPreferredSize(new Dimension(26, 26)); butSaveQuery.setToolTipText("Save current query"); panToolbar.add(butSaveQuery); // Save as ImageIcon icoSaveQueryAs = new ImageIcon("icons/page_save_as.png"); butSaveQueryAs = new JButton(icoSaveQueryAs); butSaveQueryAs.addActionListener(this); butSaveQueryAs.setPreferredSize(new Dimension(26, 26)); butSaveQueryAs.setToolTipText("Save current query under a new file name"); panToolbar.add(butSaveQueryAs); // Open definitions file ImageIcon icoOpenDef = new ImageIcon("icons/folder_table.png"); butOpenDef = new JButton(icoOpenDef); butOpenDef.addActionListener(this); butOpenDef.setPreferredSize(new Dimension(26, 26)); butOpenDef.setToolTipText("Select a new definitions file"); panToolbar.add(butOpenDef); // Run Query button ImageIcon icoRunQuery = new ImageIcon("icons/control_play_blue.png"); butRunQuery = new JButton("Run Query", icoRunQuery); butRunQuery.setPreferredSize(new Dimension(130, 26)); butRunQuery.addActionListener(this); butRunQuery.setToolTipText("Run the current query using CorpusSearch"); panToolbar.add(butRunQuery); // TextField for root node label JLabel labRootNode = new JLabel("Root:"); panToolbar.add(labRootNode); txtRootNode = new JTextField("", 12); txtRootNode.setPreferredSize(new Dimension(50, 26)); txtRootNode.addKeyListener(this); txtRootNode.setMargin(new Insets(3, 3, 3, 3)); txtRootNode.setToolTipText("<html>Search within instances of a particular type of node,<br/>" + "such as IP-*, IP-SUB, NP-*, etc. $ROOT matches<br/>" + "the root node of every tree in the corpus.</html>"); panToolbar.add(txtRootNode); chkNodesOnly = new JCheckBox("Nodes only"); chkNodesOnly.addItemListener(this); chkNodesOnly.setToolTipText("<html>If checked, CorpusSearch prints out only the nodes that<br/>" + "contain the structure described in \"Query\". If not checked,<br/>" + "CorpusSearch prints out the entire sentence that contains the<br/>" + "structure described in \"Query\".</html>"); panToolbar.add(chkNodesOnly); chkRemoveNodes = new JCheckBox("Remove nodes"); chkRemoveNodes.addItemListener(this); chkRemoveNodes.setToolTipText("<html>Remove subtrees whose root is of the same syntactic category<br/>" + "as the node boundary embedded within a instance of that node<br/>" + "boundary. \"Remove nodes\" thus removes recursive structure.</html>"); panToolbar.add(chkRemoveNodes); // Create panel at top with buttons JPanel panBottombar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // panBottombar.setBorder(new EmptyBorder(0, 0, 10, 5)); ImageIcon icoOpenFolder = new ImageIcon("icons/folder.png"); butOpenFolder = new JButton("Show result in folder", icoOpenFolder); butOpenFolder.setEnabled(false); butOpenFolder.addActionListener(this); panBottombar.add(butOpenFolder); ImageIcon icoTextEditor = new ImageIcon("icons/page_white_go.png"); butTextEditor = new JButton("Open result in text editor", icoTextEditor); butTextEditor.setEnabled(false); butTextEditor.addActionListener(this); panBottombar.add(butTextEditor); ImageIcon icoCopyResults = new ImageIcon("icons/page_copy.png"); butCopyResults = new JButton("Copy result to clipboard", icoCopyResults); butCopyResults.setEnabled(false); butCopyResults.addActionListener(this); panBottombar.add(butCopyResults); // Add stuff to top level content pane frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(panToolbar, BorderLayout.NORTH); frame.getContentPane().add(panMainArea, BorderLayout.CENTER); frame.getContentPane().add(panBottombar, BorderLayout.SOUTH); this.configureFileFilters(); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:org.interreg.docexplore.DocExploreTool.java
@SuppressWarnings("serial") protected static File askForHome(String text) { final File[] file = { null }; final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true); JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.TOP, true, false)); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT); message.setIconTextGap(20);// w w w. j ava 2s.co m //message.setFont(Font.decode(Font.SANS_SERIF)); content.add(message); final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>")); final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore", 40); pathPanel.add(pathField); pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) { JNativeFileDialog nfd = null; public void actionPerformed(ActionEvent arg0) { if (nfd == null) { nfd = new JNativeFileDialog(); nfd.acceptFiles = false; nfd.acceptFolders = true; nfd.multipleSelection = false; nfd.title = XMLResourceBundle.getBundledString("homeLabel"); } nfd.setCurrentFile(new File(pathField.getText())); if (nfd.showOpenDialog()) pathField.setText(nfd.getSelectedFile().getAbsolutePath()); } })); content.add(pathPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) { public void actionPerformed(ActionEvent e) { File res = new File(pathField.getText()); if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs()) JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"), XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE); else { file[0] = res; dialog.setVisible(false); } } })); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } })); content.add(buttonPanel); dialog.getContentPane().add(content); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); return file[0]; }