Invisible JTextArea in a JScrollPane

I want to have an invisible JTextArea in a JScrollPane (i only want a thin border either vieport border or JTextArea border). i tried setOpaque(false) for JTextArea, JScrollPane and both, and it wont work, i dont know why. Could anyone help me?

This poster is 0 for 3 in responding to previous postings he has made.I did notice - that's why I didn't post the link.
he/she might now learn how to do a search (for when future questions are ignored)
What do you think the chances are he'll bother to thank anyone for the help
he received on this posting?Nil
a 'thank you' does go a long way to getting the next query answered, but I'd prefer just
an acknowledement of "it works/doesn't work" - makes it so much easier, when
searching the forums, when you spot a "yes, that works" at the end.

Similar Messages

  • Scrolling of a JTextArea in a JScrollPane

    I have a JTextArea in a JScrollPane.
    It is for a chat and I am constantly appending messages at the bottom of the JTextArea.
    Currently the scrollPanel is scrolling the view so the last line is visible for quite some lines, which is what I want, but from a certain amount of text in the textarea it stops doing that.
    Why does it scroll along at first and then suddenly stops?

    Actually it is a JTextPane instead of JTextArea. My bad.
    And actually it are 2 JTextPanes with a common Document where I am appending the text on (and at the appending I don't have the references to the textpanes).
    Maybe I can add document listeners to the components that have the refs to the textpanes and set the caret position there?

  • How to repaint a JTextArea inside a JScrollPane

    I am trying to show some messages (during a action event generated process) appending some text into a JTextArea that is inside a JScrollPane, the problem appears when the Scroll starts and the text appended remains hidden until the event is completely dispatched.
    The following code doesnt run correctly.
    ((JTextArea)Destino).append('\n' + Mens);
    Destino.revalidate();
    Destino.paint(Destino.getGraphics());
    I tried also:
    Destino.repaint();
    Thanks a lot in advance

    Correct me if I am wrong but I think you are saying that you are calling a method and the scrollpane won't repaint until the method returns.
    If that is so, you need to use threads in order to achieve the effect you are looking for. Check out the Model-View-Contoller pattern also.

  • JTextArea within a JScrollPane within a JSplitPane

    public class CamoDataGUI
         JScrollPane primaryPane;
         JTextArea infoTextArea;
         public CamoDataGUI()
              infoTextArea = new JTextArea("Information", 10,10);
              primaryPane = new JScrollPane(infoTextArea);
         public JScrollPane getContent()
              return primaryPane;
    }Its simply not visible. getContent() is being used to provide one of the values for the SplitPane constructor that asks for an orientation and a left and right component.
    any ideas as to why its MIA?
    Thanks!

    I would like to apologize before anyone responds. I added the wrong class into the constructor of my splitpane.

  • JTextArea within a JScrollPane

    Hi!
    I've searched through the Project Swing archive and found lots of questions regarding how you ensure that when text is entered into a JTextArea control (via the append() method) the JScrollPane automatically scrolls to the position where the text was appended.
    Unfortunately I haven't yet found a satisfactory solution to this issue.
    I have a JTextArea control within a JScrollPane control. I start a seperate thread in order to perform some processing. This operation being run within this thread needs to provide progress information to the user and I present this progress information via the JTextArera control. Although the information is displayed within the JTextArea the JScrollPane unfortunately doesn't scroll down so that the last message entered into the JTextArea is visible. The user needs to scroll down manually in order to see the messages.
    I have read that if you invoke JTextArea.setText() or JTextArea.append() from within a thread otherthan the event dispatching thread then the JScrollPane will have no knowledge that text as been added. The article suggested using SwingUtilities.invokeLater(Runnable run) to ensure that the call to JTextArea.setText() or JTextArea.append() is performed within the event dispatching thread. I did create a Runnable class whose sole purpose was to call JTextArea.append() with message information but still the JScrollPane fails to automatically scroll as successive lines of text are being added to the JTextArea control.
    Can somebody please shed some light on my problem?

    Here's a simple program that works for me. Note, if you comment out the setCaretPosition() method it stops working.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestTextArea extends JFrame
         JTextArea textArea;
    public TestTextArea()
         JPanel panel = new JPanel();
         setContentPane( panel );
         panel.setPreferredSize( new Dimension( 200, 200 ) );
              textArea = new JTextArea( "one two", 3, 15 );
              JScrollPane scrollPane = new JScrollPane( textArea );
              panel.add( scrollPane );
              JTextArea textArea2= new JTextArea( "abcd", 3, 15 );
              textArea2.setPreferredSize( new Dimension( 50, 10 ) );
              panel.add( textArea2 );
         public void updateTextArea2()
              int line = 0;
              while ( true )
                   textArea.append( "\nline: " + ++line );
                   textArea.setCaretPosition( textArea.getText().length() );
                   try
                        Thread.sleep(1000);
                   catch (Exception e) {}
    public static void main(String[] args)
    TestTextArea frame = new TestTextArea();
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.pack();
    frame.setVisible(true);
              frame.updateTextArea2();

  • Disabling JTextArea in a JScrollPane

    Hello,
    I have an application that contains some JTextFields
    and a JScrollPane with a JTextArea as the viewport.
    The JTextArea is readonly for displaying messages with
    setEnable to false (setEditable and setFocusable are also false).
    The problem is that I can tab thru the fields fine,
    skipping over the scroll pane, however as soon as a
    message is deposited in the scroll pane things
    screw up. What happens is that as I tab
    down to the scroll pane, I loose my cursor and I
    have to tab again to get it back. It is like it gets lost when I try to tab past scroll pane.
    Is it possible that something is being added to the focus
    cycle when I insert a string into the JTextArea?
    Thanks in Advance
    KarlBH

    Also make sure that the JScrollBars are set to not focus.

  • JTextArea in  a JScrollPane autoscrolling chatroom...

    How can I get the JScrollPane to autoscroll and stay at the bottom? It can't be locked at the bottom either because you couldn't scroll up to see what someone had said earlier. Any idea's on this? I'm stumped.

    Sorry, don't have an answer for your latest question, but I was thinking about another of your questions. You only want it to scroll down if it is already at the bottom (like most chat clients). Try:
    JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    if(scrollBar.getValue() == scrollBar.getMaximum() )
        scrollBar.setValue( scrollBar.getMaximum() );Except that won't work because you'll have already added a line, and the scrollbar won't be at maximum. You could introduce a window, ie, if the scrollbar value is within 5 of the maximum, keep scrolling down.... but if someone sends a message longer than 5 lines, you're screwed....
    Seemed like a good idea to begin with, but I think it introduces more problems.
    Maybe you'll find it useful anyway.
    Good luck,
    Radish21

  • JScrollPane with JTextArea

    I'm creating a program where a user enters a string into a JTextField and then that string is appended to a new line in a JTextArea that is inside of a JScrollPane. I wanted to know how I could make it so that each time a line is appended to the JTextArea that the JScrollPane scrolls down to the bottom left, showing the new line? (If i don't touch the JScrollPane, this works on its own but after I scroll around it doesnt update the view to the bottom anymore).
    Thanks,
    swing can be a bit confusing at times.

    http://java.sun.com/docs/books/tutorialJWS/uiswing/components/ex6/TextDemo.jnlp
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html

  • JScrollPane w/ JTextArea problems

    I've written a simple terminal for a project I'm working on, with a JTextField for inputs and a JTextArea to display outputs. The JTextArea uses a JScrollPane to let it scroll vertically, and wraps text to avoid horizontal scrolling.
    My problem is this: when I append text to the text area, the scroll pane sometimes scrolls to the bottom, sometimes scrolls part-way, and sometimes doesn't move at all. Ideally, I'd like to have the scroll pane always pushed to the bottom. Does anyone know what causes this kind of behaviour? What input causes the bar to scroll, and what input doesn't?
    thanks,
    Andrew

    I don't know what causes the kind if behaviour you described, but this is how you get the scrollPane to scroll to the bottom:
    int bottom = scrollPane.getVerticalScrollBar().getMaximum();
    scrollPane.getVerticalScrollBar().setValue(bottom);

  • JScrollPane is not making my JTextArea scrollable....

    I'm making a little chat client for school and I'm having trouble getting my GUI to work right. I'm basically having two problems:
    1. When I put my JTextArea's in JScrollPane's, they aren't becoming scrollable. When I type on it the text just goes off the JTextArea and doesn't scroll. I can't understand why.
    2. When I don't specify a preferred size for my JTextArea's they shrink up to as small as possible and are unusable. When I do specify one they don't stretch if I increase or decrease the size of the window. I basically want them to use up as much space as possible.
    Here's my code:
    package main;
    import javax.swing.*;
    import java.awt.*;
    public class Main {
         private JFrame frame;
         private JPanel panel,output,input;
         private JTextArea area,field;
         private JButton button;
         public Main(){
              frame = new JFrame("Chat Window");
              panel = new JPanel();
              output = new JPanel();
              input = new JPanel();
              area = new JTextArea();
              field = new JTextArea();
              button = new JButton("Send");
              button.setSize(50,20);
              //area.setPreferredSize(new Dimension(300,300));
              //field.setPreferredSize(new Dimension(240,100));
              output.add(new JScrollPane(area),"Center");
              input.add(new JScrollPane(field),"West");
              input.add(button,"East");
              panel.add(new JSplitPane(JSplitPane.VERTICAL_SPLIT,true,output,input));
              frame.add(panel);
              frame.setSize(300,450);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setResizable(true);
              frame.setVisible(true);
         public static void main(String...a){
              Main main = new Main();
    }

    How about something like this?:
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    public class Main
        private JFrame frame3;
        private JPanel outputPnl, inputPnl;
        private JTextArea outputTxt, inputTxt;
        private JButton btn3;
        private void wtf3()
            frame3 = new JFrame();
            outputTxt = new JTextArea();
            inputTxt = new JTextArea();
            btn3 = new JButton("Send");
            outputPnl = new JPanel();
            inputPnl = new JPanel();
            outputPnl.setLayout(new GridLayout());
            outputPnl.add(new JScrollPane(outputTxt));
            inputPnl.setLayout(new BorderLayout());
            inputPnl.add(new JScrollPane(inputTxt), BorderLayout.CENTER);
            JPanel btnPanel = new JPanel();
            btnPanel.add(btn3, BorderLayout.CENTER);
            btnPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            inputPnl.add(btnPanel, BorderLayout.EAST);
            JSplitPane splitP3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, outputPnl, inputPnl);
            frame3.getContentPane().add(splitP3);
            frame3.setSize(600, 450);
            frame3.setLocationRelativeTo(null);
            frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame3.setVisible(true);
            splitP3.setDividerLocation(0.8);       
        public Main()
            wtf3();
        private static void createAndShow()
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    Main mn = new Main();
        public static void main(String[] args)
            createAndShow();
    }

  • JOptionPane setMaximumSize with a JScrollPane as the object doesn't work

    I am trying to use a JOptionPane for error messages. I'm trying to make the JOptionPane dialog be a minimum of 500x100 and a maximum size of 500x450 depending on the amount of text in the JTextArea inside the JScrollPane that's being passed into JOptionPane. I've tried both JOptionPane.showMessagePane(), and instantiating a JOptionPane and then setting its maximumSize, neither of which work as expected. Here is the relevant code:
    public static void doCommonMessagePane( Component parent, String optMsg,
                                             String title, int msgType )
        JTextArea msg = new JTextArea( optMsg );
        JScrollPane jsp = new JScrollPane( msg );
        initOptionPaneComponents( msg, jsp );
        Dimension maxSize =new Dimension(500, 450) ;
        JOptionPane op = new JOptionPane(jsp, msgType);
        op.setMaximumSize(maxSize);
        op.revalidate();
        op.setVisible(true);
    //here is me also trying showMessageDialog
    //    JOptionPane.showMessageDialog(parent, jsp, title, msgType);
      private static void initOptionPaneComponents( JTextArea ta, JScrollPane sp )
              Color bg = UIManager.getColor( "Panel.background" );
              Dimension jspSz = new Dimension( 500, 75 );
              Dimension max = new Dimension( 500, 450 );
              ta.setMargin( new Insets( 5, 10, 10, 5 ) );
              ta.setColumns( 50 );
              ta.setLineWrap( true );
              ta.setWrapStyleWord( true );
              ta.setEditable( false );
              ta.setEnabled( false );
              ta.setBackground( bg );
              ta.setDisabledTextColor( Color.black );
              ta.setFont( UIManager.getLookAndFeelDefaults().getFont( "Dialog" ) );
              ta.setMaximumSize(max);
              ta.setMinimumSize(jspSz);
              sp.getViewport().add( ta );
         //sp.setPreferredSize( jspSz );
              sp.getViewport().setMaximumSize(max);
              sp.getViewport().setMinimumSize(jspSz);
              sp.setBorder( BorderFactory.createLoweredBevelBorder() );
              sp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
         //     sp.setPreferredSize( jspSz );
           sp.setMinimumSize(jspSz);
              sp.setMaximumSize( max );
         }

    When the JScrollPane is placed into the CENTER position the JOptionPane ignores the maxSize of both the JScrollPane and the JTextArea and stretches both of these out to 500x700 so that all text is visible. You still miss the basic concept.
    The answer is it depends! First the size of the dialog needs to be determined.
    If you use dialog.pack() then the preferred size of all components is used to determine the size of the dialog and the scrollpane will be whatever preferred size you gave it. If you leave the preferred size at (0, 0) then the scrollpane and text area will be invisible.
    If you use dialog.setSize(???, ???), then the size of the scrollpane will be adjusted to fit the available space.
    The amount of text in the text area is irrelevant in determining the size of the scrollpane. It is relevant in determining whether scrollbars will appear or not once the scrollpane is displayed.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.

  • How do you add a Vertical scrollbar to a JTextArea?

    How do you add a Vertical scrollbar to a JTextArea? This is what I've tried so far but it hasn't worked. I got that off of someone asking a similiar question here.
    aTextArea = new JTextArea(10, 40);
             JScrollPane scrollPane = new JScrollPane(aTextArea);
             aTextArea.setText( " " );

    JScrollPane(component)
    this constructor will only show the scrollbar (vertical and/or horizontal) as needed..so, if the scrollpane viewport is larger than the component, then it will not show the scrollbar.
    you can force the scrollbar to alway show
    setHorizontalScrollBarPolicy(int policy)
    setVerticalScrollBarPolicy(int policy)

  • Selection problem in JTextArea

    hi all
    i have a TextArea in which i have some coded charecters in a group of ten charactes i treet these ten characters as a single character ,so when i delete or insert these charactes all these charactes r deleted and no other character r inserted in between , i do it with the caretListener,
    But the problem which i face is on the selection i want to select these characters as when we select some part of the URL then it is selected completely.
    help in the prob.

    this might work
    paste some text into the textArea (ensure it contains a sequence "12345")
    click anywhere in area of 12345
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    class Testing extends JFrame
      String specialChars = "12345";
      boolean settingCaret = false;
      public Testing()
        setSize(200,200);
        setLocation(300,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final JTextArea ta = new JTextArea(10,10);
        JScrollPane sp = new JScrollPane(ta);
        sp.setPreferredSize(new Dimension(175,150));
        JPanel jp = new JPanel();
        jp.add(sp);
        getContentPane().add(jp);
        pack();
        ta.addCaretListener(new CaretListener(){
          public void caretUpdate(CaretEvent ce){
            if(settingCaret == false)
              int startPos = ta.getText().indexOf(specialChars);
              if(startPos > -1)
                if(ta.getCaretPosition() >= startPos && ta.getCaretPosition() <= startPos+specialChars.length())
                  settingCaret = true;
                  ta.setSelectionStart(startPos);
                  ta.setSelectionEnd(startPos+specialChars.length());
                settingCaret = false;
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • JTextArea w/Scroll bar wont scroll AND code drops through if statements

    Hi, I'm still having trouble with the text area in the following code. When you run the code, you get the top arrow on the scroll bar, but the bottom is cut off. Also, a big problem is that no matter what choice is selected from the combo box, the code drops through to the last available value each time. Someone on the forums suggested using an array list for the values in the combo box, but I have not been able to figure out how to do that. A quick example would be apprciated.
    Thank you in advance for any help
    //Import required libraries
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.text.*;
    import java.math.*;
    import java.util.*;
    //Create the class
    public class Week3Assignment407B extends JFrame implements ActionListener
         //Panels used in container
         private JPanel jPanelRateAndTermSelection;         
         //Variables for Menu items
         private JMenuBar menuBar;    
         private JMenuItem exitMenuItem; 
         private JMenu fileMenu; 
         //Variables for user instruction and Entry       
         private JLabel jLabelPrincipal;   
         private JPanel jPanelEnterPrincipal;  
         private JLabel jLabelChooseRateAndTerm; 
         private JTextField jTextFieldMortgageAmt;
         //Variables for combo box and buttons
         private JComboBox TermAndRate;
         private JButton buttonCompute;
         private JButton buttonNew; 
         private JButton buttonClose;
         //Variables display output
         private JPanel jPanelPaymentOutput;
         private JLabel jLabelPaymentOutput;
         private JPanel jPanelErrorOutput;
         private JLabel jLabelErrorOutput;  
         private JPanel jPanelAmoritizationSchedule;
         private JTextArea jTextAreaAmoritization;
         // Constructor 
         public Week3Assignment407B() {            
              super("Mortgage Application");      
               initComponents();      
         // create a method that will initialize the main frame for the GUI
          private void initComponents()
              setSize(700,400);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      
              Container pane = getContentPane();
              GridLayout grid = new GridLayout(15, 1);
              pane.setLayout(grid);       
              //declare all of the panels that will go inside the main frame
              // Set up the menu Bar
              menuBar = new JMenuBar();
              fileMenu = new JMenu();
              fileMenu.setText("File");        
              exitMenuItem = new JMenuItem(); 
               exitMenuItem.setText("Exit");
              fileMenu.add(exitMenuItem); 
              menuBar.add(fileMenu);       
              pane.add(menuBar);
              //*******************TOP PANEL ENTER PRINCIPAL*****************************//
              // Create a label that will advise user to enter a principle amount
              jPanelEnterPrincipal = new JPanel(); 
              jLabelPrincipal = new JLabel("Amt to borrow in whole numbers");
              jTextFieldMortgageAmt = new JTextField(10);
              GridLayout Principal = new GridLayout(1,2);
              jPanelEnterPrincipal.setLayout(Principal); 
                jPanelEnterPrincipal.add(jLabelPrincipal);
              jPanelEnterPrincipal.add(jTextFieldMortgageAmt);
              pane.add(jPanelEnterPrincipal);
              //****************MIDDLE PANEL CHOOSE INTEREST RATE AND TERM*****************//
              // Create a label that will advise user to choose an Int rate and term combination
              // from the combo box
              jPanelRateAndTermSelection = new JPanel();
              jLabelChooseRateAndTerm = new JLabel("Choose the Rate and Term");
              buttonCompute = new JButton("Compute Mortgage");
              buttonNew = new JButton("New Mortgage");
              buttonClose = new JButton("Close");
              GridLayout RateAndTerm = new GridLayout(1,5);
              //FlowLayout RateAndTerm = new FlowLayout(FlowLayout.LEFT);
              jPanelRateAndTermSelection.setLayout(RateAndTerm);
              jPanelRateAndTermSelection.add(jLabelChooseRateAndTerm);
              TermAndRate = new JComboBox();
              jPanelRateAndTermSelection.add(TermAndRate);
              TermAndRate.addItem("7 years at 5.35%");
              TermAndRate.addItem("15 years at 5.5%");
              TermAndRate.addItem("30 years at 5.75%");
              jPanelRateAndTermSelection.add(buttonCompute);
              jPanelRateAndTermSelection.add(buttonNew);
              jPanelRateAndTermSelection.add(buttonClose);
              pane.add(jPanelRateAndTermSelection);
              //**************BOTTOM PANEL TEXT AREA FOR AMORITIZATION SCHEDULE***************//
              jPanelAmoritizationSchedule = new JPanel();
              jTextAreaAmoritization = new JTextArea(26,50);
              // add scroll pane to output text area
                   JScrollPane scrollBar = new JScrollPane(jTextAreaAmoritization, 
                   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                     JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              jPanelAmoritizationSchedule.add(scrollBar);
                pane.add(jPanelAmoritizationSchedule);
              //***************ADD THE ACTION LISTENERS TO THE GUI COMPONENTS*****************//
              // Add ActionListener to the buttons and menu item
              exitMenuItem.addActionListener(this);
              buttonCompute.addActionListener(this);         
              buttonNew.addActionListener(this);
              buttonClose.addActionListener(this);
              TermAndRate.addActionListener(this);
              jTextFieldMortgageAmt.addActionListener(this);
              //*************** Set up the Error output area*****************//
              jPanelErrorOutput = new JPanel();
              jLabelErrorOutput = new JLabel();
              FlowLayout error = new FlowLayout();
              jPanelErrorOutput.setLayout(error);
              pane.add(jLabelErrorOutput);
              setContentPane(pane);
              pack();
              setVisible(true);
         //Display error messages
         private void OutputError(String ErrorMsg){
              jLabelErrorOutput.setText(ErrorMsg);
              jPanelErrorOutput.setVisible(true);
         //create a method that will clear all fields when the New Mortgage button is chosen
         private void clearFields()
              jTextAreaAmoritization.setText("");
              jTextFieldMortgageAmt.setText("");
         //**************CREATE THE CLASS THAT ACTUALLY DOES SOMETHING WITH THE EVENT*****//
         //This is the section that receives the action source and directs what to do with it
         public void actionPerformed(ActionEvent e)
              Object source = e.getSource();
              String ErrorMsg;
              double principal;
              double IntRate;
              int Term;
              double monthlypymt;
              double TermInYears = 0 ;
              if(source == buttonClose)
                   System.exit(0);
              if (source == exitMenuItem) {      
                       System.exit(0);
              if (source == buttonNew)
                   clearFields();
              if (source == buttonCompute)
                   //Make sure the user entered valid numbers
                   try
                        principal = Double.parseDouble(jTextFieldMortgageAmt.getText());
                   catch(NumberFormatException nfe)
                        ErrorMsg = (" You Entered an invalid Mortgage amount"
                                  + " Please try again. Please do not use commas or decimals");
                        jTextAreaAmoritization.setText(ErrorMsg);
                   principal = Double.parseDouble(jTextFieldMortgageAmt.getText());
                    if (TermAndRate.getSelectedItem() == "7 years at 5.35%") ;
                        Term = 7;
                        IntRate = 5.35;
                    if (TermAndRate.getSelectedItem()  == "15 years at 5.5%") ;
                        Term = 15;
                        IntRate = 5.5;
                    if (TermAndRate.getSelectedItem() == "30 years at 5.75%") ;
                        Term = 30;
                        IntRate = 5.75;
                   //Variables have been checked for valid input, now calculate the monthly payment
                   NumberFormat formatter = new DecimalFormat ("$###,###.00");
                   double intdecimal = intdecimal = IntRate/(12 * 100);
                   int months = Term * 12;
                   double monthlypayment = principal *(intdecimal / (1- Math.pow((1 + intdecimal),-months)));
                   //Display the Amoritization schedule
                   jTextAreaAmoritization.setText(" Loan amount of " + formatter.format(principal)
                                                    + "\n"
                                                    + " Interest Rate is " +  IntRate + "%"
                                            + "\n"
                                            + " Term in Years "  + Term
                                            + " Monthly payment "+  formatter.format(monthlypayment)
                                            + "\n"
                                            + "  Amoritization is as follows:  "
                                            + "------------------------------------------------------------------------");
         public Insets getInsets()
              Insets around = new Insets(35,20,20,35);
              return around;
         //Main program     
         public static void main(String[]args) { 
              Week3Assignment407B frame = new Week3Assignment407B(); 
       }

    here's your initComponents with a couple of changes, the problem was the Gridlayout(15,1)
    also, the scrollpane needed a setPreferredSize()
      private void initComponents()
        setSize(700,400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Container pane = getContentPane();
        JPanel pane = new JPanel();
        //GridLayout grid = new GridLayout(15, 1);
        GridLayout grid = new GridLayout(2, 1);
        pane.setLayout(grid);
        menuBar = new JMenuBar();
        fileMenu = new JMenu();
        fileMenu.setText("File");
        exitMenuItem = new JMenuItem();
        exitMenuItem.setText("Exit");
        fileMenu.add(exitMenuItem);
        menuBar.add(fileMenu);
        //pane.add(menuBar);
        setJMenuBar(menuBar);
        jPanelEnterPrincipal = new JPanel();
        jLabelPrincipal = new JLabel("Amt to borrow in whole numbers");
        jTextFieldMortgageAmt = new JTextField(10);
        GridLayout Principal = new GridLayout(1,2);
        jPanelEnterPrincipal.setLayout(Principal);
          jPanelEnterPrincipal.add(jLabelPrincipal);
        jPanelEnterPrincipal.add(jTextFieldMortgageAmt);
        pane.add(jPanelEnterPrincipal);
        jPanelRateAndTermSelection = new JPanel();
        jLabelChooseRateAndTerm = new JLabel("Choose the Rate and Term");
        buttonCompute = new JButton("Compute Mortgage");
        buttonNew = new JButton("New Mortgage");
        buttonClose = new JButton("Close");
        GridLayout RateAndTerm = new GridLayout(1,5);
        jPanelRateAndTermSelection.setLayout(RateAndTerm);
        jPanelRateAndTermSelection.add(jLabelChooseRateAndTerm);
        TermAndRate = new JComboBox();
        jPanelRateAndTermSelection.add(TermAndRate);
        TermAndRate.addItem("7 years at 5.35%");
        TermAndRate.addItem("15 years at 5.5%");
        TermAndRate.addItem("30 years at 5.75%");
        jPanelRateAndTermSelection.add(buttonCompute);
        jPanelRateAndTermSelection.add(buttonNew);
        jPanelRateAndTermSelection.add(buttonClose);
        pane.add(jPanelRateAndTermSelection);
        jPanelAmoritizationSchedule = new JPanel();
        jTextAreaAmoritization = new JTextArea(26,50);
        JScrollPane scrollBar = new JScrollPane(jTextAreaAmoritization,
          JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollBar.setPreferredSize(new Dimension(500,100));//<------------------------
        jPanelAmoritizationSchedule.add(scrollBar);
        getContentPane().add(pane,BorderLayout.NORTH);
        getContentPane().add(jPanelAmoritizationSchedule,BorderLayout.CENTER);
        exitMenuItem.addActionListener(this);
        buttonCompute.addActionListener(this);
        buttonNew.addActionListener(this);
        buttonClose.addActionListener(this);
        TermAndRate.addActionListener(this);
        jTextFieldMortgageAmt.addActionListener(this);
        jPanelErrorOutput = new JPanel();
        jLabelErrorOutput = new JLabel();
        FlowLayout error = new FlowLayout();
        jPanelErrorOutput.setLayout(error);
        //pane.add(jLabelErrorOutput);not worrying about this one
        //setContentPane(pane);
        pack();
        setVisible(true);
      }instead of
    if (TermAndRate.getSelectedItem() == "7 years at 5.35%") ;
    Term = 7;
    IntRate = 5.35;
    you would be better off setting up arrays
    int[] term = {7,15,30};
    double[] rate = {5.35,5.50,5.75};
    then using getSelectedIndex()
    int loan = TermAndRate.getSelectedIndex()
    Term = term[loan];
    IntRate = rate[loan];

  • JTextArea & Gridbag layout - max size of control

    Hello everyone:
    I am currnetly using a JTextArea with the Gridbag layout. I want to limit the size of the JTextArea. Found an article when I did a "search" that says the size is actually controlled by the layout manager. Have tried setMaximunSize(), no luck. It appears the layout manager ignores this. The problem I am having is that I can set the size I want, however if the user types a lot of text in to the JTextArea, the control expands and over and "pushes" the controls below it down. How do I keep the layout manager from allowing this to happen?
    Thanks in advance, Bart

    Hello everyone:
    I am currnetly using a JTextArea with the Gridbag
    layout. I want to limit the size of the JTextArea.
    Found an article when I did a "search" that says the
    size is actually controlled by the layout manager.
    Have tried setMaximunSize(), no luck. It appears the
    layout manager ignores this. The problem I am having
    is that I can set the size I want, however if the user
    types a lot of text in to the JTextArea, the control
    expands and over and "pushes" the controls below it
    down. How do I keep the layout manager from allowing
    this to happen?
    Thanks in advance, Bart Do you wish to allow the user to enter as much text as he or she likes? If so, wrap the JTextArea in a JScrollPane and set the preferred size of the JScrollPange to the area you'd like the pane to consume. It'll listen, no doubt. :)

Maybe you are looking for

  • Can u use more than one apple account on your device and itunes

    Can u use more than one apple account on your device and itunes

  • SmartForms: Trigger NEXT page in a loop Not in MAIN Window?

    Thanks for all of your responses. I know understand that my list I am creating in my loop does not trigger to NEXT page because it is not in my MAIN Window. I am a little leary of moving this non MAIN window logic into my MAIN window, because I final

  • How to create infotype while creating another infotype

    Hi All, I have below requirement... Whenever user create infotype 0008, infotype 0014 should be created for the wages available in a  Z table. I created a dynamic action and call function HR_INFOTYPE_OPERATION. When i debug the routine function succe

  • Coding on a Picture in Java

    Hi guys, i have a project to do and it has to be done in Java, unfortunately i'm not too good with java. I need to create a Matrix in java and at the same time try and superimpose a picture on it. The picture will be that of a street intersection tha

  • Safari History does not clear

    I can't seen to clear URL history in Safari. I have clicked "clear history" in the history menu, and also "reset safari" in the safari menu. History appears cleared, but entering a part of a URL brings up URL history! Powerbook G4   Mac OS X (10.4.5)