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:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);// w ww . j av a 2s . c om //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
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 ww .ja va 2 s.c o 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:com.polivoto.vistas.Charts.java
private JPanel hacerTabla(Pregunta pregunta, List<Opcion> opciones, String perfil) { Tabla panel = new Tabla(); //Panel completo //scrollPanel.setBackground(Color.blue); //Ttulo pregunta JLabel tituloPregunta = new JLabel("\t" + pregunta.getTitulo() + " (" + perfil + ")"); tituloPregunta.setFont(new Font("Roboto", 1, 24)); tituloPregunta.setForeground(Color.black); tituloPregunta.setVerticalAlignment(JLabel.CENTER); JPanel panelHeader = panel.getjPanelHead(); panelHeader.add(tituloPregunta);// w ww . j av a2s. com panelHeader.setOpaque(false); panelHeader.setPreferredSize(panelGrafica.getSize()); //Panel de la tabla JPanel tabla = new JPanel(new GridLayout(pregunta.obtenerCantidadDeOpciones() + 2, 3, 5, 5)); tabla.setBackground(Color.white); //Poner el titulo de cada columna for (int i = 0; i < 3; i++) { JPanel tilt = new JPanel(); tilt.setBackground(new Color(137, 36, 31)); JLabel label = new JLabel(i == 0 ? "Opcion" : i == 2 ? "Porcentaje" : "Cantidad"); label.setFont(new Font("Roboto", 1, 18)); label.setForeground(Color.white); tilt.add(label); tilt.setSize(new Dimension(0, 35)); tilt.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); tabla.add(tilt); } int sum = 0; for (Opcion opcion : opciones) { sum += opcion.getCantidad(); } for (Opcion opc : opciones) { JPanel p1 = new JPanel(new GridLayout(0, 1)); p1.setBackground(Color.white); p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JTextArea l1 = new JTextArea(opc.getNombre()); l1.setWrapStyleWord(true); l1.setLineWrap(true); l1.setFont(new Font("Roboto", 0, 18)); l1.setEditable(false); l1.setBorder(null); p1.setPreferredSize(l1.getSize()); p1.add(l1); tabla.add(p1); JPanel p2 = new JPanel(); p2.setBackground(Color.white); p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l2 = new JLabel("" + opc.getCantidad()); l2.setFont(new Font("Roboto", 0, 18)); p2.add(l2); tabla.add(p2); JPanel p3 = new JPanel(); p3.setBackground(Color.white); p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); double porcentaje = (opc.getCantidad() * 100.0) / sum; JLabel l3 = new JLabel(String.format("%.2f", porcentaje) + "%"); l3.setFont(new Font("Roboto", 0, 18)); p3.add(l3); tabla.add(p3); } JPanel p1 = new JPanel(); p1.setBackground(Color.white); p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l1 = new JLabel("Total"); l1.setHorizontalTextPosition(JLabel.LEFT); l1.setFont(new Font("Roboto", 1, 18)); p1.add(l1); tabla.add(p1); JPanel p2 = new JPanel(); p2.setBackground(Color.white); p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l2 = new JLabel("" + sum); l2.setFont(new Font("Roboto", 1, 18)); p2.add(l2); tabla.add(p2); JPanel p3 = new JPanel(); p3.setBackground(Color.white); p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l3 = new JLabel("100.00%"); l3.setFont(new Font("Roboto", 1, 18)); p3.add(l3); tabla.add(p3); panel.getjPanelContent().add(tabla, BorderLayout.CENTER); //Relleno JPanel x = new JPanel(new GridLayout()); x.setPreferredSize(new Dimension(100, 0)); x.setBackground(Color.white); panel.getjPanelContent().add(x, BorderLayout.LINE_START); JPanel y = new JPanel(new GridLayout()); y.setPreferredSize(new Dimension(100, 0)); y.setBackground(Color.white); panel.getjPanelContent().add(y, BorderLayout.LINE_END); JPanel z = new JPanel(new GridLayout()); z.setBackground(Color.white); z.setPreferredSize(new Dimension(0, 40)); panel.getjPanelContent().add(z, BorderLayout.PAGE_END); return panel; }
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 www. java2 s . co m 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:ConfigFiles.java
public ConfigFiles(Dimension screensize) { // initializeFileBrowser(); paths = new JPanel(); paths.setBackground(Color.WHITE); //paths.setBorder(BorderFactory.createTitledBorder("Paths")); paths.setLayout(null);//from w w w . ja v a 2 s .co m paths.setPreferredSize(new Dimension(930, 1144)); paths.setSize(new Dimension(930, 1144)); paths.setMinimumSize(new Dimension(930, 1144)); paths.setMaximumSize(new Dimension(930, 1144)); //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); setLayout(null); ttcpath = new JTextField(); addPanel("TestCase Source Path", "Master directory with the test cases that can" + " be run by the framework", ttcpath, RunnerRepository.TESTSUITEPATH, 10, true, null); tMasterXML = new JTextField(); tUsers = new JTextField(); addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY, 83, true, null); tSuites = new JTextField(); addPanel("Predefined Suites Path", "Location of predefined suites", tSuites, RunnerRepository.PREDEFINEDSUITES, 156, true, null); testconfigpath = new JTextField(); addPanel("Test Configuration Path", "Test Configuration path", testconfigpath, RunnerRepository.TESTCONFIGPATH, 303, true, null); tepid = new JTextField(); addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid, RunnerRepository.REMOTEEPIDDIR, 595, true, null); tlog = new JTextField(); addPanel("Logs Path", "Location of the directory that stores the most recent log files." + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null); tsecondarylog = new JTextField(); JPanel p = addPanel("Secondary Logs Path", "Location of the directory that archives copies of the most recent log files, with" + " original file names appended with <.epoch time>", tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null); logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED)); logsenabled.setBackground(Color.WHITE); p.add(logsenabled); JPanel p7 = new JPanel(); p7.setBackground(Color.WHITE); TitledBorder border7 = BorderFactory.createTitledBorder("Log Files"); border7.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p7.setBorder(border7); p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS)); p7.setBounds(80, 740, 800, 190); paths.add(p7); JTextArea log2 = new JTextArea("All the log files that will be monitored"); log2.setWrapStyleWord(true); log2.setLineWrap(true); log2.setEditable(false); log2.setCursor(null); log2.setOpaque(false); log2.setFocusable(false); log2.setBorder(null); log2.setFont(new Font("Arial", Font.PLAIN, 12)); log2.setBackground(getBackground()); log2.setMaximumSize(new Dimension(170, 25)); log2.setPreferredSize(new Dimension(170, 25)); JPanel p71 = new JPanel(); p71.setBackground(Color.WHITE); p71.setLayout(new GridLayout()); p71.setMaximumSize(new Dimension(700, 13)); p71.setPreferredSize(new Dimension(700, 13)); p71.add(log2); JPanel p72 = new JPanel(); p72.setBackground(Color.WHITE); p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS)); trunning = new JTextField(); p72.add(addField(trunning, "Running: ", 0)); tdebug = new JTextField(); p72.add(addField(tdebug, "Debug: ", 1)); tsummary = new JTextField(); p72.add(addField(tsummary, "Summary: ", 2)); tinfo = new JTextField(); p72.add(addField(tinfo, "Info: ", 3)); tcli = new JTextField(); p72.add(addField(tcli, "Cli: ", 4)); p7.add(p71); p7.add(p72); libpath = new JTextField(); addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true, null); JPanel p8 = new JPanel(); p8.setBackground(Color.WHITE); TitledBorder border8 = BorderFactory.createTitledBorder("File"); border8.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p8.setBorder(border8); p8.setLayout(null); p8.setBounds(80, 1076, 800, 50); if (PermissionValidator.canChangeFWM()) { paths.add(p8); } JButton save = new JButton("Save"); save.setToolTipText("Save and automatically load config"); save.setBounds(490, 20, 70, 20); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { saveXML(false, "fwmconfig"); loadConfig("fwmconfig.xml"); } }); p8.add(save); // if(!PermissionValidator.canChangeFWM()){ // save.setEnabled(false); // } JButton saveas = new JButton("Save as"); saveas.setBounds(570, 20, 90, 20); saveas.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name"); if (!filename.equals("NULL")) { saveXML(false, filename); } } }); p8.add(saveas); final JButton loadXML = new JButton("Load Config"); loadXML.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { String[] configs = RunnerRepository .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/"); JComboBox combo = new JComboBox(configs); int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null); final String config; if (resp == JOptionPane.OK_OPTION) config = combo.getSelectedItem().toString(); else config = null; if (config != null) { new Thread() { public void run() { setEnabledTabs(false); JFrame progress = new JFrame(); progress.setAlwaysOnTop(true); progress.setLocation((int) loadXML.getLocationOnScreen().getX(), (int) loadXML.getLocationOnScreen().getY()); progress.setUndecorated(true); JProgressBar bar = new JProgressBar(); bar.setIndeterminate(true); progress.add(bar); progress.pack(); progress.setVisible(true); loadConfig(config); progress.dispose(); setEnabledTabs(true); } }.start(); } } catch (Exception e) { e.printStackTrace(); } } }); loadXML.setBounds(670, 20, 120, 20); p8.add(loadXML); // if(!PermissionValidator.canChangeFWM()){ // loadXML.setEnabled(false); // } tdbfile = new JTextField(); addPanel("Database XML path", "File location for database configuration", tdbfile, RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true, null); temailfile = new JTextField(); // emailpanel = (JPanel) addPanel("Email XML path", "File location for email configuration", temailfile, RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null) .getParent(); //paths.remove(emailpanel); // emailpanel.setBounds(360,440,350,100); // RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel); tglobalsfile = new JTextField(); addPanel("Globals XML file", "File location for globals parameters", tglobalsfile, RunnerRepository.GLOBALSREMOTEFILE, 521, true, null); tceport = new JTextField(); addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(), 1003, false, null); // traPort = new JTextField(); // addPanel("Resource Allocator Port","Resource Allocator Port", // traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null); // thttpPort = new JTextField(); // addPanel("HTTP Server Port","HTTP Server Port",thttpPort, // RunnerRepository.getHTTPServerPort(),740,false,null); //paths.add(loadXML); if (!PermissionValidator.canChangeFWM()) { ttcpath.setEnabled(false); tMasterXML.setEnabled(false); tUsers.setEnabled(false); tepid.setEnabled(false); tSuites.setEnabled(false); tlog.setEnabled(false); trunning.setEnabled(false); tdebug.setEnabled(false); tsummary.setEnabled(false); tinfo.setEnabled(false); tcli.setEnabled(false); tdbfile.setEnabled(false); temailfile.setEnabled(false); tceport.setEnabled(false); libpath.setEnabled(false); tsecondarylog.setEnabled(false); testconfigpath.setEnabled(false); tglobalsfile.setEnabled(false); logsenabled.setEnabled(false); } }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Show the TextMessage in a JTextArea./*w ww .ja v a 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:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java
/** * Build frame.// w ww .ja va 2 s. c o m */ private void build() { setTitle("Proprits de l'objet " + objetSchema.getId()); setSize(700, 400); setResizable(false); setLocationRelativeTo(mainFrame); if (mainFrame != null) setIconImage(mainFrame.getIconImage()); // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Description - JTextArea textAreaValues = new JTextArea("Vous pouvez apporter des modifications sur les paramtres" + " de cet objet d'identifiant " + objetSchema.getId() + ". Les" + " modifications apportes des paramtres non-cochs ne" + " seront pas prises en compte."); textAreaValues.setEditable(false); textAreaValues.setLineWrap(true); textAreaValues.setWrapStyleWord(true); textAreaValues.setFont((new JLabel()).getFont()); textAreaValues.setBorder(BorderFactory.createEmptyBorder(7, 8, 7, 8)); textAreaValues.setBackground((new JLabel()).getBackground()); // - La table des valeurs - // Correction : Tri alphabtique des valeurs Enumeration<String> k = values.keys(); String[] keys = new String[values.size()]; for (int i = 0; i < keys.length; i++) keys[i] = k.nextElement(); Arrays.sort(keys); JPanel colonne1 = new JPanel(new GridLayout(keys.length, 1)); JPanel colonne2 = new JPanel(new GridLayout(keys.length, 1)); // Enumeration<JComponent> l = labels.elements(); // Enumeration<JComponent> v = values.elements(); // Enumeration<String> k = values.keys(); // JPanel colonne1 = new JPanel( new GridLayout( values.size(), 1 ) ); // JPanel colonne2 = new JPanel( new GridLayout( values.size(), 1 ) ); for (int i = 0; keys != null && i < keys.length; i++) { // while( l.hasMoreElements() && v.hasMoreElements() && k.hasMoreElements() ) { String key = keys[i]; JComponent label = labels.get(key); JComponent value = values.get(key); JCheckBox checkbox = valuesPresent.get(key); // String key = k.nextElement(); // JComponent label = l.nextElement(); // JComponent value = v.nextElement(); // JCheckBox checkbox = valuesPresent.get( key ); if (!value.isEnabled() && value instanceof JTextField) { //value.setEnabled( true ); JButton b = new JButton("..."); b.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, Color.white), b.getBorder())); b.addActionListener(new SchemaValueEditorLauncher(b, (JTextField) value, objetSchema, key)); JPanel tmp = new JPanel(new BorderLayout()); tmp.add(value, BorderLayout.CENTER); tmp.add(b, BorderLayout.EAST); tmp.setOpaque(false); value = tmp; } JPanel panelTmp1 = new JPanel(new BorderLayout()); panelTmp1.add(checkbox, BorderLayout.WEST); panelTmp1.add(label, BorderLayout.CENTER); panelTmp1.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 3)); colonne1.add(panelTmp1); JPanel panelTmp2 = new JPanel(new BorderLayout()); panelTmp2.add(value, BorderLayout.CENTER); panelTmp2.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); colonne2.add(panelTmp2); checkbox.setOpaque(false); label.setOpaque(false); value.setOpaque(false); panelTmp1.setOpaque(false); panelTmp2.setOpaque(false); } JPanel tablePanel = new JPanel(new BorderLayout()); tablePanel.add(colonne1, BorderLayout.WEST); tablePanel.add(colonne2, BorderLayout.EAST); tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); colonne1.setOpaque(false); colonne2.setOpaque(false); tablePanel.setOpaque(false); JPanel tablePanelContainer = new JPanel(new BorderLayout()); tablePanelContainer.add(tablePanel, BorderLayout.NORTH); tablePanelContainer.setBackground(Color.white); JList tmpForBorderList = new JList(); JScrollPane tmpForBorderScroller = new JScrollPane(tmpForBorderList); JScrollPane tableScroller = new JScrollPane(tablePanelContainer); //tableScroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); tableScroller.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 6, 1, 6), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Listes des paramtres "), BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5), tmpForBorderScroller.getBorder())))); // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(textAreaValues, BorderLayout.NORTH); mainPanel.add(tableScroller, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.CENTER); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(mainPanelContainer); // - Listeners - addWindowListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.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 Plot1DHelpProvider(); 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 ww w . j a v a 2s. c o m 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:UI.SecurityDashboard.java
private void performMetric4(MainViewPanel mvp) { Metric4 metric4 = new Metric4(); JPanel graphPanel4 = new JPanel(); graphPanel4.setLayout(new BorderLayout()); metric4.run();//w w w . j av a 2s. c o m graphPanel4.add(mvp.getPanel4(metric4), BorderLayout.CENTER); MalwarePanel.setLayout(new BorderLayout()); JTextArea header = new JTextArea( "\nThe Malware detection will scan for viruses, trojans, and worms that may have affected a device.\n"); header.setLineWrap(true); header.setWrapStyleWord(true); header.setEditable(false); MalwarePanel.add(header, BorderLayout.NORTH); if (metric4.getTotalCount() == 0) { Font noMalwareFont = new Font("Calibri", Font.BOLD, 40); JLabel noMalwareLabel = new JLabel( " No Malware Detected"); noMalwareLabel.setFont(noMalwareFont); noMalwareLabel.setPreferredSize(new Dimension(WIDTH, 100)); graphPanel4.add(noMalwareLabel, BorderLayout.NORTH); JPanel emptyPanel = new JPanel(); emptyPanel.setPreferredSize(new Dimension(50, 200)); emptyPanel.setOpaque(true); graphPanel4.add(emptyPanel, BorderLayout.SOUTH); } MalwarePanel.add(graphPanel4, BorderLayout.CENTER); ChartPanel fourthPanel = mvp.getPanel4(metric4); fourthPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent cme) { dashboardTabs.setSelectedIndex(4); } @Override public void chartMouseMoved(ChartMouseEvent cme) { } }); Metric4Panel.setLayout(new BorderLayout()); Font titleFont = new Font("Calibri", Font.BOLD, 27); JLabel malwareTitleLabel = new JLabel(" Malware Detection"); malwareTitleLabel.setFont(titleFont); Metric4Panel.add(malwareTitleLabel, BorderLayout.PAGE_START); Metric4Panel.add(fourthPanel, BorderLayout.CENTER); if (metric4.getTotalCount() == 0) { Font noMalwareFont = new Font("Calibri", Font.BOLD, 20); JLabel noMalwareLabel = new JLabel(" No Malware Detected"); noMalwareLabel.setFont(noMalwareFont); Metric4Panel.add(noMalwareLabel, BorderLayout.SOUTH); } Metric4Panel.setBackground(Color.white); }
From source file:UI.SecurityDashboard.java
private void performMetric9() { GZDecompression m9 = new GZDecompression(); String[][] counts = m9.getMetric9(); Font titleFont = new Font("Calibri", Font.BOLD, 27); JLabel logAuditTitleLabel = new JLabel(" Log Audit"); logAuditTitleLabel.setFont(titleFont); AreaChart areaChart = new AreaChart(m9.getLogCount(), m9.getSuccessCount(), m9.getFailCount()); ChartPanel thisChart = areaChart.drawAreaChart(); thisChart.setBackground(Color.white); thisChart.addChartMouseListener(new ChartMouseListener() { @Override/* w w w.j a v a 2 s. c om*/ public void chartMouseClicked(ChartMouseEvent cme) { dashboardTabs.setSelectedIndex(9); } @Override public void chartMouseMoved(ChartMouseEvent cme) { } }); Metric9Panel.setBackground(Color.WHITE); Metric9Panel.setLayout(new BorderLayout()); Metric9Panel.add(logAuditTitleLabel, BorderLayout.NORTH); Metric9Panel.add(thisChart, BorderLayout.CENTER); Metric9Panel.setEnabled(false); String[] columns = { "Log Failure" }; JTable table = new JTable(counts, columns); table.setShowHorizontalLines(true); table.setRowHeight(40); table.setEnabled(false); JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); AuditPanel.setLayout(new BorderLayout()); JTextArea header = new JTextArea( "\nThrough the analysis of security logs, this page will show an audit of the attack attempts and " + "security breaches. The logs provide critical information related to system events that can be used to track suspicicous " + "activities.\n"); header.setLineWrap(true); header.setWrapStyleWord(true); header.setEditable(false); AuditPanel.add(header, BorderLayout.NORTH); AuditPanel.add(tableScrollPane, BorderLayout.CENTER); }