Search Results

Search found 83 results on 4 pages for 'jtextarea'.

Page 1/4 | 1 2 3 4  | Next Page >

  • MigLayout JTextArea is not shrinking when used with linewrap=true

    - by Marcel
    Hi. If I use a JTextArea with MigLayout like this: MigLayout thisLayout = new MigLayout("", "[][grow]", "[]20[]"); this.setLayout(thisLayout); { jLabel1 = new JLabel(); this.add(jLabel1, "cell 0 0"); jLabel1.setText("jLabel1"); } { jTextArea1 = new JTextArea(); this.add(jTextArea1, "cell 0 1 2 1,growx"); jTextArea1.setText("jTextArea1"); jTextArea1.setLineWrap(false); } then the JTextArea grows and shrinks perfectly when resizing the window. When I set the linewrap to true the JTextArea is not shrinking when I make the window smaller again. I would very much appreciate any help. Thanks Marcel

    Read the article

  • How to extract the word and line wrapping information from JTextArea for text with given font

    - by Gábor Lipták
    I have to convert styled text to wrapped simple text (for SVG word wrapping). I cannot beleive that the word wrapping information (how many lines are there, where are the line breaks) cannot be extracted from the JTextArea. So I created a small frame program: package bla; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.List; import javax.swing.JTextArea; public class Example1 extends WindowAdapter { private static String content = "01234567890123456789\n" + "0123456 0123456 01234567 01234567"; JTextArea text; public Example1() { Frame f = new Frame("TextArea Example"); f.setLayout(new BorderLayout()); Font font = new Font("Serif", Font.ITALIC, 20); text = new JTextArea(); text.setFont(font); text.setForeground(Color.blue); text.setLineWrap(true); text.setWrapStyleWord(true); f.add(text, BorderLayout.CENTER); text.setText(content); // Listen for the user to click the frame's close box f.addWindowListener(this); f.setSize(100, 511); f.show(); } public static List<String> getLines( JTextArea text ) { //WHAT SHOULD I WRITE HERE return new ArrayList<String>(); } public void windowClosing(WindowEvent evt) { List<String> lines = getLines(text); System.out.println( "Number of lines:" + lines.size()); for (String line : lines) { System.out.println( line ); } System.exit(0); } public static void main(String[] args) { Example1 instance = new Example1(); } } If you run it you will see this: And what I expect as output: Number of lines:6 0123456789 0123456789 0123456 0123456 01234567 01234567 What should I write in place of the comment?

    Read the article

  • how to get selected chracter position in JTextArea?

    - by Reddy
    Hi! Here is a challenging question! Let me first tell you my scenario how am i implementing a solution to a problem. I am reading a log file and displaying it on the JTextArea. Log file is cp037 character coded. I was reading each file as a byte stream or byte array from the log file & displaying it. Anyways, i managed to display the text properly in JTextArea by cp037 character coding. Now, User may select a set of characters in the JTextArea. All i want is the position of first character of the user's selected text, from a nearest special character '+'(its character code in cp037 is 4E), which is prior to the selected text. This character may occur at several places in the JTextArea. In simple sentence, i want the first character location(of user selected text) from nearset '+' which should be occuring prior to the user's selected text. PS: cp037 is a type of character encoding scheme which is created by IBM & used for IBM Mainframes. Please fell free to ask me if the question is not clear...:-

    Read the article

  • How to limit JTextArea max Rows and Coloums?

    - by Billbo bug
    I am using JTextArea in JScrollPane I want to limit the maximum number of lines possible and the maximum chars in each line. I need that the string will be exactly like on the screen, each line will end with '\n' (if there another line after it) and the user will be able to insert only X lines and Y chars in each line. I tried to limit the lines but i don't know exactly how many lines do i have because of the line wrapping, The line wrapping is starting new line visualy on the screen(because of the width of the JTextArea) but in the string of the component it is really the same line with no '\n' to indicate new line. I do not have an idea how to limit the max chars in each line while typing. There are 2 stages: The typing of the string- keep that the user will not be able to type more then X lines and Y chars in each line. (even if the line wrap only visualy or the user typed '/n') Insert the string to the DB- after cliking 'OK' convert the string that every line will end with "/n" even if the user did not typed it and the line was wrapped only visualy. There are few problems if i will count the chars in the line and insert '/n' in the end of the line, thats why i decided to do it in two stages. In the first stage ehile the user is typing i would rather only limit it visualy and force line wrpping or something similar. Only in the second stage when i save string i will add the '/n' even if the user did not typed it in the end of the lines! Does anyone have an idea? I know that i will have to use DocumentFilter OR StyledDocument. Here is sample code that limit only the lines to 3:(but not the chars in row to 19) private JTextArea textArea ; textArea = new JTextArea(3,19); textArea .setLineWrap(true); textArea .setDocument(new LimitedStyledDocument(3)); JScrollPane scrollPane = new JScrollPane(textArea public class LimitedStyledDocument extends DefaultStyledDocument /** Field maxCharacters */ int maxLines; public LimitedStyledDocument(int maxLines) { maxCharacters = maxLines; } public void insertString(int offs, String str, AttributeSet attribute) throws BadLocationException { Element root = this.getDefaultRootElement(); int lineCount = getLineCount(str); if (lineCount + root.getElementCount() <= maxLines){ super.insertString(offs, str, attribute); } else { Toolkit.getDefaultToolkit().beep(); } } /** * get Line Count * * @param str * @return the count of '\n' in the String */ private int getLineCount(String str){ String tempStr = new String(str); int index; int lineCount = 0; while (tempStr.length() > 0){ index = tempStr.indexOf("\n"); if(index != -1){ lineCount++; tempStr = tempStr.substring(index+1); } else{ break; } } return lineCount; } }

    Read the article

  • Setting fonts in a JTextArea

    - by vuj
    I've got a JTextArea which has the following text "Text1 Text2 Text3". Is there a way I can make all of them different fonts? E.g. "Text1" is bold, "Text2" is italic and "Text3" is normal? I know I can create a Font object, however I can only apply it the JTextArea object. Thanks.

    Read the article

  • Java JTextArea Bold

    - by ikurtz
    This is an exploratory query. I am wondering if the following is possible with JTextArea? Can I alter the text to bold (append text) and then back to normal and will it only display the bold text in bold and the rest as normal? Also can the contents of JTextArea be saved as a RTF document? Thank you.

    Read the article

  • JTextArea - Highlight Text While Scrolling Up or Down

    - by Sujay
    I'm trying to work with a non-editable JTextArea added to a JScrollPane. I want a line to be highlighted when the user clicks on that specific line. I could implement this part using the following code: public static void initHighlightOption(final JTextArea textArea){ textArea.setFont(new Font("Courier New", Font.PLAIN, 12)); textArea.setEditable(false); final Action selectLine = getAction(textArea, DefaultEditorKit.selectLineAction); textArea.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 1) { selectLine.actionPerformed(null); } }); textArea.setSelectionStart(0); textArea.setSelectionEnd(0); } public static Action getAction(JTextArea textArea, String name) { Action action = null; Action[] actions = textArea.getActions(); for (int i = 0; i < actions.length; i++) { if (name.equals(actions[i].getValue(Action.NAME).toString())) { action = actions[i]; break; } } return action; } What I want to add is that once a line is highlighted and user scrolls up/down using keyboard up/down key, i want the current line to be highlighted. Is this possible by adding a keyListener? I'm stuck on how highlight data while scrolling up. The text area contains data like this: Line1 Line2 Line3 Line4 Line5 (i.e. there might be new lines between two particular lines of data)

    Read the article

  • Displaying large file in JTextArea.

    - by Sathish Gopal
    Hi All, I'm currently working in Swing UI Assignment. This work involves showing large file content in JTextArea. The file size can be as large as 2 GB. My initial idea is to lazily load content from the file, say 1 MB of content will be shown to the user. As the user scrolls i will retrieve the next 1 MB of content to be shown. All these operation will be happening in background thread (Swing Worker). I looked at the JTextArea API, the method insert takes String and int(position of the insert) as the parameter. This will suffice, but i'm worried about performance, because the content (1 MB at a time) retrieved will have to be converted to String object. Is there any other work around or any other alternative/better solution for this.

    Read the article

  • ScrollPanel in java does not appear JTextarea resizes instead

    - by Casper Marcussen
    Hello everyone My program is finished, but testing it out, i found out that the scrollpanel does not appear, it just resizes the JTextarea instead. The code is provided below: package javaapplication15; import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.io.IOException; import javax.swing.*; public class Tekstprogram extends JFrame { public Tekstprogram() { setSize(400, 600); setDefaultCloseOperation(EXIT_ON_CLOSE); setResizable(false); Container Indhold = getContentPane(); Indhold.setLayout(new FlowLayout()); JButton openButton = new JButton("Open"); JButton saveButton = new JButton("Save"); final JLabel statusbar = new JLabel("Output of your selection will go here"); final JTextArea TekstOmråde = new JTextArea(29, 30); JScrollPane scrollText = new JScrollPane(TekstOmråde); openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); int option = chooser.showOpenDialog(Tekstprogram.this); if (option == JFileChooser.APPROVE_OPTION) { File[] sf = chooser.getSelectedFiles(); String filelist = "nothing"; if (sf.length > 0) { filelist = sf[0].getName(); } for (int i = 1; i < sf.length; i++) { filelist = filelist + ", " + sf[i].getName(); } try { String strLine; File selectedFile = chooser.getSelectedFile(); FileInputStream in = new FileInputStream(selectedFile); BufferedReader br = new BufferedReader(new InputStreamReader(in)); while ((strLine = br.readLine()) != null) { TekstOmråde.append(strLine + "\n"); } } catch (Exception e) { System.out.println("En fejl opstod ved" + e); } } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JFileChooser chooser = new JFileChooser(); int option = chooser.showSaveDialog(Tekstprogram.this); if (option == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); try { BufferedWriter out = new BufferedWriter(new FileWriter(file)); out.write(TekstOmråde.getText()); out.close(); } catch (IOException e) { System.out.println("IOException fejl opstod :"); e.printStackTrace(); } } } }); Indhold.add(openButton); Indhold.add(saveButton); Indhold.add(TekstOmråde); Indhold.add(scrollText); Indhold.add(statusbar); } public static void main(String args[]) { Tekstprogram sfc = new Tekstprogram(); sfc.setVisible(true); } } Is there anyway to make the JTexarea static?

    Read the article

  • Java Log ==> JTextArea

    - by asmo
    Need: Output a Java application's log into a GUI component, such as a JTextArea. Concern: Need to log things from any class, in a static manner. However, the GUI logger component must not be static (obviously) as it's the member of a parent component. What should I do?

    Read the article

  • Output to jTextArea in realtime

    - by Robert
    I have some code which takes a few minutes to process, it has to connect to the web for each string in a long array, each string is a url. I want to make it so that everytime it connects, it should refresh the jtextarea so that the user is not staring into a blank page that looks frozen for 20 min. or however long it takes. here is an example of something i tried and didnt work: try { ArrayList<String> myLinks = LinkParser.getmyLinksArray(jTextArea1.getText()); for (String s : myLinks) { jTextArea2.append(LinkChecker.checkFileStatus(s) + "\n"); } } catch (IOException ex) { JOptionPane.showMessageDialog(jTextArea1, "Parsing Error", "Parsing Error", JOptionPane.ERROR_MESSAGE); Logger.getLogger(MYView.class.getName()).log(Level.SEVERE, null, ex); }

    Read the article

  • Writing a line in a JTextArea from another class

    - by Christopher Nastovski
    I'm trying to use a Method in my class 'Visual' to write a line of code into a JTextArea and it prints when I call it from 'Visual' but when I call it from 'Login' It only prints Text into the Console, not to the TextArea. private static Visual Visual; Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again."); or private static Visual Visual = new Visual(); Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again."); Dont work form 'Login' But, WriteLine("Test"); works from 'Visual', the class that the method is in. Here's the method in 'Visual' public void WriteLine(String Text) { System.out.println(Text); SystemFeed.append(Text.toString() + "\n"); SystemFeed.setCaretPosition(SystemFeed.getDocument().getLength()); }

    Read the article

  • How can I set partial text color in JTextArea

    - by ComputerJy
    I want to set color for specific lines in the text area. What I've found so far, was the following // Declarations private final DefaultStyledDocument document; private final MutableAttributeSet homeAttributeSet; private final MutableAttributeSet awayAttributeSet; // Usage in the form constructor jTextAreaLog.setDocument(document); homeAttributeSet = new SimpleAttributeSet(); StyleConstants.setForeground(homeAttributeSet, Color.blue); StyleConstants.setItalic(homeAttributeSet, true); awayAttributeSet = new SimpleAttributeSet(); StyleConstants.setForeground(awayAttributeSet, Color.red); // Setting the style of the last line final int start = jTextAreaLog.getLineStartOffset(jTextAreaLog.getLineCount() - 2); final int length = jTextAreaLog.getLineEndOffset(jTextAreaLog.getLineCount() - 1) - start; document.setCharacterAttributes(start, length, awayAttributeSet, true); But this is not working. What am I doing wrong?

    Read the article

  • UTF-8 and JTextArea

    - by ManWard
    hi i have 2 JTextArea that one of these contain Unicode Code point like this \u0645 i want another JTextArea show Character representation of this Unicode code point.but when pass this code point to JTextArea , it show code point not Character but if i set code point to JTextArea setText method directly it work correctly ! why ? and which can i pass String of Codepoint from one JTextArea to another ? thanks

    Read the article

  • What could I add to this code to allow the cell height to dynamically change as I edit the JTextArea

    - by Dr. Plaguey
    The derived classes I am using public class TextAreaRenderer extends JTextArea implements TableCellRenderer { public TextAreaRenderer() { setLineWrap(true); setWrapStyleWord(true); } public Component getTableCellRendererComponent(JTable jTable, Object obj, boolean isSelected, boolean hasFocus, int row, int column) { setText((String)obj); int height_wanted = (int)getPreferredSize().getHeight() + 10; if (height_wanted != rootJTable.getRowHeight(row)) rootJTable.setRowHeight(row, height_wanted); return this; } } class TextEditor extends AbstractCellEditor implements TableCellEditor { protected JTextArea ta; String txt; public TextEditor() { ta = new JTextArea(); } //Implement the one CellEditor method that AbstractCellEditor doesn't. public Object getCellEditorValue() { return ta.getText(); } // Implement the one method defined by TableCellEditor. public Component getTableCellEditorComponent(javax.swing.JTable table, Object value,boolean isSelected, int row, int column) { txt = value.toString(); ta.setText(txt); ta.setLineWrap(true); return new JScrollPane(ta); } public boolean isCellEditable(EventObject anEvent) { return true; } } Set column renderer and editor rootJTable.getColumnModel().getColumn(1).setCellRenderer(new TextAreaRenderer()); rootJTable.getColumnModel().getColumn(1).setCellEditor(new TextEditor());

    Read the article

  • How to put limitations on size & no. of characters in JTextArea?

    - by Supereme
    Hi, I'm developing an application that requires a textarea to be used in which no. of characters are restricted to 165. I made an object of JTextArea with row & column no. 3,3 respectively but it didn't work as when I went on typing, the size of 'Textarea' went on increasing.How to restrict that? As I've used 'DocumentListener' for noting no. of characters typed,deleted,cut and pasted, I'm getting problem when suddenly the size of textarea is increased. Thank you!

    Read the article

  • JTextArea thread safe?

    - by Dhaivat Pandya
    Hello everyone, I have some code that does some initialization (including making a JTextArea object), starts three seperate threads, and then these threads try to update the JTextArea (i.e. append() to it), but its not working at all. Nothing shows up on the JTextArea (however, during the initialzation, I print some test lines onto it, and that works fine). What's going on? How can I fix this? Also, each of those threads sleeps a random amount of time every time it has to update the JTextArea. Sorry I haven't provided any code, its all spread out over several files.

    Read the article

  • How to set JtextArea to keep fixed no of rows?

    - by Hippo
    How can i keep no of rows constant in text area. I need to create a console window for my application. If rows exceeds predefined no of rows first rows must get disposed. As if first written row will be destroyed first when i append anything which exceeds no of rows set. One more thing , i need to keep vertical scroll bar. That means no of rows must not be the whatever rows are visible when text area it opened. For example : - no of visible rows on view port are 30. It should keep 120 rows information, which will can be seen with the help of scroll bar.

    Read the article

  • Is there a version of postActionEvent for KeyEvent (specifically for a JTextArea)?

    - by Brian Pelc
    I'm writing a program that contains multiple JTextFields and 2 JTextAreas within an input panel. I have a submit button on the bottom. I have it set up so when a user types something into each field (including the JTextAreas) and hits the Enter key, it updates a text file, and when they press the submit button it updates the file then outputs a new version of it in the local directory. If the user presses Enter in any of the fields, it validates their input, however, I want to re-validate all fields when they press the submit button. Each field (again, JTextAreas included) has it's own validation check within its ActionListener or KeyListener (for the JTextAreas). It's easy enough to use postActionEvent() for the JTextFields, but is there a similar method for the JTextAreas to force fire a KeyEvent? I don't want to duplicate code and consume memory by re-writing the validation for those 2 Components inside the ActionEvent for the JButton. Unfortunately, I can't provide a sample because I'm writing the program on a classified machine (PC).

    Read the article

  • How can I update a Jtextarea once? (mysql side-?)

    - by user1294196
    Ok what I've been trying to do is figure out how to make it so when I press the search button on my program the code that is currently just being printed to the console will print to the text area I have. I can't figure out how to do this and I've searched google and still found no answer. And while I'm at it if anyone could help me figure out how to send this same line of information to a mysql database that would help greatly. package GTE; import java.awt.EventQueue; public class GTE { private JFrame frmGte; public String hashq = "..."; public String twtresults; public int refresh = 1; public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { GTE window = new GTE(); window.frmGte.setVisible(true); } catch (Exception e) {} } }); } /** * Create the application. * @throws IOException * @throws FontFormatException */ public GTE(){ try { initialize(); } catch (FontFormatException e) {} catch (IOException e) {} } /** * Initialize the contents of the frame. * @throws IOException * @throws FontFormatException */ private void initialize() throws FontFormatException, IOException { frmGte = new JFrame(); frmGte.setResizable(false); frmGte.setTitle("GTE"); frmGte.setBounds(100, 100, 450, 390); frmGte.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[]{434, 0}; gridBagLayout.rowHeights = new int[]{21, 0, 0, 0, 0, 0, 0, 0, 0}; gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE}; gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; frmGte.getContentPane().setLayout(gridBagLayout); JLabel GTETitle = new JLabel("Personal Tweet Extractor"); InputStream is = this.getClass().getResourceAsStream("ultraviolentbb_reg.ttf"); Font GTEFont = Font.createFont(Font.TRUETYPE_FONT,is); Font f = GTEFont.deriveFont(24f); GTETitle.setFont(f); GTETitle.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_GTETitle = new GridBagConstraints(); gbc_GTETitle.insets = new Insets(0, 0, 5, 0); gbc_GTETitle.anchor = GridBagConstraints.NORTH; gbc_GTETitle.fill = GridBagConstraints.HORIZONTAL; gbc_GTETitle.gridx = 0; gbc_GTETitle.gridy = 0; frmGte.getContentPane().add(GTETitle, gbc_GTETitle); Label label_2 = new Label("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); GridBagConstraints gbc_label_2 = new GridBagConstraints(); gbc_label_2.insets = new Insets(0, 0, 5, 0); gbc_label_2.gridx = 0; gbc_label_2.gridy = 1; frmGte.getContentPane().add(label_2, gbc_label_2); JLabel SearchTweets = new JLabel("Search For Tweets With" + hashq + ":"); GridBagConstraints gbc_SearchTweets = new GridBagConstraints(); gbc_SearchTweets.insets = new Insets(0, 0, 5, 0); gbc_SearchTweets.gridx = 0; gbc_SearchTweets.gridy = 2; frmGte.getContentPane().add(SearchTweets, gbc_SearchTweets); JLabel label = new JLabel("#"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 0); gbc_label.gridx = 0; gbc_label.gridy = 3; frmGte.getContentPane().add(label, gbc_label); JButton Search = new JButton("Start Search"); Search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { TS(hashq); GTE.this.refresh = 0; try { nulll dialog = new nulll(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (Exception e) {} } public void TS(String hashtag){ Twitter twitter = new TwitterFactory().getInstance(); try { System.out.println(hashtag); QueryResult result = twitter.search(new Query("#" + hashtag)); List<Tweet> tweets = result.getTweets(); for (Tweet tweet : tweets) { System.out.println("@" + tweet.getFromUser() + " : " + tweet.getText()); GTE.this.twtresults = ("@" + tweet.getFromUser() + " : " + tweet.getText()); } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to search tweets: " + te.getMessage()); System.exit(-1); } } }); TextField textField = new TextField(); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GTE.this.hashq = evt.getActionCommand(); } }); GridBagConstraints gbc_textField = new GridBagConstraints(); gbc_textField.ipadx = 99; gbc_textField.insets = new Insets(0, 0, 5, 0); gbc_textField.gridx = 0; gbc_textField.gridy = 4; frmGte.getContentPane().add(textField, gbc_textField); GridBagConstraints gbc_Search = new GridBagConstraints(); gbc_Search.insets = new Insets(0, 0, 5, 0); gbc_Search.gridx = 0; gbc_Search.gridy = 5; frmGte.getContentPane().add(Search, gbc_Search); Label label_1 = new Label("Search Results For Tweets With"); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.insets = new Insets(0, 0, 5, 0); gbc_label_1.gridx = 0; gbc_label_1.gridy = 6; frmGte.getContentPane().add(label_1, gbc_label_1); TextArea textArea = new TextArea(); textArea.setText(twtresults); textArea.setEditable(false); GridBagConstraints gbc_textArea = new GridBagConstraints(); gbc_textArea.gridx = 0; gbc_textArea.gridy = 7; frmGte.getContentPane().add(textArea, gbc_textArea); JMenuBar menuBar = new JMenuBar(); frmGte.setJMenuBar(menuBar); JMenu Filemenu = new JMenu("File"); menuBar.add(Filemenu); JMenuItem Exititem = new JMenuItem("Exit"); Exititem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.exit(0); } }); Filemenu.add(Exititem); JMenu Helpmenu = new JMenu("Help"); menuBar.add(Helpmenu); JMenuItem Aboutitem = new JMenuItem("About"); Helpmenu.add(Aboutitem); } }

    Read the article

  • Set Caret position with JTextArea in JScrollPane

    - by Albinoswordfish
    Right now I have a JTextArea inside of a JScrollPane. For the current content it has both a vertical and horizontal scroll bar showing up. I'm trying to implement a search functionality where a user can search for a certain string and it will set the caret position to the first occurrence of that string. However it seems that JScrollPane only scrolls vertically when I set my caret position. So matching strings going off the JTextArea horizontally will completely get missed and the horizontal scroll bar won't scroll at all. I'm using the basic function setCaretPosition() for the JTextArea Does anybody have any idea why my JScrollPane isn't moving horizontally using setCaretPosition() Edit: It appears the horizontal scroll bar is scrolling but it moves so little that it's barely noticeable. I can only see the very first pixel of the character. Is there a way to have the scrollbar center (or as much as possible) to the caret position?

    Read the article

  • Mix of Arabic and English causes problems in JTextArea (Java)

    - by Dan
    I have a JTextArea which displays HTML of an Arabic web page. So it's essentially a mix of English and Arabic. In the JTextArea, with columns set to 30, certain text just disappears instead of wrapping properly. The weird thing is that if I copy the invisible text and paste it into Notepad, then I can see it in Notepad. If I change the number of columns to 40, everything displays fine. Any ideas?

    Read the article

  • Dynamically refresh JTextArea as processing occurs?

    - by digiarnie
    I am trying to create a very simple Swing UI that logs information onto the screen via a JTextArea as processing occurs in the background. When the user clicks a button, I want each call to: textArea.append(someString + "\n"); to immediately show up in the UI. At the moment, the JTextArea does not show all log information until the processing has completed after clicking the button. How can I get it to refresh dynamically?

    Read the article

  • Java Swing: JTextArea columns question

    - by battousai622
    How do i put the text in specific columns with jTextArea? private javax.swing.JTextArea jTextArea1; jTextArea1.setColumns(4); jTextArea1.insert(price, 0); //column 1 jTextArea1.insert(cost, 0); //column 2 jTextArea1.insert(quantity, 0); //column ect.. jTextArea1.insert(itemName, 0); jTextArea1.insert("\n", 0);

    Read the article

1 2 3 4  | Next Page >