The resizing of a JTextArea

Hi.
Before I begin, I have...
--Searched the forums for similar postings
--Read the API for all related components
--Attempted various solutions myself
--Followed the Swing tutorials/trails
That being said, I've got a JTextArea that gets added to a JPanel that gets added to a JFrame. The JPanel uses a GridBagLayout. The problem is that when I resize the GUI negatively, at some point, my JTextArea suffers from significant shrinkage. It kinda does this broken rubberband thing where the JTextArea goes to about 1 or 2 pixels in height and all the other components move toward the vertical center of the window along with the now tiny JTextArea.
Code below. Thanks in advance to those who enjoy answering these things for those of us that are temporarily frustrated :-)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
public class BidToolGUI {
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
     //create an object of type BidToolGUI to work with
     BidToolGUI myGUI = new BidToolGUI();
     //create components
     JLabel custNameLabel = new JLabel("Customer name: ");
          JLabel sheetIDLabel = new JLabel("Fact sheet ID: ");
          JLabel howManyLabel = new JLabel("How many D p/n's?: ");
          JLabel dpnsLabel = new JLabel("Delta p/n's: ");
          JLabel filler = new JLabel("");
     JRadioButton thinkcentre = new JRadioButton("ThinkCentre");
     JRadioButton thinkpad = new JRadioButton("ThinkPad");
     ButtonGroup buttons = new ButtonGroup();
     buttons.add(thinkcentre);
     buttons.add(thinkpad);
     JTextField custNameField = new JTextField();
     JTextField sheetIDField = new JTextField();
     JTextField howManyField = new JTextField(5);
     JTextArea dpnsArea = new JTextArea(25, 25);
     JScrollPane scrollDpnsArea = new JScrollPane(dpnsArea);
     JButton gen = new JButton("Get delta p/n's");
     JButton clear = new JButton("Clear");
     JButton search = new JButton("Search");
          *string used to communicate to Site the brand
          *looks at the buttons
     String think;
          *string set up to receive data back from php
     String line;
//Make sure we have nice window decorations.
//JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("Bid Tool");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(200, 100);
//Create a JTabbed pane
JTabbedPane tabbedPane = new JTabbedPane();
//Create a JPanel that uses a GridBagLayout
JPanel panel1 = new JPanel(new GridBagLayout());
     //Create a new GridBagConstraints object
     GridBagConstraints c = new GridBagConstraints();
     c.fill = GridBagConstraints.BOTH;
     //Add the ThinkCentre button
     c.gridx = 0;
               c.gridy = 0;
     panel1.add(thinkcentre, c);
     //Add the ThinkPad button
     c.gridx = 1;
               c.gridy = 0;
     panel1.add(thinkpad, c);
     //Add the customer name label
     c.gridx = 0;
               c.gridy = 1;
     panel1.add(custNameLabel, c);
     //Add the customer name field
     c.gridx = 1;
               c.gridy = 1;
               c.gridwidth = 2;
               panel1.add(custNameField, c);
     //Add the sheet ID label
     c.gridx = 0;
               c.gridy = 2;
               c.gridwidth = 1;
     panel1.add(sheetIDLabel, c);
     //Add the sheet ID field
     c.gridx = 1;
               c.gridy = 2;
               c.gridwidth = 2;
               panel1.add(sheetIDField, c);
     //Add the how many? label
     c.gridx = 0;
     c.gridy = 3;
     c.gridwidth = 1;
     panel1.add(howManyLabel, c);
     //Add the how many? field
     c.gridx = 1;
     c.gridy = 3;
     c.gridwidth = 1;
     panel1.add(howManyField, c);
     //Add the Get Delta p/n's button
     c.gridx = 0;
     c.gridy = 4;
     c.weightx = .3;
     c.gridwidth = 1;
     panel1.add(gen, c);
     //Add the clear button
     c.gridx = 1;
     c.gridy = 4;
     c.weightx = .3;
     c.gridwidth = 1;
     panel1.add(clear, c);
     //Add the search button
     c.gridx = 2;
     c.gridy = 4;
     c.weightx = .3;
     c.gridwidth = 1;
     panel1.add(search, c);
     //Add the output area
     c.gridx = 0;
     c.gridy = 5;
     c.gridwidth = 3;
     panel1.add(scrollDpnsArea, c);
     tabbedPane.addTab("DPNG", null, panel1,
"Delta p/n Generator");
//Add the tabbedPane to the frame
//JLabel label = new JLabel("Hello World"); <<<old code from example>>>
frame.getContentPane().add(tabbedPane);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}

