Text 2 « Development « Java Swing Q&A





1. Why is Swing text always bold?    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

2. Word-based text undo/redo    coderanch.com

Does anyone know of coding example for word-based text undo? By default, Swing undoes and redoes typed-in text one character at a time, but I'd like to undo and redo based on whole words. This is the way most professional word-processing programs do it. I have a way of doing word-based undo and redo, but it's so complicated and kludgy that ...

4. save text file problem help !    coderanch.com

hello i been having this problem for long time now and i just can not find what is the problem in my code ..what i am trying to do is to read text file get the correct data and save it in linked list then save it again with different name as a text file . now the problem is i ...

5. Metal L&F Text Antialiasing    coderanch.com

7. Search text in HTML    coderanch.com

I want to read HTML file and based on the search text entered , i need to find that text in the HTML file. Yes, i am trying to read the HTML file stored locally. First step i did is reading the HTML file. The program is below: public class ReadHTMLSample { public static void main(String args[]){ JEditorPane pane = new ...

8. Displaying text    coderanch.com

I'm working on a Java applet telnet client, and the socket stuff is done now, but I'm trying to rig it so that the Swing component that displays the text displays it correctly. Because it seems to use HTML as a default it does things like collapse multiple spaces down to a single space, ignore the telnet ANSI colour codes, that ...

9. Read and search text in HTML - ArrIndOutOfBoundsException: 88    coderanch.com

Hi, I am searching text from HTML and finding file names. Placing those names to JList. Searching is taking place properly. but java.lang.ArrayIndexOutOfBoundsException: 88 is thrown. Find the code below: public String search(JEditorPane editorPane, String word, String arg_strFilePath) { int countOccurances = 0; strGetFileName = arg_strFilePath; try { reader = new FileInputStream(arg_strFilePath); } catch (FileNotFoundException e) { e.printStackTrace(); } HTMLEditorKit htmlKit ...





10. HTML scraping using javax.swing.text.html.    coderanch.com

Hello ranchers, I am developing an application/web service for RSS feed generation from HTML pages listing news stories. At this stage, I am looking into HTML scraping for extracting the necessary information. With the help of an online example I can get the links in an HTML document using javax.swing.text.html. public static void main(String[] args) { List links = new ArrayList(); ...

11. best way to switch from a text based program to a GUI???    coderanch.com

Hi there, I currently have a text based program with arrays, and i have designed a GUI seperately with no information in it, or any classes linking. What would the best way of making the switch from a text based program to a GUI? Can it be done, or would i have to recreate my program from my GUI program that ...

12. How to determine size of TableColumn text?    coderanch.com

Hi there, I have an SWT table with several columns. I can set each column's heading text by using tableColumn.setText("Some Text"); However, how do you determine how wide the rendered heading text will be so that you can appropriately set the column width? In this particular column, the width of the contents will be smaller than the width of the heading ...

13. text editing    coderanch.com

14. create a text analysis    coderanch.com

So far I have like this: import javax.swing.*; import java.awt; import java.awt.event; import java.io.*; import java.applet.Applet; import java.awt.TextArea; import java.awt.Button; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.util.Vector; import java.lang.Integer; public class TextAnalysis extends Applet { String newln = new String(new char[] {50}); public boolean DEBUGGING = true; TextArea t = new TextArea; TextArea r = new TextArea("",1,1,TextArea.SCROLLBARS_VERTICAL_ONLY); Button lb = new Button("Load"); ...

15. Taking values from a text file inside paintcomponent    coderanch.com

Hi, I want to read values from a text files from specified fields and use them as values to fill my methods inside the paintComponent() method. I am using for loop to do that but not able to do it properly. Can somebody give me a good example code howto do it ?? Here is extract of my code below:- public ...

16. Help with reprinting downloaded text from FTP site onto GUI!    coderanch.com

*This has already been posted on the Sun Java Forum, but I need help quickly, so I am cross-posting. Thank you!* Basically, I have all of the data download from the FTP site but I can't get it to be reprinted to the GUI after the GUI is already opened initially. I'm pretty sure I have to make a new method ...





19. Swing - strange behaviour on text insert into a HTML pane    coderanch.com

Hi all, I am trying to fix a problem on inserting a span tag into an existing html page (in an EDITABLE JEditorPane). The behaviour: Assuming the cells in a table (3 rows, 2 columns) are numbered from 1 to 6, with cell one being the top left most, cell 2 top right, cell 3 middle left, etc. 1. Inserting the ...

20. How to copy styled text    coderanch.com

21. Text to Bitmap convertion    coderanch.com

hi can anybody please tell me how to generate a bitmap file from text entered in Jtextfield .i need a wirless bitmap format. Actually i am using this code private Bitmap getScaledBitmapImage(String imagename, int ratioX, int ratioY) { EncodedImage image = EncodedImage.getEncodedImageResource(imagename); int currentWidthFixed32 = Fixed32.toFP(image.getWidth()); int currentHeightFixed32 = Fixed32.toFP(image.getHeight()); double ratio = (double)ratioX / (double) ratioY; double w = (double) ...

22. Animating text    coderanch.com

23. triangles and text    coderanch.com

24. automatic text input    coderanch.com

25. Text location is messed up on some computers    coderanch.com

Hi All, I'm having a little bit of trouble with text locations on components for some computers. When I run the application on my computer (and on most computers) the text looks fine, but when it is run on some others, it is set so the bottom "line" is midway through the component. See attachments for examples. I'm not sure how ...

26. text typing in jTextBox    coderanch.com

Hi, I'm new to Swing. I created a database application to search a text in the database and i use a jTextBox to enter the text. But now i have a problem in entering the values in the text box since the value is typed reversely. When entering a character it goes in front of others without going to the last ...

27. How to save default text in notepad    coderanch.com

I want to save text in notepad and o when i write it write it in a single line but i want it in next line when there is next line in code . like "my name is vivek" when i write it .notepad show me "my name is vivek" but i want the text as same as above so help ...

29. Text Anti-aliasing    coderanch.com

30. Double text alignment    coderanch.com

31. I need to have my program take information from text file Plus my pie chart is in wrong place    coderanch.com

/*/** Mortgage Calculator Program * Week 5 PRG421 *Change Request #7 High-Level Requirements Requestor: Ninfa Pendleton - Rapid City, SD Write the program in Java (with a graphical user interface) * and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage and the user's selection from a menu of available mortgage loans: ...

32. .c to text conversion    coderanch.com

33. Weird rendering of text outline in AWT    coderanch.com

I've followed a tutorial on creating a text with border here: http://java.sun.com/developer/onlineTraining/Media/2DText/style.html, using java.awt.Graphics2D. It works, but only for thin outlines. If i make the outline thicker, the sharp points in the text (in letters like A, M or W) get overly "stretched". Please see the attached picture, it's hard to describe this effect. As a workaround, I tried to use ...

34. Using Swing to display an array from text file issues    coderanch.com

Hi all, I am fresh into Java here. I am trying to pull data from a text file, 2000 words or so, and have them display one at a time flashing on the screen for a set time then the next word etc... until EOF. I am getting these errors: Exception in thread "main" java.lang.NullPointerException at TimeThis.readFile(TimeThis.java:53) at TimeThis.start(TimeThis.java:94) at TimeThis.main(TimeThis.java:104) ...

35. passing text from a class to a gui class    java-forums.org

Hi, I have a class a server class and a serverGUI class. Now the server class creates sockets etc and I need to display messages in the serverGUI (in a texfield), as soon as the socket is created. However, since I cant access the texfield from the server class I can't do this. Any help pls? Add to rob's Reputation

36. Looking for HTMR-RTF text control    java-forums.org

I'm looking for HTML-RTF text control, it would be good if it extends JComponent. It's not enough the functionality of JTextPane, also it has too many bugs... Some web based HTML-RTF is less acceptable...but if you knew some good, please write down the links. Free or not free - doesn't matter. Thx. P.S. It will be used as editor in a ...

37. change text size in all GUI components    java-forums.org

If you set all the font attributes of the components to null, then they will all inherit the font from the base container. So, just set the font of the container. I believe the default is to inherit. Size and things like bold, italic, are inherit attributes of the font, so everything will have exactly the same font. Of course, that ...

38. Reading in a text file    java-forums.org

Hello, I am trying to create a Java interface for reading text files. I have already managed to create a GUI which can read a text file into a JTextPane which is inside a JScrollPane, but now I want to do something different. Rather than scrolling through the text file, I want to be able to read through it like a ...

39. Help With Text Analayzer Program    java-forums.org

I am trying to create a text analyzer program and i am having real trouble doing so. I have been given the skeleton code and i have tried to create this program myself but i cant seem to do so import java.awt.*; import java.awt.event.*; import javax.swing.*; public class text_analysis extends JPanel implements ActionListener { JPanel board; // Panel for buttons JPanel ...

40. How to make a TEXT TWIST using GUI    java-forums.org

i want to have a GUI application but i cant... public class TextTwist { private static final int ALPHABET = 256; // return profile of ASCII string s public static int[] profile(String s) { int[] cnt = new int[ALPHABET]; for (int i = 0; i < s.length(); i++) ++cnt[s.charAt(i)]; return cnt; } // are two profiles identical? public static boolean contains(int[] ...

41. [iText] Is it possible to rotate the text (Chunk)?    java-forums.org

Hello. I hope that I started on the right place. I use the iText library and I have a problem. I would like to rotate the text (Chunk) by 90 degrees, but I do not know how to do it. I hope you know what's going on and help me. My English is poor... :D Thanks.

42. Pulse effect on text    java-forums.org

Can you describe what you mean by pulse effect? If you mean a pulsing change in color or brightness, then create a color array in advance, perhaps based on a sine curve, and then use a Swing Timer to change foreground colors. If you mean something else, then by all means feel free to share the details with us so we ...

43. how to get tow in puts from one text filed    java-forums.org

44. Working with text panes    java-forums.org

I am getting pretty close to having a fairly decent text editor but I am still running into trouble with some capabilities I would like to implement. One of the first questions I have is in regards to button groups. I have a button which changes the text to sub script and a button for super script. However, it doesn't make ...

45. :( Text File Opening Problem    java-forums.org

46. get text and show it and save it    java-forums.org

47. logging class outputs two text files when i only want one!!    java-forums.org

public static void main(String[] args) { Logger logger = Logger.getLogger("MyLog"); FileHandler fh; try { // This block configure the logger with handler and formatter fh = new FileHandler("C:/newgui/MyLogFile.log"); logger.addHandler(fh); //logger.setLevel(Level.ALL); SimpleFormatter formatter = new SimpleFormatter(); fh.setFormatter(formatter); // the following statement is used to log any messages logger.info(""); } catch (SecurityException e) { } catch (IOException e) { } logger.info("error log"); this ...

48. How do I add text after using MemoryImageSource    java-forums.org

I've followed all the tutorials adding text to images and buffered images with no problems until I try to add text to an image created using MemoryImageSource. I get an error message saying that the usual method doesn't work with images produced by ImageProducer. The image starts life as an integer array with ARGB format so converting it into a buffered ...

49. Updating text displayed in a Swing Application    java-forums.org

Hey , I'm trying to a develop a swing application. I am facing a problem when i attempt to update the value of a text area. i have the text area called "mytextarea1" added to a panel which is added to a frame .I have a button "button_start" which should start the updating of the text area according to the function ...

50. What are the available tricks to hightlight any line in a text containing many lines?    java-forums.org

Hi, I have some piece of text contains 20-25lines. I want to draw all the text in a window and dynamically highlight any line of the text. For this reason, i am thinking to design a JPanel, which will put all the text in a textArea first but after that how to highlight the text? Can i change color of any ...

51. Clickable text in a component    java-forums.org

I'm looking for a way to create a text box, like a JTextArea, that has links that underline when you hover over them. Ideally, when a link is clicked it would call a listener method with the link text as an argument. This is not for HTML. It's more like a remote log file browser. Edit: the component does not need ...

52. setting text    java-forums.org

Re: setting text here is the rest of the code: Java Code: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * TEST.java * * Created on Nov 10, 2011, 8:58:37 PM */ package gui; public class TEST extends javax.swing.JFrame { /** Creates new form TEST */ public TEST() { ...

53. Center AND wrap text    java-forums.org

Hi! I'm trying to display text in a window. I want it to be centered and to wrap onto multiple lines. I can do both, but not at the same time. For example, a JLabel supports centering but not wrapping, while a JTextArea supports wrapping but can't center text. How do I do this?

54. Inputting some text in a GUI.    java-forums.org

Hello. I am new to Java and am finding it difficult to grasp the GUI aspect. What I want to do is to have some kind of input box where the user enters some text and then presses a button which processes the text (using a class that I have developed). I don't have a clue as to how I should ...

55. GUI: How to save these data to a text/dat file?    java-forums.org

Hello, this is my first time in java forums :) Here is my code which is slightly finished...i spent 2 weeks continuing this and still no progress :( I HAVE NO IDEA HOW TO SAVE THE DATA TO A TEXT FILE :'( i dont even know where to put it. im familiar with BufferedWriter, PrintWriter, etc. and i know how to ...

56. GUI text display input to list array    java-forums.org

57. Find and Replace in Text File    java-forums.org

As this question has nothing to do with Swing and so is in the wrong forum, I will move it to the New To Java section. Poster, have you tried reading in the file, and writing it out to a new file, changing the word when you get to it. Then deleting the original file and renaming the new file?

58. Center text in a JComponent?    java-forums.org

The easiest way is to add a JLabel to it that has its horizontalAlignment property set to SwingConstants.CENTER. If you give the JComponent a BorderLayout and add the JLabel to the BorderLayout.CENTER position then it will fill the component. Otherwise, you may need to muck with FontMetrics, something I've not yet done.

59. I want to put text outputs in the GUI console.    java-forums.org

Hi all, I have this java problem , which I need to put the outputs in the GUI. It is a sorting program, when I click the key, it sorts by it self. First, when I run the program, CLI and GUI console appears. However, when I click the key (RUN SORTING), on the CLI - the sorting list eg -> ...

60. opening a text file in notepad using swing    forums.oracle.com

61. searching a keyword in the GUI text file    forums.oracle.com

Hey. i have a GUI which reads in the text file and display its content in jtextarea and i have a button from which a user can type anything and will write it to a text file. now i was thinking of searching a keyword in a txt file through a GUI. First my question is how can if find a ...

62. Text in GUI    forums.oracle.com

JMenuItem scores = new JMenuItem("Scores"); scores.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scoresSheet(); } }); options.add(scores); JMenuItem quitItem = new JMenuItem("quit"); quitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); options.add(quitItem); return menuBar; } public Container createContentPane() { //Create the content-pane-to-be. JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setOpaque(true); //Create a scrolled text area. output = new JTextArea(5, 30); ...

63. Displaying text in GUI    forums.oracle.com

64. How do I add text typed in a Java GUI to my database?    forums.oracle.com

Using NetBeans, I've created a GUI, which has a 5 text boxes and an add/sumbit button. I've also created a database, which is on my Runtime Panel in Netbeans, and has a table with 5 columns. Once my GUI is running, I want the Add button to insert the information from each of the text boxes to the 5 columns in ...

65. Text in swing    forums.oracle.com

66. About Swing.text Question    forums.oracle.com

I am new in swing. In javax.swing.text package is there a AbstractDocument class. If I have created that object, how can I move the contents of that object to RTF file? This mind come up because I want to save styled text into RTF file. Is that possible? Please give me some ideas. Thank you.

67. GUI help, is the output text working?    forums.oracle.com

68. Have more than 1 text entry field in a pane in GUI.    forums.oracle.com

You can create a JPanel and place several JTextFields inside of this JPanel, then display the JPanel in a JOptionPane via showMessageDialog. After the dialog exits, extract the text from the JTextFields, and there you are. Also: 1) Make sure that you go throught the Sun Swing tutorials to get a decent understanding of Swing, and 2) Try to ask Swing ...

69. Swing.Text.HTML Question    forums.oracle.com

70. GUI: Process Text~~~ Need HELP!    forums.oracle.com

Below is a GUI that i create...the purpose of this program is to count the number of lines, number of words and number of characters that a user type in a Text Area...My problem is ....i dunno the coding of count the number of lines, number of words and number of characters.. Below is the code that i have done....Now i ...

72. Reading in a text file to GUI for later analysis    forums.oracle.com

A couple of points: *You've commented out stuff that is needed, like the adding of actionlisteners, the implements actionlistener,... *Your actionlistener is looking for a menu choice which doesn't exist "displayContentsChoice". Does this menu item need to be created? *How much of this code have you yourself created? Do you understand its inner working? *What is the purpose of this code? ...

73. Having text with different formats within one GUI component    forums.oracle.com

I'm attempting to output text in a GUI but would like to change the formatting for certain areas of the text - i.e. most of it would be plain text but some areas of it are to be highlighted. I was expecting to be able to do this using a simple jTextArea but as far as I can tell it only ...

74. Gui Help Text Areas    forums.oracle.com

75. how to display text file in swing    forums.oracle.com

Hi, It is simple. Just create a button and add it to the action listener as button.addActionListener(this); Your class should extend ActionListener. and also there should be a method named - actionPerformed(ActionEvent avt) in your class Now inside this method, just compare the action as: if(avt.getSource()==button) { // in this method, hjust take your file contents and display it on the ...