List of usage examples for javax.swing JTextArea setWrapStyleWord
@BeanProperty(description = "should wrapping occur at word boundaries") public void setWrapStyleWord(boolean word)
From source file:net.sf.firemox.ui.wizard.AboutMdb.java
/** * Creates a new instance of AboutMdb <br> * //from w ww . ja v a 2 s. c om * @param parent */ public AboutMdb(JFrame parent) { super(LanguageManager.getString("about.tbs"), "<html><b>" + LanguageManager.getString("tbsname") + ": </b>" + MdbLoader.getTbsFullName() + "<br><b>" + LanguageManager.getString("author") + ": </b>" + MdbLoader.getAuthor() + "<br><b>" + LanguageManager.getString("info") + ": </b>" + MdbLoader.getMoreInfo() + "<br><b>" + LanguageManager.getString("version") + ": </b>" + MdbLoader.getVersion(), "mp64.gif", LanguageManager.getString("close"), 420, 320); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); // Then try and read it locally final InputStream inGPL = MToolKit.getResourceAsStream(MToolKit.mdbFile); if (inGPL != null) { disclaimer.setText(MdbLoader.getDisclaimer().replaceAll("\t", "").replaceAll("\n", "")); IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); setLocation((getToolkit().getScreenSize().width - 420) / 2, (getToolkit().getScreenSize().height - 320) / 2); }
From source file:net.sf.firemox.deckbuilder.DeckRules.java
/** * Create a new instance of DeckRules//from ww w . ja va 2s . c om * * @param parent */ public DeckRules(JFrame parent) { super(LanguageManager.getString("jdeckrules", MdbLoader.getTbsFullName()), LanguageManager.getString("jdeckrules.tooltip", MdbLoader.getTbsFullName()), "wiz_library_wiz.png", LanguageManager.getString("close"), 490, 300); // ... Set initial text, scrolling, and border. final JTextArea textRules = new JTextArea(); textRules.setEditable(false); textRules.setLineWrap(true); textRules.setWrapStyleWord(true); textRules.setAutoscrolls(true); textRules.setTabSize(2); textRules.setText("No defined rules"); BufferedReader inGPL = null; try { inGPL = new BufferedReader(new FileReader(MToolKit.getTbsFile( "decks/DECK_CONSTRAINTS-" + LanguageManager.getLanguage().getLocale() + "-lang.info"))); textRules.read(inGPL, "Deck constraints"); } catch (IOException e) { // Ignore this error } finally { IOUtils.closeQuietly(inGPL); } final JScrollPane scrollingArea = new JScrollPane(textRules); gameParamPanel.add(scrollingArea); pack(); }
From source file:BoxLayoutPane.java
public BoxLayoutPane() { // Use a BorderLayout layout manager to arrange various Box components this.setLayout(new BorderLayout()); // Give the entire panel a margin by adding an empty border // We could also do this by overriding getInsets() this.setBorder(new EmptyBorder(10, 10, 10, 10)); // Add a plain row of buttons along the top of the pane Box row = Box.createHorizontalBox(); for (int i = 0; i < 4; i++) { JButton b = new JButton("B" + i); b.setFont(new Font("serif", Font.BOLD, 12 + i * 2)); row.add(b);// www .ja v a2 s . c o m } this.add(row, BorderLayout.NORTH); // Add a plain column of buttons along the right edge // Use BoxLayout with a different kind of Swing container // Give the column a border: can't do this with the Box class JPanel col = new JPanel(); col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS)); col.setBorder(new TitledBorder(new EtchedBorder(), "Column")); for (int i = 0; i < 4; i++) { JButton b = new JButton("Button " + i); b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2)); col.add(b); } this.add(col, BorderLayout.EAST); // Add column to right of panel // Add a button box along the bottom of the panel. // Use "Glue" to space the buttons evenly Box buttonbox = Box.createHorizontalBox(); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Okay")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Cancel")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Help")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space this.add(buttonbox, BorderLayout.SOUTH); // Create a component to display in the center of the panel JTextArea textarea = new JTextArea(); textarea.setText("This component has 12-pixel margins on left and top" + " and has 72-pixel margins on right and bottom."); textarea.setLineWrap(true); textarea.setWrapStyleWord(true); // Use Box objects to give the JTextArea an unusual spacing // First, create a column with 3 kids. The first and last kids // are rigid spaces. The middle kid is the text area Box fixedcol = Box.createVerticalBox(); fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels fixedcol.add(textarea); // Component fills in the rest fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels // Now create a row. Give it rigid spaces on the left and right, // and put the column from above in the middle. Box fixedrow = Box.createHorizontalBox(); fixedrow.add(Box.createHorizontalStrut(12)); fixedrow.add(fixedcol); fixedrow.add(Box.createHorizontalStrut(72)); // Now add the JTextArea in the column in the row to the panel this.add(fixedrow, BorderLayout.CENTER); }
From source file:net.sf.firemox.ui.component.SplashScreen.java
/** * Create a new instance of this class./*from w w w. jav a2 s . c o m*/ * * @param filename * the picture filename. * @param parent * the splash screen's parent. * @param waitTime * the maximum time before the screen is hidden. */ public SplashScreen(String filename, Frame parent, int waitTime) { super(parent); getContentPane().setLayout(null); toFront(); final JLabel l = new JLabel(new ImageIcon(filename)); final Dimension labelSize = l.getPreferredSize(); l.setLocation(0, 0); l.setSize(labelSize); setSize(labelSize); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - labelSize.width / 2, screenSize.height / 2 - labelSize.height / 2); final JLabel mp = new JLabel(IdConst.PROJECT_DISPLAY_NAME); mp.setLocation(30, 305); mp.setSize(new Dimension(300, 30)); final JLabel version = new JLabel(IdConst.VERSION); version.setLocation(235, 418); version.setSize(new Dimension(300, 30)); final JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setFont(MToolKit.defaultFont); disclaimer.setTabSize(2); // Then try and read it locally Reader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } final JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); disclaimerSPanel.setViewportView(disclaimer); disclaimerSPanel.setLocation(27, 340); disclaimerSPanel.setPreferredSize(new Dimension(283, 80)); disclaimerSPanel.setSize(disclaimerSPanel.getPreferredSize()); getContentPane().add(disclaimerSPanel); getContentPane().add(version); getContentPane().add(mp); getContentPane().add(l); final int pause = waitTime; final Runnable waitRunner = new Runnable() { public void run() { try { Thread.sleep(pause); while (!bKilled) { Thread.sleep(200); } } catch (InterruptedException e) { // Ignore this error } setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } }; // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { setVisible(false); dispose(); if (MagicUIComponents.magicForm != null) MagicUIComponents.magicForm.toFront(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } } }); setVisible(true); start(waitRunner); }
From source file:org.gumtree.vis.awt.AbstractPlotEditor.java
private JPanel createHelpPanel() { 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 = plot.getHelpProvider(); 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);// w w w . j av a 2 s .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:de.unidue.inf.is.ezdl.gframedl.components.AboutDialog.java
private JPanel getContent() { JPanel panel = new JPanel(new GridBagLayout()); JLabel iconLabel = new JLabel(new ImageIcon(Images.LOGO_EZDL_LARGE_SINGLE.getImage())); JTextArea licenseTextArea = new JTextArea(licenseText); licenseTextArea.setEditable(false);// www.j a v a2 s .c om licenseTextArea.setLineWrap(true); licenseTextArea.setWrapStyleWord(true); licenseTextArea.setOpaque(false); licenseTextArea.setBorder(BorderFactory.createEmptyBorder()); JScrollPane licenseScrollPane = new JScrollPane(licenseTextArea); JTable propertiesTable = new JTable(tableModel); propertiesTable.setBackground(Color.WHITE); propertiesTable.setShowGrid(false); JScrollPane propertiesScrollPane = new JScrollPane(propertiesTable); propertiesScrollPane.setBackground(Color.WHITE); propertiesScrollPane.getViewport().setBackground(Color.WHITE); JButton closeButton = new JButton(I18nSupport.getInstance().getLocString("ezdl.controls.close")); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(I18nSupport.getInstance().getLocString("ezdl.licence"), licenseScrollPane); tabbedPane.addTab(I18nSupport.getInstance().getLocString("ezdl.properties"), propertiesScrollPane); tabbedPane.setBackground(Color.WHITE); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, 0, 0, 0); c.anchor = GridBagConstraints.CENTER; panel.add(iconLabel, c); c.gridx = 0; c.gridy = 1; c.weightx = 1; c.weighty = 1; c.anchor = GridBagConstraints.CENTER; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(10, 20, 10, 20); panel.add(tabbedPane, c); c.gridy = 2; c.fill = GridBagConstraints.NONE; c.weighty = 0; c.insets = new Insets(0, 20, 10, 20); panel.add(closeButton, c); panel.setBackground(Color.WHITE); return panel; }
From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java
private void showErrorWindow(String title, String body) { try {/*w ww .jav a2 s . c o m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // System.setProperty("apple.awt.UIElement", "false"); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(body); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setLineWrap(true); textArea.setFont(Font.getFont(Font.MONOSPACED)); textArea.setEditable(false); textArea.setWrapStyleWord(true); scrollPane.setPreferredSize(new Dimension(500, 500)); JTextPane titleLabel = new JTextPane(); titleLabel.setContentType("text/html"); // let the text pane know this is what you want titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off titleLabel.setEditable(false); titleLabel.setBackground(null); titleLabel.setBorder(null); panel.add(titleLabel); panel.add(scrollPane); final JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); moveCenter(frame); frame.setVisible(true); JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.", JOptionPane.CLOSED_OPTION); System.exit(1); } catch (Exception e) { log.error("Problem showing error window", e); } }
From source file:net.sf.firemox.ui.wizard.About.java
/** * Creates a new instance of About <br> * //from www .jav a 2s . c om * @param parent */ public About(JFrame parent) { super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"), "mp64.gif", LanguageManager.getString("close"), 420, 620); JPanel thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLabel(IdConst.VERSION); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING)); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); thanksPanelLeft.setMaximumSize(new Dimension(100, 2000)); thanksPanelLeft.setMinimumSize(new Dimension(100, 16)); jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); thanksPanelLeft = new JPanel(); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); StringBuilder contributors = new StringBuilder(); addContributor(contributors, "Fabrice Daugan", "developper", "france"); addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia"); addContributor(contributors, "nico100", "graphist", "france"); addContributor(contributors, "seingalt_tm", "graphist", "france"); addContributor(contributors, "surtur2", "tester", null); addContributor(contributors, "Jan Blaha", "developper", "cz"); addContributor(contributors, "Tureba", "developper", "brazil"); addContributor(contributors, "hakvf", "tester", "france"); addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian"); jLabel5 = new JLabel(contributors.toString()); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); thanksPanelLeft.add(jLabel5); jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen"); jLabel5.setFont(MToolKit.defaultFont); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel blanklbl = new JLabel(); blanklbl.setHorizontalAlignment(SwingConstants.RIGHT); blanklbl.setMaximumSize(new Dimension(100, 16)); blanklbl.setMinimumSize(new Dimension(100, 16)); blanklbl.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(blanklbl); jLabel5 = new JLink( "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043", LanguageManager.getString("joindev")); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); // forum francais thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT); jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip")); thanksPanel.add(jLabel5); jLabel5 = new JLabel(); jLabel5.setMaximumSize(new Dimension(1000, 16)); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setTabSize(2); disclaimer.setFont(new Font("Arial", 0, 10)); // Then try and read it locally BufferedReader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); }
From source file:com.loy.MainFrame.java
@SuppressWarnings("rawtypes") public void init() { String src = "ee.png"; try {/*from ww w . j ava 2 s .co m*/ ClassPathResource classPathResource = new ClassPathResource(src); image = ImageIO.read(classPathResource.getURL()); this.setIconImage(image); } catch (IOException e) { } menu = new JMenu("LOG CONSOLE"); this.jmenuBar = new JMenuBar(); this.jmenuBar.add(menu); panel = new JPanel(new BorderLayout()); this.add(panel); ClassPathResource classPathResource = new ClassPathResource("application.yml"); Yaml yaml = new Yaml(); Map result = null; try { result = (Map) yaml.load(classPathResource.getInputStream()); } catch (IOException e1) { e1.printStackTrace(); } String platformStr = result.get("platform").toString(); String version = result.get("version").toString(); String jvmOption = result.get("jvmOption").toString(); @SuppressWarnings("unchecked") List<String> projects = (List<String>) result.get("projects"); platform = Platform.valueOf(platformStr); final Runtime runtime = Runtime.getRuntime(); File pidsForder = new File("./pids"); if (!pidsForder.exists()) { pidsForder.mkdir(); } else { File[] files = pidsForder.listFiles(); if (files != null) { for (File f : files) { f.deleteOnExit(); String pidStr = f.getName(); try { Long pid = new Long(pidStr); if (Processes.isProcessRunning(platform, pid)) { if (Platform.Windows == platform) { Processes.tryKillProcess(null, platform, new NullProcessor(), pid); } else { Processes.killProcess(null, platform, new NullProcessor(), pid); } } } catch (Exception ex) { } } } } File currentForder = new File(""); String rootPath = currentForder.getAbsolutePath(); rootPath = rootPath.replace(File.separator + "build" + File.separator + "libs", ""); rootPath = rootPath.replace(File.separator + "e-example-ms-start-w", ""); for (String value : projects) { String path = value; String[] values = value.split("/"); value = values[values.length - 1]; String appName = value; value = rootPath + "/" + path + "/build/libs/" + value + "-" + version + ".jar"; JMenuItem menuItem = new JMenuItem(appName); JTextArea textArea = new JTextArea(); textArea.setVisible(true); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setAutoscrolls(true); JScrollPane scorll = new JScrollPane(textArea); this.textSreaMap.put(appName, scorll); EComposite ecomposite = new EComposite(); ecomposite.setCommand(value); ecomposite.setTextArea(textArea); composites.put(appName, ecomposite); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<JScrollPane> values = textSreaMap.values(); for (JScrollPane t : values) { t.setVisible(false); } String actions = e.getActionCommand(); JScrollPane textArea = textSreaMap.get(actions); if (textArea != null) { textArea.setVisible(true); panel.removeAll(); panel.add(textArea); panel.repaint(); panel.validate(); self.repaint(); self.validate(); } } }); menu.add(menuItem); } new Thread(new Runnable() { @Override public void run() { int size = composites.keySet().size(); int index = 1; for (String appName : composites.keySet()) { EComposite composite = composites.get(appName); try { Process process = runtime.exec( "java " + jvmOption + " -Dfile.encoding=UTF-8 -jar " + composite.getCommand()); Long pid = Processes.processId(process); pids.add(pid); File pidsFile = new File("./pids", pid.toString()); pidsFile.createNewFile(); new WriteLogThread(process.getInputStream(), composite.getTextArea()).start(); } catch (IOException e) { e.printStackTrace(); } synchronized (lock) { try { if (index < size) { lock.wait(); } else { index++; } } catch (InterruptedException e) { e.printStackTrace(); } } } } }).start(); }
From source file:edu.ku.brc.specify.config.SpecifyExceptionTracker.java
@Override protected FeedBackSenderItem getFeedBackSenderItem(final Class<?> cls, final Exception exception) { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,8px,p,2px, p,4px,p,2px,f:p:g")); Vector<Taskable> taskItems = new Vector<Taskable>(TaskMgr.getInstance().getAllTasks()); Collections.sort(taskItems, new Comparator<Taskable>() { @Override/* ww w .ja va2 s .c om*/ public int compare(Taskable o1, Taskable o2) { return o1.getName().compareTo(o2.getName()); } }); final JTextArea commentsTA = createTextArea(3, 60); final JTextArea stackTraceTA = createTextArea(15, 60); final JCheckBox moreBtn; commentsTA.setWrapStyleWord(true); commentsTA.setLineWrap(true); //JLabel desc = createI18NLabel("UNHDL_EXCP", SwingConstants.LEFT); JEditorPane desc = new JEditorPane("text/html", getResourceString("UNHDL_EXCP")); desc.setEditable(false); desc.setOpaque(false); //desc.setFont(new Font(Font.SANS_SERIF, Font.BOLD, (new JLabel("X")).getFont().getSize())); JScrollPane sp = new JScrollPane(stackTraceTA, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); int y = 1; pb.add(desc, cc.xyw(1, y, 4)); y += 2; pb.add(createI18NFormLabel("UNHDL_EXCP_CMM"), cc.xy(1, y)); y += 2; pb.add(createScrollPane(commentsTA, true), cc.xyw(1, y, 4)); y += 2; forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); //$NON-NLS-1$ setControlSize(moreBtn); JButton copyBtn = createI18NButton("UNHDL_EXCP_COPY"); PanelBuilder innerPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,2px,p:g,2px,p")); innerPB.add(createI18NLabel("UNHDL_EXCP_STK"), cc.xy(1, 1)); innerPB.add(sp, cc.xyw(1, 3, 3)); innerPB.add(copyBtn, cc.xy(1, 5)); stackTracePanel = innerPB.getPanel(); stackTracePanel.setVisible(false); pb.add(moreBtn, cc.xyw(1, y, 4)); y += 2; pb.add(stackTracePanel, cc.xyw(1, y, 4)); y += 2; ByteArrayOutputStream baos = new ByteArrayOutputStream(); exception.printStackTrace(new PrintStream(baos)); stackTraceTA.setText(baos.toString()); moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (stackTracePanel.isVisible()) { stackTracePanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } else { stackTracePanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (dlg != null) { dlg.pack(); } } }); copyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String taskName = getTaskName(); FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(), stackTraceTA.getText(), cls.getName()); NameValuePair[] pairs = createPostParameters(item); StringBuilder sb = new StringBuilder(); for (NameValuePair pair : pairs) { if (!pair.getName().equals("bug")) { sb.append(pair.getName()); sb.append(": "); if (pair.getName().equals("comments") || pair.getName().equals("stack_trace")) { sb.append("\n"); } sb.append(pair.getValue()); sb.append("\n"); } } // Copy to Clipboard UIHelper.setTextToClipboard(sb.toString()); } }); pb.setDefaultDialogBorder(); dlg = new CustomDialog((Frame) null, getResourceString("UnhandledExceptionTitle"), true, CustomDialog.OK_BTN, pb.getPanel()); dlg.setOkLabel(getResourceString("UNHDL_EXCP_SEND")); dlg.createUI(); stackTracePanel.setVisible(false); centerAndShow(dlg); String taskName = getTaskName(); FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(), stackTraceTA.getText(), cls.getName()); return item; }