Okee dokee. Great answer. I now have a clue and will go try and implement the appropriate code. The one thing I don't get is this: Since I'm using GridBagLayout, the size of the panel is determined dynamically by GridBagLayout based on what components I'm putting where. I like the size of the window when I first run the program, but how do I know what that size is? I'm going to go back and set the minimum size as you suggested, but getting it to be the size that it is when I first run the program is going to be trial and error I think.
Thanks so much for the direction.

Similar Messages

  • Resizing ListCellRenderers using JTextArea and word wrap

    Hi,
    I'm trying to create a ListCellRenderer to draw nice cells for a JList. Each cell has a one line title and a description of variable length. So, I create a custom ListCellRenderer, which consists of a JPanel containing a JLabel for the title and a JTextArea for the description. I set the JTextArea to do wrapping on word boundried and it all almost works.
    But, the list cells don't resize to accomodate the variable height of the cells. They show only 1 line for the title and 1 line for the description.
    I have seen a few threads relating to this including the article, "Multi-line cells in JTable in JDK 1.4+" in the Java Specialists' Newsletter, which seems to do a similar trick for JTables. But so far nothing I've tried works.
    Curiously, using println debugging, my getListCellRenderer method seems to get called for each cell twice while my GUI is being drawn. It looks to me like the TextUI view that draws the JTextArea seems to do the word wrapping after the first set of getListCellRenderer calls. But, it's the first set of calls that seems to establish the layout of the list.
    Any help would be appreciated. I've pulled out quite enough hair over this one.
    -chris
    package bogus;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Font;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    public class CellRendererTest {
         public static void main(String[] args) {
              final CellRendererTest test = new CellRendererTest();
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        test.createGui();
         public void createGui() {
              JFrame frame = new JFrame("Testing Bogus ListCellRenderer");
              JList list = new JList(createBogusListItems());
              list.setCellRenderer(new MyListCellRenderer());
              frame.add(list);
              frame.setSize(200, 400);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private MyListItem[] createBogusListItems() {
              List<MyListItem> items = new ArrayList<MyListItem>();
              items.add(new MyListItem("First item", "This is a nice short description."));
              items.add(new MyListItem("Another one", "This is a longer description which might take up a couple of lines."));
              items.add(new MyListItem("Next one", "This is a ridiculously long description which is total gibberish." +
                        "Blah blah blabber jabber goo. Blither blather bonk. Oink boggle gaggle ker-plunk."));
              items.add(new MyListItem("No Desc", null));
              items.add(new MyListItem("Last one", "Boink!"));
              return items.toArray(new MyListItem[items.size()]);
         static class MyListCellRenderer extends JPanel implements ListCellRenderer {
              private JLabel title;
              private JTextArea desc;
              // hack to see if this is even possible
              private static int[] rows = {1, 2, 3, 0, 1};
              public MyListCellRenderer() {
                   setLayout(new BorderLayout());
                   setBorder(BorderFactory.createEmptyBorder(6, 4, 6, 4));
                   setOpaque(true);
                   title = new JLabel();
                   title.setFont(new Font("Arial", Font.ITALIC | Font.BOLD, 11));
                   add(title, BorderLayout.NORTH);
                   desc = new JTextArea();
                   desc.setFont(new Font("Arial", Font.PLAIN, 9));
                   desc.setOpaque(false);
                   desc.setWrapStyleWord(true);
                   desc.setLineWrap(true);
                   add(desc, BorderLayout.CENTER);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus) {
                   MyListItem item = (MyListItem)value;
                   title.setText(item.title);
                   if (item.description != null && item.description.length() > 0) {
                        desc.setText(item.description);
                        desc.setVisible(true);
                   else {
                        desc.setVisible(false);
                   // uncomment next line to to somewhat simulate the effect I want (hacked using the rows array)
                   // desc.setRows(rows[index]);
                   if (isSelected) {
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                   else {
                        setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   return this;
         static class MyListItem {
              String title;
              String description;
              public MyListItem(String title, String description) {
                   this.title = title;
                   this.description = description;
    }

    This seems to work
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Insets;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.text.View;
    public class CellRendererTest {
         int WIDTH = 220;
         public static void main(String[] args) {
              final CellRendererTest test = new CellRendererTest();
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        test.createGui();
         public void createGui() {
              JFrame frame = new JFrame("Testing Bogus ListCellRenderer");
              JList list = new JList(createBogusListItems());
              final MyListCellRenderer renderer = new MyListCellRenderer();
              list.setCellRenderer( renderer );
              JScrollPane listScrollPane = new JScrollPane(list);
              frame.add(listScrollPane);
              frame.setSize(WIDTH, 400);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private MyListItem[] createBogusListItems() {
              List<MyListItem> items = new ArrayList<MyListItem>();
              items.add(new MyListItem("First item", "This is a nice short description."));
              items.add(new MyListItem("Another one", "This is a longer description which might take up a couple of lines."));
              items.add(new MyListItem("Next one", "This is a ridiculously long description which is total gibberish." +
                        "Blah blah blabber jabber goo. Blither blather bonk. Oink boggle gaggle ker-plunk."));
              items.add(new MyListItem("No Desc", null));
              items.add(new MyListItem("Last one", "Boink!"));
              items.add(new MyListItem("Ooops this one breaks things by being longer than my fixed width", "Blabber babble gibber flipper flop."));
              return items.toArray(new MyListItem[items.size()]);
         static class MyListCellRenderer extends JPanel implements ListCellRenderer {
              public JLabel title;
              public JTextArea desc;
              Color altColor = new Color(0xeeeeee);
              public MyListCellRenderer() {
                   setLayout(new BorderLayout());
                   setBorder(BorderFactory.createEmptyBorder(6, 4, 6, 4));
                   setOpaque(true);
                   title = new JLabel();
                   title.setFont(new Font("Arial", Font.ITALIC | Font.BOLD, 11));
                   add(title, BorderLayout.NORTH);
                   desc = new JTextArea();
                   desc.setFont(new Font("Arial", Font.PLAIN, 9));
                   desc.setOpaque(false);
                   desc.setWrapStyleWord(true);
                   desc.setLineWrap(true);
                   add(desc, BorderLayout.CENTER);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus) {
                   Insets insets = desc.getInsets();
                int rendererLeftRightInsets = insets.left + insets.right + 8;  // 8 from panel border
                int topDownInsets = insets.top + insets.bottom;
                int listWidth = list.getWidth();
                int viewWidth = listWidth;
                   int scrollPaneLeftRightInsets = 0;
                   JScrollPane scroll = (JScrollPane) SwingUtilities.getAncestorOfClass( JScrollPane.class, list );
                   if ( scroll != null && scroll.getViewport().getView() == list ) {
                        Insets scrollPaneInsets = scroll.getBorder().getBorderInsets(scroll);
                     scrollPaneLeftRightInsets = scrollPaneInsets.left + scrollPaneInsets.right;
                     listWidth = scroll.getWidth() - scrollPaneLeftRightInsets;
                     JScrollBar verticalScrollBar = scroll.getVerticalScrollBar();
                     if (verticalScrollBar.isShowing()) {
                         listWidth -= verticalScrollBar.getWidth();
                     viewWidth = listWidth - rendererLeftRightInsets;
                   MyListItem item = (MyListItem)value;
                   title.setText(item.title);
                   if (item.description != null && item.description.length() > 0) {
                        desc.setText(item.description);
                        desc.setVisible(true);
                        View rootView = desc.getUI().getRootView(desc);
                     rootView.setSize( viewWidth, Float.MAX_VALUE );
                    float yAxisSpan = rootView.getPreferredSpan(View.Y_AXIS);
                        Dimension preferredSize = new Dimension( viewWidth, (int)yAxisSpan + topDownInsets );
                        desc.setPreferredSize( preferredSize );
                   } else {
                        desc.setVisible(false);
                   title.setPreferredSize( new Dimension( viewWidth, title.getPreferredSize().height ) );
                   // uncomment next line to to somewhat simulate the effect I want (hacked using the rows array)
                   //desc.setRows(rows[index]);
                   if (isSelected) {
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                   else {
                        if (index % 2 == 0)
                             setBackground(altColor);
                        else
                             setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   return this;
         static class MyListItem {
              String title;
              String description;
              public MyListItem(String title, String description) {
                   this.title = title;
                   this.description = description;
    }

  • Saving the data in a jtextarea

    I have a mancala game that records which players turn it is, how many moves have been made, and which cup was selected. I am able to successfully save the game, but can't figure out how to save the data in the JTextArea. Please help me figure out how I might solve this.
    class TogizKumalakPanel extends JPanel
        private JTextArea actionRecordArea = new JTextArea(6, 23);
        private JScrollPane actionScrollPane;
        private BoardV8 playBoard;
        private int playTurn;
        private int moveCount = 1;
        public TogizKumalakPanel()
            super();
         playTurn = 1;
            playBoard = new BoardV8();
         addMouseListener(new MouseHandler());
            addMouseMotionListener(new MouseMotionHandler());
            actionRecordArea.setEditable(false);
            actionScrollPane = new JScrollPane(actionRecordArea,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            add(actionScrollPane, "South");
        public void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
         playBoard.drawBoard(g2);
        public BoardV8 getPlayerCup()
            return playBoard;
        public void setPlayerCup(BoardV8 cupIn)
            playBoard = cupIn;
        public int getPlayerTurn()
            return playTurn;
        public void setPlayerTurn(int cupIn)
             playTurn = cupIn;
        public JScrollPane getActionScrollPane()
            return actionScrollPane;
        public void setActionScrollPane(JScrollPane actionScrollPane)
            this.actionScrollPane = actionScrollPane;
    private class SaveListener implements ActionListener
            public void actionPerformed(ActionEvent event)
                String fileName;
                myChooser.setCurrentDirectory(new File("."));
                myChooser.showSaveDialog(TogizKumalakFrame.this);
                fileName = myChooser.getSelectedFile().getPath();
                try
                    ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(fileName));
                    outputStream.writeObject(myPanel.getPlayerCup());
                    outputStream.writeInt(myPanel.getPlayerTurn());
                    outputStream.writeObject(myPanel.getActionScrollPane());
                catch(IOException e)
                    System.out.println("Problem making or writing to an output stream.");
              System.out.println(e);
        private class LoadListener implements ActionListener
            public void actionPerformed(ActionEvent event)
                String fileName;
                myChooser.setCurrentDirectory(new File("."));
                myChooser.showOpenDialog(TogizKumalakFrame.this);
                fileName = myChooser.getSelectedFile().getPath();
                try
                    Container contentPane = getContentPane();
              contentPane.remove(myPanel);
                    myPanel = new TogizKumalakPanel();
                    contentPane.add(myPanel, "Center");
              ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(fileName));
                    myPanel.setPlayerCup((BoardV8)inputStream.readObject());
                    myPanel.setPlayerTurn((int)inputStream.readInt());
                    myPanel.setActionScrollPane((JScrollPane)inputStream.readObject());
                    setVisible(true);
                catch(IOException e)
                    System.out.println("Problem making an input stream.");
                catch(ClassNotFoundException e)
                    System.out.println("Class not found problem when reading objects.");
        }

    I haven't read ur entire code but to save the data in a jtextarea, use get text to get the text and then write to a file.

  • The resize widget || disappeared.  How do I get it back

    The resize widget that I used so often has disappeared on one of my computers.  All my computers run OS X lion 10.7.4.  All but one have the widget.
    It is handy, because often when a column is too narrow in column view to show an entire file or folder name, because it is too long, I doubble click on the widget that looks like two vertical lines, and the column gets wider to the correct width.
    Here are two images that illustrate the issue.  Image 1 shows the widget at the bottom of the colums, inside the red circle.  In image 2 the widget is not visible.  How do I get it back?
    In image 2 the widget is not visible.  How do I get it back?

    I figured it out.

  • How to get the content of a jTextArea?

    hi everyone
    can some body provide me with some help???
    I want to know how to get the content of a jTextArea
    it may be a String and i want to use that String to make some applications
    I've use this :
    String ch=jTextArea.getSelectedText()
    but i'm not sure it will work and i'm not sure it will take the text writen inside the jTextArea ... please help
    Thanks

    http://forum.java.sun.com/thread.jspa?threadID=778988&tstart=0

  • I am unable to get the resize pointer to appear.

    I often use the resize pointer to adjust Excel column sizes and Desktop window sizes.  In perhaps the past month or so, I haven't been able to get this cursor even to appear.  If I hold the arrow pointer to a column edge or a window edge, it appears to flash very rapidly between the arrow pointer and the resize pointer, but I can't get the resize pointer to remain and be used.
    My apologies for opening a new issues, but I have not been able to find this issue clearly described, or any significant solution to cursor problems.  It took a lot of searching just to learn the term "resize pointer".
    I have a 2009-ish MBP and OS X 10.8.4.  I also have a Magic Mouse connected, but the problem occurs on either the mouse or the trackpad, and whether or not the mouse is connected.
    Thanks.

    Wow!  All fixed.  I ran defaults delete -g which did not show immediate improvement, but then I rebooted.  I must admit I did a Safe Boot, just to throw in one other solution I had seen.  However, everything is back to normal.  Thanks very much.

  • I am using Dreamweaver cc 2014 and after applying css styles to my fluid grid layout I lose the resize, delete, duplicate and move up/ down ability.

    I am using Dreamweaver cc 2014 and after applying css styles to my fluid grid layout I lose the resize,delete, duplicate an move up/ down ability.
    For this reason I cannot build new pages by copying one page to create another.
    I have a third style sheet that I use for the navigation styles  and h1 -h6 ect. tags. and I am also using a css drop menu, can one of these be the problem?
    The css menu I am using has the following script - I goes at the bottom of the html page. Before the closing body tag,
    <script>
    $(function () {
      $("#nav").tinyNav();
    </script>
    I am also using the following for image control - I place it towards the top of the fluid
    grid style sheet.
        box-sizing: border-box; /* Opera/IE 8+ */
        -moz-box-sizing: border-box; /* Firefox, other Gecko */
        -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    Can some one please help.

    I am using Dreamweaver cc 2014 and after applying css styles to my fluid grid layout I lose the resize,delete, duplicate an move up/ down ability.
    This implies there is something broken in your FluidGrid Layout CSS file.   It  could be something simple like a missing semi-colon or curly bracket.   Run your code through the W3C validation tools below to check for errors.  NOTE:  ignore reported errors in boilerplate.css
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Nancy O.

  • Why does the move tool and the resize function freeze when I insert pictures to a layer?

    This is very annoying. I was stupid enough to buy a one year subscription to Photoshop CC, only to find that it is ruining my happiness. I am trying to run it on a brand new Macbook Pro 15 retina i7 running Yosemite, and everything works fine, except for this one thing - when I drag a new photo into a layer, the resize function and the move tool stops working for a very long time. If I am patient enough, the functions will finally wake up. Is there a way to get around this problem?  I have searched the forum without any luck, and I am just about to start jumping up and down, calling Adobe by names that will make my neighbors cover up their ears. $/!"%%#/&%"#W)!ÆY!!!

    Right-mouse on the Synaptics toolbar icon  to bring up Mouse Properties, select the Device Settings tab, press Settings to bring up Properties for Synatpics ClickPad, on the left open Pointing... Sensitivity... Palm Check.  This is a feature to prevent accidental touchpad movement by your palm while you're typing.  So it prevents use of the touch pad when keys are directly used.
    Good luck!

  • Disabling Maximize option from JFrame without disabling the resizing option

    Hi all,
    I want to know how we can disable the maximize option of a JFrame window without disabling the resizing option. I have tried JFrame.resizable(false). It disables both maximizing and resizable option. But I need the resizable option to be working.
    Anyone can help me?
    Thanks in Advance

    this works OK on 1.5.0_05 (unsure about other versions)
    and you'll lose the minimize as well
    import javax.swing.*;
    import java.awt.*;
    class Testing
      public void buildGUI()
        JFrame f = new JFrame("JFrame");
        f.setUndecorated(true);
        f.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
        f.setSize(400,300);
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging

    Contexts: I am very competent with GFX and have worked on many projects.
    When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging in the same render. It snaps again. I don't want to re-size from the canvas dimensions, I want to resize from the render's original dimensions.

    Ap_Compsci_student_13 wrote:
    ok sorry but doesn't sscce say to post the whole code?the first S is Short, and yes, it needs to be all the code needed to illustrate the problem and let use reproduce it. If you were developing a new Web framework, your example might be short, but for a student game it's very long.

  • The resize tool just don't appear in my ai CS6

    The resize tool just don't appear. When I try to resize, it only turn out that I only move my text box. Is there something wrong with my software?

    Sorry, think I need I didn't make myself clear. It's the textbox that I am having problem.
    The resize tool just didn't appear when I place the cursor over the edge of the textbox.
    It end up only moving the whole textbox.
    Is there a bug with my software?

  • How to save the content of a JTextArea into a txt file?

    Hi, I want to save the content of a JTextArea into a txt file line by line. Here is part of my code(catch IOException part is omitted):
    String s = textArea.getText();
    File file = new File("file.txt");
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    bw.write(s);
    bw.close();
    But I found in the file all is binary code instead of text, any people can help me?
    Thanks in advance

    I can see text in the file now, but the problem is
    when I write three lines in textarea, for example
    111
    222
    333
    then I open the txt file with notepad, it is
    111222333
    How to save them line by line? Use a PrintWriter. It lets you write lines (it's the same class as System.out).
    http://java.sun.com/j2se/1.4/docs/api/java/io/PrintWriter.html

  • How can i disable the Enter key in JTextArea?

    How can i disable the Enter key in JTextArea?
    When i press Enter key in JTextArea,I hope JTextArea do nothing.
    Thanks!

    HI, I've the same problem;
    uncle_alice solution works fine, but if I paste in textArea a multi-line text,
    this last results on more lines (rows);
    Isn't possible to avoid this?
    Alternatively, how can I disable cut/copy/paste on TextArea?
    Thank you in advance.
    MargNat
    Message was edited by:
    MargNat

  • Intercept the resize event of the header of the column

    hi
    how to intercept the resize event of the header of the column

    Add a changeListener to the width property:
        firstNameCol.widthProperty().addListener(new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldvalue, Object newValue) {
                    System.out.println("The column width is changed: New width is " + newValue);
            });

  • How to print the all content of JTextArea to several pages

    Hi there, my application have a JTextArea and user can type text in. When the jbPrint button is pressed, the all content of JTextArea should be printed to papers. But now my application can only print out the first page even the content of JTextArea is 3-page length, does anyone can give me some clue or example? Thanks in advance.!! Really hurry!!

    Use freely downloadable smart jprint classes from http://www.activetree.com. This package also allows you to print contents of any kind of JTextComponent such as JTextField, JTextArea, JEditorPane, and JTextPane.
    Print the swing components with or without showing in the UI. Line breaking is done automatically for you and prints in multiple pages.
    JTable printing is specially interesting.

Maybe you are looking for

  • Installation problem on redhat 6.0, class not found

    I have followed the instructions for installing oracle 8i. When i run runIns.sh I get the following error message: class not found: oracle.sysman.oii.oiic.OiicInstaller Does anyone know what this means? and what do i have to do?

  • Camera Raw update for CS2

    Will Adobe be supporting camera raw for CS2 any more? I got CS2 last year and I can't afford to update to CS3. CS2 camera raw 3.7 does not read Canon D40 raw file.

  • How do I clean out my cache to speed up computer

    I have a MacBook Pro.  It has slowed down quite a bit and I would like to clean it up to speed it up.  I am open to suggestions to do this. thanks

  • Modify PR in external opreation

    Hello During external operation creation we need to modify EBAN table to add an indicator. I tried EXIT´S COZF0001 COZF0002 But they don´t export the field that I need. Is there any BADI or enhancement that could help us modify EBAN before PR creatio

  • UPC rebate help/apple  care protection plan

    I'm confused as to which UPC they want. It's the one with the serial/part numbers right? There are like 3 or 4 labels on my box. And on my Ipod, do they want me to cut out the little tiny UPC label to the Ipod box? (i could only find a shipping label