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:pcgen.gui2.dialog.AboutDialog.java
/** * Construct the awards panel. This panel shows each award * the pcgen project has been awarded/*from ww w .jav a 2 s . c om*/ * * @return The awards panel. */ private JPanel buildAwardsPanel() { JScrollPane sp = new JScrollPane(); JPanel panel = new JPanel(); JPanel aPanel = new JPanel(); aPanel.setLayout(new GridBoxLayout(2, 2)); aPanel.setBackground(Color.WHITE); Icon goldIcon = Icons.createImageIcon("gold200x200-2005.gif"); if (goldIcon != null) { JLabel e2005 = new JLabel(goldIcon); aPanel.add(e2005); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2005_ennie")); aPanel.add(title); } Icon bronzeIcon = Icons.createImageIcon("bronze200x200-2003.gif"); if (bronzeIcon != null) { JLabel e2003 = new JLabel(bronzeIcon); aPanel.add(e2003); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2003_ennie")); aPanel.add(title); } sp.setViewportView(aPanel); panel.add(sp, BorderLayout.CENTER); return panel; }
From source file:plpwr.Task3.java
/*** * @link http://stackoverflow.com/a/18068820/781312 *//* ww w . j a v a 2 s . c o m*/ public Task3() throws Throwable { Reader filereader; try { File[] files = {}; // files= new Task2.FileDialogFluent(Window.getWindow(), "Choose file", FileDialog.LOAD).setVisibleFluent(true).getFiles(); File file = files[0]; filereader = new FileReader(file); } catch (Throwable t) { String input = "name,dateOfBirth,dept,jobTitle\n" + "John,1962-11-24,accounting,senior accountant\n" + "Tina,1962-09-26,administration,manager\n" + "Karen,1972-01-10, marketing,graphic designer\n" + "Michael,1978-02-11,research,programmer\n" + "Sandra,1976-10-26,marketing,account manager"; filereader = new StringReader(input); } CSVReader reader = new CSVReader(filereader); List<String[]> rows = reader.readAll(); String header[] = rows.remove(0); System.out.println(StringUtils.join(header, '\t')); for (String[] str : rows) { System.out.println(StringUtils.join(str, '\t')); } DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element el = doc.createElement("employees"); for (String[] row : rows) { Element e = doc.createElement("employee"); for (int i = 0; i < row.length; i++) { System.out.println("ROW" + row[i]); Element a = doc.createElement(header[i]); a.appendChild(doc.createTextNode(row[i])); e.appendChild(a); } el.appendChild(e); } doc.appendChild(el); JTextArea msg = new JTextArea(App.formatDocument(doc)); msg.setLineWrap(true); msg.setWrapStyleWord(true); showDialog(null, msg); }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getDescriptionPanel() { if (descriptionPanel == null) { descriptionPanel = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true);/* w ww. java2s .co m*/ ta.setWrapStyleWord(true); connect(_conceptContext, "/description", ta); ta.setBorder(BorderFactory.createEtchedBorder()); descriptionPanel.add(ta, BorderLayout.CENTER); } return descriptionPanel; }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getPurposePanel() { if (purposePanel == null) { purposePanel = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true);//from w w w . j a v a 2 s. co m ta.setWrapStyleWord(true); String lang = _controller.getCurrentGuideLanguageCode(); connect(_descriptionContext, "/details/" + lang + "/purpose", ta); ta.setBorder(BorderFactory.createEtchedBorder()); purposePanel.add(ta, BorderLayout.CENTER); } return purposePanel; }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getUsePanel() { if (usePanel == null) { usePanel = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true);/* www. j a v a2 s . co m*/ ta.setWrapStyleWord(true); String lang = _controller.getCurrentGuideLanguageCode(); connect(_descriptionContext, "/details/" + lang + "/use", ta); ta.setBorder(BorderFactory.createEtchedBorder()); usePanel.add(ta, BorderLayout.CENTER); } return usePanel; }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getMisusePanel() { if (misusePanel == null) { misusePanel = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true);/*from w ww .ja v a 2s .co m*/ ta.setWrapStyleWord(true); String lang = _controller.getCurrentGuideLanguageCode(); connect(_descriptionContext, "/details/" + lang + "/misuse", ta); ta.setBorder(BorderFactory.createEtchedBorder()); misusePanel.add(ta, BorderLayout.CENTER); } return misusePanel; }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getReferencePanel() { if (references == null) { references = new JPanel(new BorderLayout()); JTextArea ta = new JTextArea(); ta.setLineWrap(true);//from w w w . j a v a 2 s . c o m ta.setWrapStyleWord(true); connect(_descriptionContext, "/otherDetails/references", ta); ta.setBorder(BorderFactory.createEtchedBorder()); references.add(ta, BorderLayout.CENTER); } return references; }
From source file:semgen.extraction.RadialGraph.Clusterer.java
public String clusterAndRecolor(AggregateLayout<String, Number> layout, int numEdgesToRemove, Color[] colors, boolean groupClusters) { setCursor(new Cursor(Cursor.WAIT_CURSOR)); String moduletable = ""; Graph<String, Number> g = layout.getGraph(); layout.removeAll();/*from ww w .ja va 2 s. c om*/ EdgeBetweennessClusterer<String, Number> clusterer = new EdgeBetweennessClusterer<String, Number>( numEdgesToRemove); Set<Set<String>> clusterSet = clusterer.transform(g); List<Number> edges = clusterer.getEdgesRemoved(); sempanel.removeAll(); int i = 0; // Set the colors of each node so that each cluster's vertices have the same color extractor.clusterpanel.checkboxpanel.removeAll(); for (Iterator<Set<String>> cIt = clusterSet.iterator(); cIt.hasNext();) { moduletable = moduletable + "\nCLUSTER " + (i + 1); Set<String> vertices = cIt.next(); Color c = colors[i % colors.length]; Set<DataStructure> datastrs = new HashSet<DataStructure>(); for (String vertex : vertices) { datastrs.add(extractor.semsimmodel.getDataStructure(vertex)); } JLabel modulelabel = new JLabel("Cluster " + (i + 1)); modulelabel.setOpaque(true); modulelabel.setFont(SemGenFont.defaultBold()); modulelabel.setBackground(c); modulelabel.setAlignmentX(LEFT_ALIGNMENT); sempanel.add(modulelabel); // Update the semantics panel Set<String> addedterms = new HashSet<String>(); for (String ver : vertices) { if (extractor.semsimmodel.getDataStructure(ver).hasPhysicalProperty()) { if (extractor.semsimmodel.getDataStructure(ver).getPhysicalProperty() .getPhysicalPropertyOf() != null) { PhysicalModelComponent pmc = extractor.semsimmodel.getDataStructure(ver) .getPhysicalProperty().getPhysicalPropertyOf(); String name = null; if (pmc.hasRefersToAnnotation()) { name = pmc.getFirstRefersToReferenceOntologyAnnotation().getValueDescription(); } else { name = pmc.getName(); } if (!addedterms.contains(name)) { addedterms.add(name); JTextArea enttext = new JTextArea(name); enttext.setOpaque(true); enttext.setBackground(c); enttext.setFont(SemGenFont.defaultPlain(-2)); if (pmc instanceof PhysicalProcess) { enttext.setFont(SemGenFont.defaultItalic(-2)); name = "Process: " + name; } else name = "Entity: " + name; enttext.setWrapStyleWord(true); enttext.setLineWrap(true); enttext.setBorder(BorderFactory.createEmptyBorder(7, 7, 0, 0)); enttext.setAlignmentX(LEFT_ALIGNMENT); sempanel.add(enttext); moduletable = moduletable + "\n " + name; } } } } sempanel.validate(); sempanel.repaint(); semscroller.repaint(); semscroller.validate(); this.repaint(); this.validate(); colorCluster(vertices, c); ExtractorJCheckBox box = new ExtractorJCheckBox("Cluster " + (i + 1), datastrs); box.setBackground(c); box.setOpaque(true); box.addItemListener(extractor); extractor.clusterpanel.checkboxpanel.add(box); if (groupClusters == true) groupCluster(layout, vertices); i++; } refreshModulePanel(); for (Number e : g.getEdges()) { if (edges.contains(e)) edgePaints.put(e, Color.lightGray); else edgePaints.put(e, Color.black); } nummodules = i; setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return moduletable; }
From source file:storybook.toolkit.swing.SwingUtil.java
public static JPanel createNotesPanel(JTextArea taNotes) { MigLayout layout = new MigLayout("fill", "", "[top]"); JPanel panel = new JPanel(layout); taNotes.setLineWrap(true);/*from w w w.j av a 2 s. c o m*/ taNotes.setWrapStyleWord(true); taNotes.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); JScrollPane scroller = new JScrollPane(taNotes); scroller.setPreferredSize(new Dimension(400, 400)); panel.add(scroller, "grow"); return panel; }
From source file:tvbrowser.TVBrowser.java
/** * Entry point of the application//from w ww.ja v a2 s . c o m * @param args The arguments given in the command line. */ public static void main(String[] args) { // Read the command line parameters parseCommandline(args); try { Toolkit.getDefaultToolkit().setDynamicLayout( (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.dynamicLayoutSupported")); } catch (Exception e) { e.printStackTrace(); } mLocalizer = util.ui.Localizer.getLocalizerFor(TVBrowser.class); // Check whether the TV-Browser was started in the right directory if (!new File("imgs").exists()) { String msg = "Please start TV-Browser in the TV-Browser directory!"; if (mLocalizer != null) { msg = mLocalizer.msg("error.2", "Please start TV-Browser in the TV-Browser directory!"); } JOptionPane.showMessageDialog(null, msg); System.exit(1); } if (mIsTransportable) { System.getProperties().remove("propertiesfile"); } // setup logging // Get the default Logger Logger mainLogger = Logger.getLogger(""); // Use a even simpler Formatter for console logging mainLogger.getHandlers()[0].setFormatter(createFormatter()); if (mIsTransportable) { File settingsDir = new File("settings"); try { File test = File.createTempFile("write", "test", settingsDir); test.delete(); } catch (IOException e) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e1) { //ignore } JTextArea area = new JTextArea(mLocalizer.msg("error.noWriteRightsText", "You are using the transportable version of TV-Browser but you have no writing rights in the settings directory:\n\n{0}'\n\nTV-Browser will be closed.", settingsDir.getAbsolutePath())); area.setFont(new JLabel().getFont()); area.setFont(area.getFont().deriveFont((float) 14).deriveFont(Font.BOLD)); area.setLineWrap(true); area.setWrapStyleWord(true); area.setPreferredSize(new Dimension(500, 100)); area.setEditable(false); area.setBorder(null); area.setOpaque(false); JOptionPane.showMessageDialog(null, area, mLocalizer.msg("error.noWriteRightsTitle", "No write rights in settings directory"), JOptionPane.ERROR_MESSAGE); System.exit(1); } } // Load the settings Settings.loadSettings(); Locale.setDefault(new Locale(Settings.propLanguage.getString(), Settings.propCountry.getString())); if (Settings.propFirstStartDate.getDate() == null) { Settings.propFirstStartDate.setDate(Date.getCurrentDate()); } if (!createLockFile()) { updateLookAndFeel(); showTVBrowserIsAlreadyRunningMessageBox(); } String logDirectory = Settings.propLogdirectory.getString(); if (logDirectory != null) { try { File logDir = new File(logDirectory); logDir.mkdirs(); mainLogger.addHandler( new FileLoggingHandler(logDir.getAbsolutePath() + "/tvbrowser.log", createFormatter())); } catch (IOException exc) { String msg = mLocalizer.msg("error.4", "Can't create log file."); ErrorHandler.handle(msg, exc); } } else { // if no logging is configured, show WARNING or worse for normal usage, show everything for unstable versions if (TVBrowser.isStable()) { mainLogger.setLevel(Level.WARNING); } } // log warning for OpenJDK users if (!isJavaImplementationSupported()) { mainLogger.warning(SUN_JAVA_WARNING); } //Update plugin on version change if (Settings.propTVBrowserVersion.getVersion() != null && VERSION.compareTo(Settings.propTVBrowserVersion.getVersion()) > 0) { updateLookAndFeel(); updatePluginsOnVersionChange(); } // Capture unhandled exceptions //System.setErr(new PrintStream(new MonitoringErrorStream())); String timezone = Settings.propTimezone.getString(); if (timezone != null) { TimeZone.setDefault(TimeZone.getTimeZone(timezone)); } mLog.info("Using timezone " + TimeZone.getDefault().getDisplayName()); // refresh the localizers because we know the language now Localizer.emptyLocalizerCache(); mLocalizer = Localizer.getLocalizerFor(TVBrowser.class); ProgramInfo.resetLocalizer(); ReminderPlugin.resetLocalizer(); Date.resetLocalizer(); ProgramFieldType.resetLocalizer(); // Set the proxy settings updateProxySettings(); // Set the String to use for indicating the user agent in http requests System.setProperty("http.agent", MAINWINDOW_TITLE); Version tmpVer = Settings.propTVBrowserVersion.getVersion(); final Version currentVersion = tmpVer != null ? new Version(tmpVer.getMajor(), tmpVer.getMinor(), Settings.propTVBrowserVersionIsStable.getBoolean()) : tmpVer; /*TODO Create an update service for installed TV data services that doesn't * work with TV-Browser 3.0 and updates for them are known. */ if (!isTransportable() && Launch.isOsWindowsNtBranch() && currentVersion != null && currentVersion.compareTo(new Version(3, 0, true)) < 0) { String tvDataDir = Settings.propTVDataDirectory.getString().replace("/", File.separator); if (!tvDataDir.startsWith(System.getenv("appdata"))) { StringBuilder oldDefaultTvDataDir = new StringBuilder(System.getProperty("user.home")) .append(File.separator).append("TV-Browser").append(File.separator).append("tvdata"); if (oldDefaultTvDataDir.toString().equals(tvDataDir)) { Settings.propTVDataDirectory.setString(Settings.propTVDataDirectory.getDefault()); } } } Settings.propTVBrowserVersion.setVersion(VERSION); Settings.propTVBrowserVersionIsStable.setBoolean(VERSION.isStable()); final Splash splash; if (mShowSplashScreen && Settings.propSplashShow.getBoolean()) { splash = new SplashScreen(Settings.propSplashImage.getString(), Settings.propSplashTextPosX.getInt(), Settings.propSplashTextPosY.getInt(), Settings.propSplashForegroundColor.getColor()); } else { splash = new DummySplash(); } splash.showSplash(); /* Initialize the MarkedProgramsList */ MarkedProgramsList.getInstance(); /*Maybe there are tvdataservices to install (.jar.inst files)*/ PluginLoader.getInstance().installPendingPlugins(); PluginLoader.getInstance().loadAllPlugins(); mLog.info("Loading TV listings service..."); splash.setMessage(mLocalizer.msg("splash.dataService", "Loading TV listings service...")); TvDataServiceProxyManager.getInstance().init(); ChannelList.createForTvBrowserStart(); ChannelList.initSubscribedChannels(); if (!lookAndFeelInitialized) { mLog.info("Loading Look&Feel..."); splash.setMessage(mLocalizer.msg("splash.laf", "Loading look and feel...")); updateLookAndFeel(); } mLog.info("Loading plugins..."); splash.setMessage(mLocalizer.msg("splash.plugins", "Loading plugins...")); try { PluginProxyManager.getInstance().init(); } catch (TvBrowserException exc) { ErrorHandler.handle(exc); } splash.setMessage(mLocalizer.msg("splash.tvData", "Checking TV database...")); mLog.info("Checking TV listings inventory..."); TvDataBase.getInstance().checkTvDataInventory(); mLog.info("Starting up..."); splash.setMessage(mLocalizer.msg("splash.ui", "Starting up...")); Toolkit.getDefaultToolkit().getSystemEventQueue().push(new TextComponentPopupEventQueue()); // Init the UI final boolean fStartMinimized = Settings.propMinimizeAfterStartup.getBoolean() || mMinimized; SwingUtilities.invokeLater(new Runnable() { public void run() { initUi(splash, fStartMinimized); new Thread("Start finished callbacks") { public void run() { setPriority(Thread.MIN_PRIORITY); mLog.info("Deleting expired TV listings..."); TvDataBase.getInstance().deleteExpiredFiles(1, false); // first reset "starting" flag of mainframe mainFrame.handleTvBrowserStartFinished(); // initialize program info for fast reaction to program table click ProgramInfo.getInstance().handleTvBrowserStartFinished(); // load reminders and favorites ReminderPlugin.getInstance().handleTvBrowserStartFinished(); FavoritesPlugin.getInstance().handleTvBrowserStartFinished(); // now handle all plugins and services GlobalPluginProgramFormatingManager.getInstance(); PluginProxyManager.getInstance().fireTvBrowserStartFinished(); TvDataServiceProxyManager.getInstance().fireTvBrowserStartFinished(); // finally submit plugin caused updates to database TvDataBase.getInstance().handleTvBrowserStartFinished(); startPeriodicSaveSettings(); } }.start(); SwingUtilities.invokeLater(new Runnable() { public void run() { ChannelList.completeChannelLoading(); initializeAutomaticDownload(); if (Launch.isOsWindowsNtBranch()) { try { RegistryKey desktopSettings = new RegistryKey(RootKey.HKEY_CURRENT_USER, "Control Panel\\Desktop"); RegistryValue autoEnd = desktopSettings.getValue("AutoEndTasks"); if (autoEnd.getData().equals("1")) { RegistryValue killWait = desktopSettings.getValue("WaitToKillAppTimeout"); int i = Integer.parseInt(killWait.getData().toString()); if (i < 5000) { JOptionPane pane = new JOptionPane(); String cancel = mLocalizer.msg("registryCancel", "Close TV-Browser"); String dontDoIt = mLocalizer.msg("registryJumpOver", "Not this time"); pane.setOptions(new String[] { Localizer.getLocalization(Localizer.I18N_OK), dontDoIt, cancel }); pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(mLocalizer.msg("registryWarning", "The fast shutdown of Windows is activated.\nThe timeout to wait for before Windows is closing an application is too short,\nto give TV-Browser enough time to save all settings.\n\nThe setting hasn't the default value. It was changed by a tool or by you.\nTV-Browser will now try to change the timeout.\n\nIf you don't want to change this timeout select 'Not this time' or 'Close TV-Browser'.")); pane.setInitialValue(mLocalizer.msg("registryCancel", "Close TV-Browser")); JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(mainFrame), UIManager.getString("OptionPane.messageDialogTitle")); d.setModal(true); UiUtilities.centerAndShow(d); if (pane.getValue() == null || pane.getValue().equals(cancel)) { mainFrame.quit(); } else if (!pane.getValue().equals(dontDoIt)) { try { killWait.setData("5000"); desktopSettings.setValue(killWait); JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryChanged", "The timeout was changed successfully.\nPlease reboot Windows!")); } catch (Exception registySetting) { JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryNotChanged", "<html>The Registry value couldn't be changed. Maybe you haven't the right to do it.<br>If it is so contact you Administrator and let him do it for you.<br><br><b><Attention:/b> The following description is for experts. If you change or delete the wrong value in the Registry you could destroy your Windows installation.<br><br>To get no warning on TV-Browser start the Registry value <b>WaitToKillAppTimeout</b> in the Registry path<br><b>HKEY_CURRENT_USER\\Control Panel\\Desktop</b> have to be at least <b>5000</b> or the value for <b>AutoEndTasks</b> in the same path have to be <b>0</b>.</html>"), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE); } } } } } catch (Throwable registry) { } } if (currentVersion != null && currentVersion.compareTo(new Version(2, 71, false)) < 0) { if (Settings.propProgramPanelMarkedMinPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMinPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMinPriorityColor.setColor(new Color(255, 0, 0, 30)); } if (Settings.propProgramPanelMarkedMediumPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMediumPriorityColor .setColor(new Color(140, 255, 0, 60)); } if (Settings.propProgramPanelMarkedHigherMediumPriorityColor.getColor().equals( Settings.propProgramPanelMarkedHigherMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedHigherMediumPriorityColor .setColor(new Color(255, 255, 0, 60)); } if (Settings.propProgramPanelMarkedMaxPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMaxPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMaxPriorityColor .setColor(new Color(255, 180, 0, 110)); } } // check if user should select picture settings if (currentVersion != null && currentVersion.compareTo(new Version(2, 22)) < 0) { TvBrowserPictureSettingsUpdateDialog.createAndShow(mainFrame); } else if (currentVersion != null && currentVersion.compareTo(new Version(2, 51, true)) < 0) { Settings.propAcceptedLicenseArrForServiceIds.setStringArray(new String[0]); } if (currentVersion != null && currentVersion.compareTo(new Version(2, 60, true)) < 0) { int startOfDay = Settings.propProgramTableStartOfDay.getInt(); int endOfDay = Settings.propProgramTableEndOfDay.getInt(); if (endOfDay - startOfDay < -1) { Settings.propProgramTableEndOfDay.setInt(startOfDay); JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("timeInfoText", "The time range of the program table was corrected because the defined day was shorter than 24 hours.\n\nIf the program table should show less than 24h use a time filter for that. That time filter can be selected\nto be the default filter by selecting it in the filter settings and pressing on the button 'Default'."), mLocalizer.msg("timeInfoTitle", "Times corrected"), JOptionPane.INFORMATION_MESSAGE); Settings.handleChangedSettings(); } } MainFrame.getInstance().getProgramTableScrollPane().requestFocusInWindow(); } }); } }); // register the shutdown hook Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook") { public void run() { deleteLockFile(); MainFrame.getInstance().quit(false); } }); }