List of usage examples for javax.swing JTextArea setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java
private void initialiseUI() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.weightx = 1.0;//from w w w .j a v a2 s .c o m c.gridx = 0; c.gridy = 0; JTextArea taDescription = new JTextArea("Configure the Service Catalogue integration functionality"); taDescription.setFont(taDescription.getFont().deriveFont(Font.PLAIN, 11)); taDescription.setLineWrap(true); taDescription.setWrapStyleWord(true); taDescription.setEditable(false); taDescription.setFocusable(false); taDescription.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(taDescription, c); c.gridy++; c.insets = new Insets(20, 0, 0, 0); JLabel jlBioCatalogueAPIBaseURL = new JLabel("Base URL of the Service Catalogue instance to connect to:"); this.add(jlBioCatalogueAPIBaseURL, c); c.gridy++; c.insets = new Insets(0, 0, 0, 0); tfBioCatalogueAPIBaseURL = new JTextField(); this.add(tfBioCatalogueAPIBaseURL, c); c.gridy++; c.insets = new Insets(30, 0, 0, 0); // We are not removing BioCatalogue services from its config panel any more - // they are being handled by the Taverna's Service Registry // JButton bForgetStoredServices = new JButton("Forget services added to Service Panel by BioCatalogue Plugin"); // bForgetStoredServices.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) // { // int response = JOptionPane.showConfirmDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent... // "Are you sure you want to clear all SOAP operations and REST methods\n" + // "that were added to the Service Panel by the BioCatalogue Plugin?\n\n" + // "This action is permanent is cannot be undone.\n\n" + // "Do you want to proceed?", "BioCatalogue Plugin", JOptionPane.YES_NO_OPTION); // // if (response == JOptionPane.YES_OPTION) // { // BioCatalogueServiceProvider.clearRegisteredServices(); // JOptionPane.showMessageDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent... // "Stored services have been successfully cleared, but will remain\n" + // "being shown in Service Panel during this session.\n\n" + // "They will not appear in the Service Panel after you restart Taverna.", // "BioCatalogue Plugin", JOptionPane.INFORMATION_MESSAGE); // } // } // }); // this.add(bForgetStoredServices, c); JButton bLoadDefaults = new JButton("Load Defaults"); bLoadDefaults.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadDefaults(); } }); JButton bReset = new JButton("Reset"); bReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetFields(); } }); JButton bApply = new JButton("Apply"); bApply.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyChanges(); } }); JPanel jpActionButtons = new JPanel(); jpActionButtons.add(bLoadDefaults); jpActionButtons.add(bReset); jpActionButtons.add(bApply); c.insets = new Insets(30, 0, 0, 0); c.gridy++; c.weighty = 1.0; this.add(jpActionButtons, c); }
From source file:com.tascape.qa.th.android.driver.App.java
/** * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction. * * @param timeoutMinutes timeout in minutes to fail the manual steps * * @throws Exception if case of error/*from w w w .java 2 s. co m*/ */ public void interactManually(int timeoutMinutes) throws Exception { LOG.info("Start manual UI interaction"); long end = System.currentTimeMillis() + timeoutMinutes * 60000L; AtomicBoolean visible = new AtomicBoolean(true); AtomicBoolean pass = new AtomicBoolean(false); String tName = Thread.currentThread().getName() + "m"; SwingUtilities.invokeLater(() -> { JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail()); jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); JPanel jpContent = new JPanel(new BorderLayout()); jd.setContentPane(jpContent); jpContent.setPreferredSize(new Dimension(1088, 828)); jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel jpInfo = new JPanel(); jpContent.add(jpInfo, BorderLayout.PAGE_START); jpInfo.setLayout(new BorderLayout()); { JButton jb = new JButton("PASS"); jb.setForeground(Color.green.darker()); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_START); jb.addActionListener(event -> { pass.set(true); jd.dispose(); visible.set(false); }); } { JButton jb = new JButton("FAIL"); jb.setForeground(Color.red); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_END); jb.addActionListener(event -> { pass.set(false); jd.dispose(); visible.set(false); }); } JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); new SwingWorker<Long, Long>() { @Override protected Long doInBackground() throws Exception { while (System.currentTimeMillis() < end) { Thread.sleep(1000); long left = (end - System.currentTimeMillis()) / 1000; this.publish(left); } return 0L; } @Override protected void process(List<Long> chunks) { Long l = chunks.get(chunks.size() - 1); jlTimeout.setText(l + " seconds left"); if (l < 850) { jlTimeout.setForeground(Color.red); } } }.execute(); JPanel jpResponse = new JPanel(new BorderLayout()); JPanel jpProgress = new JPanel(new BorderLayout()); jpResponse.add(jpProgress, BorderLayout.PAGE_START); JTextArea jtaJson = new JTextArea(); jtaJson.setEditable(false); jtaJson.setTabSize(4); Font font = jtaJson.getFont(); jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize())); JTree jtView = new JTree(); JTabbedPane jtp = new JTabbedPane(); jtp.add("tree", new JScrollPane(jtView)); jtp.add("json", new JScrollPane(jtaJson)); jpResponse.add(jtp, BorderLayout.CENTER); JPanel jpScreen = new JPanel(); jpScreen.setMinimumSize(new Dimension(200, 200)); jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS)); JScrollPane jsp1 = new JScrollPane(jpScreen); jpResponse.add(jsp1, BorderLayout.LINE_START); JPanel jpJs = new JPanel(new BorderLayout()); JTextArea jtaJs = new JTextArea(); jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs); jSplitPane.setResizeWeight(0.88); jpContent.add(jSplitPane, BorderLayout.CENTER); JPanel jpLog = new JPanel(); jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS)); JCheckBox jcbTap = new JCheckBox("Enable Click", null, false); jpLog.add(jcbTap); jpLog.add(Box.createHorizontalStrut(8)); JButton jbLogUi = new JButton("Log Screen"); jpResponse.add(jpLog, BorderLayout.PAGE_END); { jpLog.add(jbLogUi); jbLogUi.addActionListener((ActionEvent event) -> { jtaJson.setText("waiting for screenshot..."); Thread t = new Thread(tName) { @Override public void run() { LOG.debug("\n\n"); try { WindowHierarchy wh = device.loadWindowHierarchy(); jtView.setModel(getModel(wh)); jtaJson.setText(""); jtaJson.append(wh.root.toJson().toString(2)); jtaJson.append("\n"); File png = device.takeDeviceScreenshot(); BufferedImage image = ImageIO.read(png); int w = device.getDisplayWidth(); int h = device.getDisplayHeight(); BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(image, 0, 0, w, h, null); g2.dispose(); JLabel jLabel = new JLabel(new ImageIcon(resizedImg)); jpScreen.removeAll(); jsp1.setPreferredSize(new Dimension(w + 30, h)); jpScreen.add(jLabel); jLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY()); if (jcbTap.isSelected()) { device.click(e.getPoint().x, e.getPoint().y); device.waitForIdle(); jbLogUi.doClick(); } } }); } catch (Exception ex) { LOG.error("Cannot log screen", ex); jtaJson.append("Cannot log screen"); } jtaJson.append("\n\n\n"); LOG.debug("\n\n"); jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1); jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1); } }; t.start(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbLogMsg = new JButton("Log Message"); jpLog.add(jbLogMsg); JTextField jtMsg = new JTextField(10); jpLog.add(jtMsg); jtMsg.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent pE) { } @Override public void focusGained(final FocusEvent pE) { jtMsg.selectAll(); } }); jtMsg.addKeyListener(new KeyAdapter() { @Override public void keyPressed(java.awt.event.KeyEvent e) { if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { jbLogMsg.doClick(); } } }); jbLogMsg.addActionListener(event -> { Thread t = new Thread(tName) { @Override public void run() { String msg = jtMsg.getText(); if (StringUtils.isNotBlank(msg)) { LOG.info("{}", msg); jtMsg.selectAll(); } } }; t.start(); try { t.join(); } catch (InterruptedException ex) { LOG.error("Cannot take screenshot", ex); } jtMsg.requestFocus(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbClear = new JButton("Clear"); jpLog.add(jbClear); jbClear.addActionListener(event -> { jtaJson.setText(""); }); } JPanel jpAction = new JPanel(); jpContent.add(jpAction, BorderLayout.PAGE_END); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jpJs.add(jpAction, BorderLayout.PAGE_END); jd.pack(); jd.setVisible(true); jd.setLocationRelativeTo(null); jbLogUi.doClick(); }); while (visible.get()) { if (System.currentTimeMillis() > end) { LOG.error("Manual UI interaction timeout"); break; } Thread.sleep(500); } if (pass.get()) { LOG.info("Manual UI Interaction returns PASS"); } else { Assert.fail("Manual UI Interaction returns FAIL"); } }
From source file:net.sf.jabref.openoffice.StyleSelectDialog.java
private void displayDefaultStyle(boolean authoryear) { try {/* ww w . j ava 2 s . c o m*/ // Read the contents of the default style file: URL defPath = authoryear ? JabRef.class.getResource(OpenOfficePanel.DEFAULT_AUTHORYEAR_STYLE_PATH) : JabRef.class.getResource(OpenOfficePanel.DEFAULT_NUMERICAL_STYLE_PATH); BufferedReader r = new BufferedReader(new InputStreamReader(defPath.openStream())); String line; StringBuilder sb = new StringBuilder(); while ((line = r.readLine()) != null) { sb.append(line); sb.append('\n'); } // Make a dialog box to display the contents: final JDialog dd = new JDialog(diag, Localization.lang("Default style"), true); JLabel header = new JLabel( "<html>" + Localization.lang("The panel below shows the definition of the default style.") //+"<br>" + Localization.lang( "If you want to use it as a template for a new style, you can copy the contents into a new .jstyle file") + "</html>"); header.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dd.getContentPane().add(header, BorderLayout.NORTH); JTextArea ta = new JTextArea(sb.toString()); ta.setEditable(false); JScrollPane sp = new JScrollPane(ta); sp.setPreferredSize(new Dimension(700, 500)); dd.getContentPane().add(sp, BorderLayout.CENTER); JButton okButton = new JButton(Localization.lang("OK")); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(okButton); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dd.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { dd.dispose(); } }); dd.pack(); dd.setLocationRelativeTo(diag); dd.setVisible(true); } catch (IOException ex) { LOGGER.warn("Problem showing default style", ex); } }
From source file:com.smart.aqimonitor.client.AqiMonitor.java
/** * Create the frame./* w w 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:com.sshtools.common.ui.SshToolsApplication.java
public void openChangelog(Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); String changelog = ""; try {/*from ww w . j a va 2s . c om*/ BufferedReader br = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/changelog"))); String line = br.readLine(); while (line != null) { changelog += line + "\n"; line = br.readLine(); } br.close(); } catch (Exception e) { changelog = "<Error opening changelog>\n"; } javax.swing.JTextArea message = new javax.swing.JTextArea(changelog); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); // MultilineLabel x = new MultilineLabel(changelog); // x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); // x.setFont(x.getFont().deriveFont(12f)); javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.getViewport().add(message); scrollPane.setSize(400, 200); scrollPane.setPreferredSize(new java.awt.Dimension(400, 200)); UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "Change log", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:com.diversityarrays.kdxplore.trialmgr.TrialManagerApp.java
@Override public AfterUpdateResult initialiseAppAfterUpdateCheck(AppInitContext initContext) { final AfterUpdateResult[] initResult = new AfterUpdateResult[1]; initResult[0] = AfterUpdateResult.OK; trialExplorerPanel.doPostOpenOperations(); String currentDatabaseUrl = explorerProperties.getCurrentDatabaseUrl(); if (!KdxploreDatabase.LOCAL_DATABASE_URL.equalsIgnoreCase(currentDatabaseUrl)) { clientProvider.setInitialClientUrl(currentDatabaseUrl); }//from w ww .j a v a2 s.c om clientProvider.setInitialClientUsername(explorerProperties.getCurrentDatabaseUsername()); if (currentDatabaseUrl == null) { currentDatabaseUrl = KdxploreDatabase.LOCAL_DATABASE_URL; } Closure<DatabaseDataLoadResult> loadDataErrorCompleteHandler = new Closure<DatabaseDataLoadResult>() { @Override public void execute(DatabaseDataLoadResult result) { Throwable problem = result.cause; if (problem == null) { // If user is logged in it may be to another database // so ensure we don't get confused by shutting down the extant connection. if (clientProvider.isClientAvailable()) { DALClient client = clientProvider.getDALClient(); if (!client.getBaseUrl().equalsIgnoreCase(result.dbUrl)) { clientProvider.logout(); } } String initialTabName = TAB_TRIALS; if (KdxploreConfig.getInstance().getModeList().contains("CIMMYT") && trialExplorerPanel.getTrialCount() <= 0 && traitExplorerPanel.getTraitCount() <= 0) { // This will suggest that the user loads traits first. initialTabName = TAB_TRAITS; // The reason for this in CIMMYT mode is that because the // user isn't able to get the Traits from the database // they really should load the Traits first. // } int index = tabbedPane.indexOfTab(initialTabName); tabbedPane.setSelectedIndex(index); } else { problem.printStackTrace(); messagesPanel.println(problem); Throwable lastCause = null; Throwable cause = problem; while (cause != null) { lastCause = cause; cause = cause.getCause(); } if (lastCause != null) { Shared.Log.e(TAG, "Initialisation Failed", lastCause); //$NON-NLS-1$ } // Replace all extant tabs with the Error tab. for (int tabIndex = tabbedPane.getTabCount(); --tabIndex >= 0;) { tabbedPane.remove(tabIndex); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); result.cause.printStackTrace(pw); pw.close(); JTextArea ta = new JTextArea(sw.toString()); ta.setEditable(false); tabbedPane.addTab(Msg.TAB_INIT_ERROR(), new JScrollPane(ta)); initResult[0] = AfterUpdateResult.FAIL_IF_ALL; String errmsg = lastCause == null ? "" : lastCause.getMessage(); //$NON-NLS-1$ GuiUtil.errorMessage(TrialManagerApp.this, Msg.ERRMSG_CHECK_MESSSAGES_URL_CAUSE(result.dbUrl, errmsg), OfflineData.LOADING_OFFLINE_REFERENCE_DATA_ERROR()); } } }; List<DatabaseDataStub> databaseStubs = DatabaseDataUtils.collectDatabaseDirectories(userDataFolder, driverType); DatabaseDataStub chosen = null; if (databaseStubs.isEmpty()) { // This is a brand new one. chosen = DatabaseDataStub.create(driverType, userDataFolder, currentDatabaseUrl); // Path dirPath = Paths.get(defaultKdxploreDatabaseLocation.databaseDirectory.getPath()); // boolean isDefaultDatabase = defaultKdxploreDatabaseLocation.databaseDirectory.equals(dirPath.toFile()); // chosen = new DatabaseDataStub(isDefaultDatabase, defaultKdxploreDatabaseLocation.driverType, dirPath, currentDatabaseUrl, null); } else { if (databaseStubs.size() == 1) { chosen = databaseStubs.get(0); } else { DatabaseDataStub[] selectionValues = databaseStubs .toArray(new DatabaseDataStub[databaseStubs.size()]); for (DatabaseDataStub dds : selectionValues) { if (currentDatabaseUrl.equalsIgnoreCase(dds.dburl)) { chosen = dds; break; } } if (chosen == null) { chosen = selectionValues[0]; } Object answer = JOptionPane.showInputDialog(TrialManagerApp.this, Msg.MSG_CHOOSE_DATABASE_TO_OPEN_DEFAULT(chosen.toString()), Msg.TITLE_MULTIPLE_DATABASES_FOUND(), JOptionPane.QUESTION_MESSAGE, null, selectionValues, chosen); if (answer instanceof DatabaseDataStub) { chosen = (DatabaseDataStub) answer; } } } if (chosen == null) { initResult[0] = AfterUpdateResult.FAIL_IF_ALL; // System.exit(0); } else { loadOfflineDataAsync(chosen, loadDataErrorCompleteHandler); trialExplorerPanel.initialiseUploadHandler(offlineData); } return initResult[0]; }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Hist2DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);//from w w w. jav a 2s .c om listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Show the TextMessage in a JTextArea.//from ww w .j a va 2 s. c om * * @param textMessage * @return * @throws JMSException */ protected JComponent handleTextMessage(final TextMessage textMessage) throws JMSException { // // Show the text in a JTextArea, you can edit the message in place and // then drop it onto another queue/topic. final String text = textMessage.getText(); final JTextArea textPane = new JTextArea(); // final CharBuffer bytes = CharBuffer.wrap(text.subSequence(0, // text.length())) ; // final JTextArea textPane = new MyTextArea(new PlainDocument(new // MappedStringContent(bytes))) ; textPane.setEditable(false); textPane.setFont(Font.decode("Monospaced-PLAIN-12")); textPane.setLineWrap(true); textPane.setWrapStyleWord(true); textPane.append(text); textPane.getDocument().addDocumentListener(new DocumentListener() { public void doChange() { try { textMessage.setText(textPane.getText()); } catch (JMSException e) { JOptionPane.showMessageDialog(textPane, "Unable to update the TextMessage: " + e.getMessage(), "Error modifying message content", JOptionPane.ERROR_MESSAGE); try { textPane.setText(textMessage.getText()); } catch (JMSException e1) { log.error(e1.getMessage(), e1); } textPane.setEditable(false); textPane.getDocument().removeDocumentListener(this); } } @Override public void changedUpdate(DocumentEvent arg0) { doChange(); } @Override public void insertUpdate(DocumentEvent arg0) { doChange(); } @Override public void removeUpdate(DocumentEvent arg0) { doChange(); } }); textPane.setCaretPosition(0); return textPane; }
From source file:ConfigFiles.java
public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y, boolean withbutton, ActionListener actionlistener) { JPanel p1 = new JPanel(); p1.setBackground(Color.WHITE); TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p1.setBorder(border);//w w w . j a va2s. co m p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS)); p1.setBounds(80, Y, 800, 75); paths.add(p1); JTextArea tcpath = new JTextArea(description); tcpath.setWrapStyleWord(true); tcpath.setLineWrap(true); tcpath.setEditable(false); tcpath.setCursor(null); tcpath.setOpaque(false); tcpath.setFocusable(false); tcpath.setFont(new Font("Arial", Font.PLAIN, 12)); tcpath.setBackground(getBackground()); tcpath.setMaximumSize(new Dimension(170, 22)); tcpath.setPreferredSize(new Dimension(170, 22)); tcpath.setBorder(null); JPanel p11 = new JPanel(); p11.setBackground(Color.WHITE); p11.setLayout(new GridLayout()); p11.add(tcpath); p11.setMaximumSize(new Dimension(700, 18)); p11.setPreferredSize(new Dimension(700, 18)); textfield.setMaximumSize(new Dimension(340, 27)); textfield.setPreferredSize(new Dimension(340, 27)); textfield.setText(fieldtext); JButton b = null; if (withbutton) { b = new JButton("..."); if (!PermissionValidator.canChangeFWM()) { b.setEnabled(false); } b.setMaximumSize(new Dimension(50, 20)); b.setPreferredSize(new Dimension(50, 20)); if (actionlistener == null) { b.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent ev) { Container c; if (RunnerRepository.container != null) c = RunnerRepository.container.getParent(); else c = RunnerRepository.window; try { new MySftpBrowser(RunnerRepository.host, RunnerRepository.user, RunnerRepository.password, textfield, c, false); } catch (Exception e) { System.out.println("There was a problem in opening sftp browser!"); e.printStackTrace(); } } }); } else { b.addActionListener(actionlistener); b.setText("Save"); b.setMaximumSize(new Dimension(70, 20)); b.setPreferredSize(new Dimension(70, 20)); } } JPanel p12 = new JPanel(); p12.setBackground(Color.WHITE); p12.add(textfield); if (withbutton) p12.add(b); p12.setMaximumSize(new Dimension(700, 32)); p12.setPreferredSize(new Dimension(700, 32)); p1.add(p11); p1.add(p12); return p12; }
From source file:edu.ku.brc.specify.plugins.ipadexporter.InstitutionConfigDlg.java
/** * @return/* ww w . j a v a 2 s . c o m*/ */ private JPanel createPicturePanel() { AppPreferences remotePrefs = AppPreferences.getRemote(); String picturelocation = remotePrefs.get(getRemotePicturePrefName(), ""); JTextArea explainTextArea = UIHelper.createTextArea(); explainTextArea.setEditable(false); explainTextArea.setText(getResourceString("PICTURE_EXPLAIN")); explainTextArea.setOpaque(false); final String thumbnailPicMsg = getResourceString("THUMBNAIL_PIC"); imageView = new ImageDisplay(200, 200, true, true); imageView.setThumbnailMsg(thumbnailPicMsg); if (StringUtils.isNotEmpty(picturelocation)) { String fullPath = UIRegistry.getAppDataDir() + File.separator + picturelocation; File urlFile = new File(fullPath); if (urlFile.exists()) { imageView.setValue(urlFile.toURI().toASCIIString(), null); } } JButton clearBtn = UIHelper.createI18NButton("CLEAR_PICTURE"); clearBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { imageView.setValue(null, null); imageView.setThumbnailMsg(thumbnailPicMsg); imageView.repaint(); } }); CellConstraints cc = new CellConstraints(); PanelBuilder epb = new PanelBuilder(new FormLayout("f:p:g", "top:p:g,4px,p")); epb.add(explainTextArea, cc.xy(1, 1)); PanelBuilder bpb = new PanelBuilder(new FormLayout("p", "f:p:g,p")); bpb.add(clearBtn, cc.xy(1, 2)); epb.add(bpb.getPanel(), cc.xy(1, 3)); PanelBuilder pb = new PanelBuilder(new FormLayout("p,8px,f:p:g", "f:p:g")); pb.add(imageView, cc.xy(1, 1)); pb.add(epb.getPanel(), cc.xy(3, 1)); return pb.getPanel(); }