Moving around in a  j scroll pane.

I have a JTextArea inside a JScrollPane and I'm trying to get the scroll pane to goto a certain line number that I want by using:
TA.setCaretPosition(10*linenumber);the linenumber is the line number the user enters and then the 10 is just the pixel it will go down because the interval I counted between each line is about 10. But it doesn't seem to move at all, what am I doing wrong?

I guess it doesn't work like that.
What you are doing is moving the caret to a certain position in the document. The setCaretPosition method expects the CHARACTER position in the document to which to move, and has nothing to do with pixels...
But this won't be moving the scroll pane at all. I think what you are looking for is the TA.scrollRectToVisible(Rectangle) method. You pass a Rectangle on the textarea that you want to be made visible, and the call is repassed to the parents until a JViewPort is found, which is then scrolled.
To calculate this rectangle you could use TA.getRows() and TA.getSize().height, for example, to determine how much space each row is really occupying.
Best regards,
Marcos.

Similar Messages

  • Problem with parallax scrolling moving around randomly

    I have an ipad air. My problem is with the parallax scrolling. It just seems to be moving randomly around the screen even when the ipad is steady and it's quite difficult to get the ipad to change orientation when I stand it on its side. I've reset  the ipad and turned it on and off a few times. Has anyone been having this problem and know how to fix it. I know you can turn it off but I don't really want to.

    Hi there
    I am experiencing the exact same problem with my Ipad Air. Did you manage to find a solution yet? Im hoping it isnt a hardware problem either. Orientation not really co-operating. Background image moving around the whole time as if trying to settle, even when device dead still?!
    Please do let me know
    Thanks
    Greg

  • InDesign CC (CS7) Scrolling and moving around so slow and choppy!!

    Adobe - please send out an update for CC!! Me and IT dept checked my Mac system requirements and all is fine there. Moving around on my pages (e.g. hand tool) and scrolling is so choppy, slow, and lags. And sometimes my art disappears and I'm looking at blank pages until I stop or let refresh for a bit.
    I also noticed that when I'm in "preview mode," CPUs go down and much less choppy and smoother moving around, but I can't work in preview mode. (e.g. I need hidden characters on for Indexing markers, and my frames and guides on).
    CS6 works MUCH smoother, but I can't save client files down if that's how they provide them to me. Please recommend any other suggestions or hopefully an update will help this issue.

    I also hop on the issue to give it some more attention.
    InDesign scolling lags badly, Tools are slow, Program crashes. Equal problems using Illustrator/Photoshop.
    My Mac is not the newest – but CS6 was running like a charm before.
    Some TechSpecs:
    OSX Mavericks (Clean Install)
    Core2Duo 2.4 GhZ
    8GB 1067MhZ DDR3 RAM
    OCZ Vertex SSD 256GB
    Currently using the Test-Period of CC on this machine to figure out how it works – but that should not be a problem as the Programs are the same. As a student I would prefer the current discount offer (the normal rate is al little too much for me right now). Please fix this problem, otherwise I can't buy it the next year. Btw. Subscription method is great compared to the old payment method.

  • Photoshop CS2 redraw garbage when moving around an image window on my G4 laptop

    Hi.I recently had to reinstall Photoshop CS2 onto my Mac Laptop 1.5 GHz PowerPC G4, running system 10.4.11, which required a new hard drive after the old one died. I am immediatly encountering a serious redraw/image repositioning problem in Photoshop that I have never seen before, and in Imageready as well. This does not happen in Macromedia Fireworks 8 however.
    I am zoomed into an image. Using the hand tool, or the scroll bars or the arrows, as soon as I move an image little messed up line graphic glitches appear and stay in place for the remainder or working with an image, and ultimately covers the image completely after moving around within it a number of times. you can see examples of this in these screenshots I've uploaded:
    http://pixeljam.com/temp/photoshopRedrawGarbage/moveGarbage04.gif
    http://pixeljam.com/temp/photoshopRedrawGarbage/moveGarbage03.gif
    http://pixeljam.com/temp/photoshopRedrawGarbage/moveGarbage02.gif
    and the lines stay the same size and position even when zooming in. here's the same image w/ the same defects zoomed out and in:
    http://pixeljam.com/temp/photoshopRedrawGarbage/moveGarbage01.gif
    http://pixeljam.com/temp/photoshopRedrawGarbage/moveGarbage01_zoomed.gif
    I've tried trashing & re-installing photoshop completely, tried running it before the updates needed from the original Photoshop application disk, and after. still the same problem.
    This occurs only when using the laptop on its own. When I hook it up to my Apple Studio Cinema Display, it works fine. The problem does not occur on the Cinema Display OR the laptop screen! it's very odd. Basically, the laptop is now something I cannot actually use away from my desk until this is resolved.
    Has anyone ever encountered this or possibly have any suggestions or advice? Thanks so much!
    -Rich
    And here are some more specs on my computer & hardware:
    Hardware Overview:
    Machine Name: PowerBook G4 12"
    Machine Model: PowerBook6,8
    CPU Type: PowerPC G4 (1.5)
    Number Of CPUs: 1
    CPU Speed: 1.5 GHz
    L2 Cache (per CPU): 512 KB
    Memory: 1.25 GB
    Bus Speed: 167 MHz
    Boot ROM Version: 4.9.0f0
    Serial Number: 4H5456AZRJ7
    Sudden Motion Sensor:
    State: Enabled
    Version: 1.0
    GeForce FX Go5200:
    Chipset Model: GeForce FX Go5200
    Type: Display
    Bus: AGP
    VRAM (Total): 64 MB
    Vendor: nVIDIA (0x10de)
    Device ID: 0x0329
    Revision ID: 0x00b1
    ROM Revision: 2122
    Displays:
    Color LCD:
    Display Type: LCD
    Resolution: 1024 x 768
    Depth: 16-bit Color
    Built-In: Yes
    Core Image: Supported
    Mirror: Off
    Online: Yes
    Quartz Extreme: Supported
    Cinema Display:
    Display Type: LCD
    Resolution: 1680 x 1050
    Depth: 32-bit Color
    Core Image: Supported
    Main Display: Yes
    Mirror: Off
    Online: Yes
    Quartz Extreme: Supported
    DIMM0/BUILT-IN:
    Size: 256 MB
    Type: Built-in
    Speed: Built-in
    Status: OK
    ATA Bus:
    MATSHITADVD-R UJ-845E:
    Capacity: 1.72 GB
    Model: MATSHITADVD-R UJ-845E
    Revision: DMP2
    Serial Number:
    Removable Media: Yes
    Detachable Drive: No
    BSD Name: disk5
    Protocol: ATAPI
    Unit Number: 0
    Socket Type: Internal
    OS9 Drivers: No
    S.M.A.R.T. status: Not Supported

    Hi. Thanks for your responses. There is definitely some incorrectness in the info I provided about the computer. for the Hard Drive, it's odd.. I copied and pasted that from my system profiler.. In actuality the Hard Drive is 74.53 GB. Not sure how that error occurred.
    Also I looked again at the computer's memory. I forgot the second larger 1GB memory card when I was copying and pasting from the system profiler. Sorry about that. I was in a but of a rush to get the question out.
    DIMM0/BUILT-IN:
    Size: 256 MB
    Type: Built-in
    Speed: Built-in
    Status: OK
    DIMM1/J31:
    Size: 1 GB
    Type: DDR SDRAM
    Speed: PC2700U-25330
    Status: OK
    Another thing I noticed about the problem I'm facing is that it leaves defects from mouse trails as well in the image window. None of the defects are lasting nor will they print. I close the file and they go away, if I zoom, they stay the same size. I'd agree, it sounds like a video card problem, but the reason I posted here is that only in photoshop and imageready do these problems occur. My guess, if it's the video card is that they are just programs that require more of the system. why my video card would be crapping out now, I have no idea. but I guess that's how it goes.
    But why would it work fine when hooked up to the apple cinema display? even on the laptop screen itself the problem is not present. only when the laptop is on its own.
    The computer has served me very well for almost 3 years without this problem, so that's why it's something that is not a normal problem that should be expected from this computer. I am grateful to have it & can't afford a new one.. this one is still sitting on my credit card balance. Thankfully I am under the applecare protection plan and will bring it in to the local Mac shop on monday and demonstrate the issue to them.
    Thanks for your replies.

  • Scroll pane can't align it's content

    When a Node(group fro example) is added into a scroll pane, the scroll pane automatically align the node to the upper left corner of the scroll pane's content area. How can i customize the Node's alignment(the middle center eg) in the scroll pane. When the Node's size is scaled and larger than the scroll pane's size the scroll pane's scroll bar appears, and if the Node's size shrinks and it's size becomes smaller than the scroll pane's then the Node is aligned to the middle center. it seems don't take affect if i override the scroll pane's layoutChildren method and set layoutX and layoutY property of the Node.
    If any one can give me some clue?
    thanks

    ScrollPanes are somewhat tricky to use. They don't align content, you need to use layout managers to do that or you need to layout yourself with shapes in groups using absolute co-ordinates and/or translations. The ScrollPane defines it's own viewport related coordinates and you need to layout your content within that viewport.
    How can i customize the Node's alignment(the middle center eg) in the scroll pane.Get the layoutBoundsInParent of the node, get the viewportBounds of the scrollpane and perform the translation of the node such that the center of the node is in the center of the viewportBounds (will require a little bit of basic maths to do this) by adding listeners on each property.
    When the Node's size is scaled and larger than the scroll pane's size the scroll pane's scroll bar appears, and if the Node's size shrinks and it's size becomes smaller than the scroll pane's then the Node is aligned to the middle center.Similar to above, just work with those properties.
    Not exactly a direct answer to your question, but you could try playing around with the following code if you like Saludon. It is something I wrote to learn about JavaFX's layoutbounds system. Resizing the scene and toggling items on and off will allow you to see the scroll pane. The view bounds listeners show you the properties you are interested in to achieve the effect you want.
    import javafx.application.Application;
    import javafx.beans.value.*;
    import javafx.event.*;
    import javafx.geometry.Bounds;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.layout.*;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.*;
    import javafx.stage.Stage;
    public class LayoutBoundsScrollableAnchorPane extends Application  {
      // define some controls.
      final ToggleButton stroke    = new ToggleButton("Add Border");
      final ToggleButton effect    = new ToggleButton("Add Effect");
      final ToggleButton translate = new ToggleButton("Translate");
      final ToggleButton rotate    = new ToggleButton("Rotate");
      final ToggleButton scale     = new ToggleButton("Scale");
      public static void main(String[] args) { launch(args); }
      @Override public void start(Stage stage) throws Exception {
        // create a square to be acted on by the controls.
        final Rectangle square = new Rectangle(20, 30, 100, 100); //square.setFill(Color.DARKGREEN);
        square.setStyle("-fx-fill: linear-gradient(to right, darkgreen, forestgreen)");
        // show the effect of a stroke.
        stroke.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (stroke.isSelected()) {
              square.setStroke(Color.FIREBRICK); square.setStrokeWidth(10); square.setStrokeType(StrokeType.OUTSIDE);
            } else {
              square.setStroke(null); square.setStrokeWidth(0.0); square.setStrokeType(null);
            reportBounds(square);
        // show the effect of an effect.
        effect.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (effect.isSelected()) {
              square.setEffect(new DropShadow());
            } else {
              square.setEffect(null);
            reportBounds(square);
        // show the effect of a translation.
        translate.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (translate.isSelected()) {
              square.setTranslateX(100);
              square.setTranslateY(60);
            } else {
              square.setTranslateX(0);
              square.setTranslateY(0);
            reportBounds(square);
        // show the effect of a rotation.
        rotate.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (rotate.isSelected()) {
              square.setRotate(45);
            } else {
              square.setRotate(0);
            reportBounds(square);
        // show the effect of a scale.
        scale.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (scale.isSelected()) {
              square.setScaleX(2);
              square.setScaleY(2);
            } else {
              square.setScaleX(1);
              square.setScaleY(1);
            reportBounds(square);
        // layout the scene.
        final AnchorPane anchorPane = new AnchorPane();
        AnchorPane.setTopAnchor(square,  0.0);
        AnchorPane.setLeftAnchor(square, 0.0);
        anchorPane.setStyle("-fx-background-color: cornsilk;");
        anchorPane.getChildren().add(square);
        // add a scrollpane and size it's content to fit the pane (if it can).
        final ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(anchorPane);
        square.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
          @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
            anchorPane.setPrefSize(Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()), Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
        scrollPane.viewportBoundsProperty().addListener(
          new ChangeListener<Bounds>() {
          @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
            anchorPane.setPrefSize(Math.max(square.getBoundsInParent().getMaxX(), newBounds.getWidth()), Math.max(square.getBoundsInParent().getMaxY(), newBounds.getHeight()));
        // layout the scene.
        VBox controlPane = new VBox(10);
        controlPane.setStyle("-fx-background-color: linear-gradient(to bottom, gainsboro, silver); -fx-padding: 10;");
        controlPane.getChildren().addAll(
          HBoxBuilder.create().spacing(10).children(stroke, effect).build(),
          HBoxBuilder.create().spacing(10).fillHeight(false).children(translate, rotate, scale).build()
        VBox layout = new VBox();
        VBox.setVgrow(scrollPane, Priority.ALWAYS);
        layout.getChildren().addAll(scrollPane, controlPane);
        // show the scene.
        final Scene scene = new Scene(layout, 300, 300);
        stage.setScene(scene);
        stage.show();
        reportBounds(square);
      /** output the squares bounds. */
      private void reportBounds(final Node n) {
        StringBuilder description = new StringBuilder();
        if (stroke.isSelected())       description.append("Stroke 10 : ");
        if (effect.isSelected())       description.append("Dropshadow Effect : ");
        if (translate.isSelected())    description.append("Translated 100, 60 : ");
        if (rotate.isSelected())       description.append("Rotated 45 degrees : ");
        if (scale.isSelected())        description.append("Scale 2 : ");
        if (description.length() == 0) description.append("Unchanged : ");
        System.out.println(description.toString());
        System.out.println("Layout Bounds:    " + n.getLayoutBounds());
        System.out.println("Bounds In Local:  " + n.getBoundsInLocal());
        System.out.println("Bounds In Parent: " + n.getBoundsInParent());
        System.out.println();
    }

  • Keeping focus in the viewable window of a scroll pane

    I have many text fields and text areas inside a scroll pane. When I use tab to cycle through these boxes the focus goes out of the viewable window rather then the scroll pane moving to follow the focus. Is it possible for the scroll pane to follow the focus? I would think it is. But I haven't been able to figure out how. Any ideas?
    Thanks,
    Mark

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
      FieldListener fieldListener = new FieldListener();
      final static int fieldNumber = 15;
      JPanel panel;
      public test() {
        super("Focused Scrolling");
        panel = new JPanel();
        panel.setLayout(new GridLayout(0,1));
        JTextField textField;
        for(int i = 0; i < fieldNumber; i++) {
          textField  = new JTextField("TextField # " + i);
          textField.addFocusListener(fieldListener);
          panel.add(textField);
        JScrollPane scrollPane = new JScrollPane(panel);
        getContentPane().add(scrollPane, "Center");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300,200);
        setLocation(350,200);
        setVisible(true);
      class FieldListener extends FocusAdapter {
        public void focusGained(FocusEvent e) {
          JComponent field = (JComponent)e.getSource();
          Rectangle r = field.getBounds();
          //System.out.println("r = " + r);
          // JComponent method sends message to component's
          // parent who implements scrollable interface
          panel.scrollRectToVisible(r);
      public static void main(String[] args) {
        new test();
    }

  • Putting an image in a scroll pane

    This is probably a simple question for most of you, but I need a little bit of help. How do I put a picture in a scroll pane?
    The problem I have is that I can load an image and display it, that works fine. However, let's say I am making a new frame (I generally use JFrames), and I want to have a scroll pane in it. Let's also say I have numerous buttons around the edges (using a BorderLayout, or something). How do I load an image, draw the image on-screen and have it so that it only shows up in the scroll pane without the scrollbars disappearing?
    I try to do it now, but for some reason the scroll bars of the scroll pane never show up. I can make the entire image be displayed by dragging the window edges bigger (the normal way you make windows bigger), and then I can see the entire picture. Unfortunately, the scroll bars on the scroll pane never show up if the window is too small to display the entire image. This is very puzzling, because I really don't know what I'm doing wrong. I have tried putting a panel in the scroll pane, and drawing on the panel, but still no scroll bars show up on the scroll pane if it is not big enough to show the entire picture / panel.
    I am sure that the solution is very simple, but right now that solution eludes me.

    There's an example in the swing tutorials that seems to me to do exactly what you want.
    See if http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html does the job, (less the border layout and buttons of course, but that shouldn't be too hard once you get the scroll bars working).
    I believe the default scrollbar policy will let the scroll bars appear only when needed based on the bounds and the preferred size.
    I used the example to set up a scrolling map (still just a gif image) and it works fine. If you still have trouble, you probably need to post the relevant section of code.

  • Not happy with moving around keys on the timeline

    I just changed from Final Cut to Premiere CS5.0 and I really like it. Working on a Macbook Pro i5 2.3GHZ, Mac OSX 10.7 But I am not happy with moving around on the timeline. I was used to using the up and down arrows to move to next video edit point, marker point or audio edit point. I tried everything to change it, highlighted the track etc. It only works together with the FN key, which is a bit uncomfortable. And then it definetely is not going to any audio edit points (very annoying!!!) and marker points (have to use Q and W keys). It makes me doubting if continuing with Premiere or not. Its such an esencial and easy to use tool while editing in a normal fast editing rythm. When I change it in the customize keyboard menu, into a Custom keyboard or FCP keyboard, it would ignore my changes on the arrowkeys, although it recognizes any other changes I do. Is it so complicate to change this issue in Premiere to how it is set in FCP? Its such an obvious tool, using the arow keys to move around, cannot beleive that we have to live with such a limitation. Please!!!

    Its such an obvious tool, using the arow keys to move around, cannot beleive that we have to live with such a limitation. Please!!!
    You dont have to live with that at all if you are fixed only to what you have previously done.
    It makes me doubting if continuing with Premiere or not.
    There ya go!

  • I can't sync my ipod to itunes. It looks like it is going through all the steps to sync but nothing happens. The music I moved around is not going where it should

    I can't sync my ipod to itunes. It goes through all the steps to sync but it does not sync. The music I moved around does not go where I put it. It shows up in itunes (when changing music around) but does not change it on my ipod. Can someone help me?

    Sync Session Failed to Start iTouch iOS5: Apple Support Communities
    iphone could not be synced sync session failed to start...: Apple Support Communities
    and
    Can't connect to the iTunes Store

  • Remove/Hide scroll bars in scroll panes.

    Hi all,
    I am pretty new to action script. I am building a photo gallery and I am loading the thumbnails from an XML file into a scroll pane dynamically. As the scroll pane fills up, it gets wider to accomodate the thumbnails. There is one row, and eventually, I want to have the user be able to mouse left or right and have the scroll pane scroll, versus clicking on the bar or the left/right arrows. However, in order to accomplish this, I need the scroll bars to disappear!
    Is there anyway to either remove or hide both the x and y scroll bars on a scroll pane? My scroll pane is called: thumbPane.
    Thanks in advance!
    -Rob

    Hello friend,
                       first select scrollpane.Then open parameters panel (if dont know go to window > properties > paramiters ) turn to OFF HorizontalScrollPolicy  and verticalScrollPoliy then left and right scroll Bar will not display.
    THANKS.

  • IS IT POSSIBLE TO ADD A SCROLL PANE TO A PANEL??

    Hi, Im trying to add a scroll pane to a panel but when I compile the code and try to open the form - a 'Illegal Argument Exception' is produced. Can anyone tell me whether it is possible to add a scroll pane the actual panel itself and also the code to do this.     
    Many Thanks, Karl.
    I have added some sample code I have created -
    public RequestForm(RequestList inC)throws SQLException{
              inRequestList = inC;
              displayForm();
              displayFields();
              displayButtons();
              getContentPane().add(panel);
              setVisible(true);
         public void displayForm() throws SQLException{
              setTitle("Request Form");
              setSize(600,740);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              getContentPane().setLayout(new BorderLayout());
              Border etched = BorderFactory.createEtchedBorder();
              panel = new JPanel();
              panel.setLayout( null );
              //panel.setBackground(new Color(1,90,50));
              Border paneltitled = BorderFactory.createTitledBorder(etched,"");
              panel.setBorder(paneltitled);
              scrollPane1 = new JScrollPane(panel);
              scrollPane1.setBounds(0, 0, 600, 740);
              panel.add(scrollPane1);
    }

    Hi all,
    I am still having trouble here. would it be posible to add a scrollpanel to this form? Can anyone provide me with a working piece of code so I see how it actually works.
    Any help would be greatly appreciated.
    Many Thanks, Karl.
    Code as Follows:
    /* ADMIN HELP Manual*/
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    public class AdminHelp extends JFrame implements ActionListener{
         private JButton exit;
         private JLabel heading1, help;
         private JPanel panel;
         Font f = new Font("Times New Roman", Font.BOLD, 30);
         private JScrollPane scroll;
         public AdminHelp(){
              setTitle("ADMIN Help Manual");
              setSize(400,325);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              panel = new JPanel();
              panel.setLayout(null);
              exit = new JButton("Close");
              exit.setBounds(280,260,100,20);
              exit.addActionListener(this);
              panel.add(exit);
              exit.setToolTipText("Click here to close and return to the main menu");
              getContentPane().add(panel);
              show();
              public void actionPerformed(ActionEvent event){
              Object source = event.getSource();
                   if (source == exit){
                        dispose();
              public static void main(String[] args){
                   AdminHelp frame = new AdminHelp();
                   frame.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                   System.exit(0);

  • Need help with a scroll pane

    Hello all. I am trying to get a scroll pane to work in an application that I have built for school. I am trying to get an amortization table to scroll through for a mortgage calculator. It isn't recognizing my scrollpane and I am not sure why. Could someone give me a push in the right direction.
    import javax.swing.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.text.*;
    public class MortCalcWeek3 extends JFrame implements ActionListener
         DecimalFormat twoPlaces = new DecimalFormat("#,###.00");//number format
         int L[] = {7, 15, 30};
         double I[] = {5.35, 5.5, 5.75};
         double P, M, J, H, C, Q;
         JPanel panel = new JPanel ();//creates the panel for the GUI
         JLabel title = new JLabel("Mortgage Calculator");
         JLabel PLabel = new JLabel("Enter the mortgage amount: ");
         JTextField PField = new JTextField(10);//field for obtaining user input for mortgage amount
         JLabel choices = new JLabel ("Choose the APR and Term in Years");
         JTextField choicestxt = new JTextField (0);
         JButton calcButton = new JButton("Calculate");
         JTextField payment = new JTextField(10);
         JLabel ILabel = new JLabel("Annual Percentage Rate: choose one");
         String [] IChoice = {I[0] + "", I[1] + "", I[2] + ""};
         JComboBox IBox = new JComboBox(IChoice);
         JLabel LLabel = new JLabel("Term (in years): choose one");
         String [] LChoice = {L[0] + "", L[1] + "", L[2] + ""};
         JComboBox LBox = new JComboBox(LChoice);
         JLabel amortBox = new JLabel("Amortiaztion Table");
         JScrollPane amortScroll = new JScrollPane(amortBox);
         public MortCalcWeek3 () //creates the GUI window
                        super("Mortgage Calculator");
                        setSize(300, 400);
                        setBackground (Color.white);
                        setForeground(Color.blue);
                        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        //Creates the container
                        Container contentPane = getContentPane();
                        FlowLayout fresh = new FlowLayout(FlowLayout.LEFT);
                        panel.setLayout(fresh);
                        //identifies trigger events
                        calcButton.addActionListener(this);
                        PField.addActionListener(this);
                        IBox.addActionListener(this);
                        LBox.addActionListener(this);
                        panel.add(PLabel);
                        panel.add(PField);
                        panel.add(choices);
                        panel.add(choicestxt);
                        panel.add(ILabel);
                        panel.add(IBox);
                        panel.add(LLabel);
                        panel.add(LBox);
                        panel.add(calcButton);
                        panel.add(payment);
                        panel.add(amortBox);
                        payment.setEditable(false);
                        panel.add(amortScroll);
                        setContentPane(panel);
                        setVisible(true);
         }// end of GUI info
              public void actionPerformed(ActionEvent e) {
                   MortCalcWeek3();     //calls the calculations
              public void MortCalcWeek3() {     //performs the calculations from user input
                   double P = Double.parseDouble(PField.getText());
                   double I = Double.parseDouble((String) IBox.getSelectedItem());
                   double L = Double.parseDouble((String) LBox.getSelectedItem());
                   double J = (I  / (12 * 100));//monthly interest rate
                   double N = (L * 12);//term in months
                   double M = (P * J) / (1 - Math.pow(1 + J, - N));//Monthly Payment
                 String showPayment = twoPlaces.format(M);
                 payment.setText(showPayment);
         //public void amort() {
                   //int N = (L * 12);
                   int month = 1;
                             while (month <= N)
                                  //performs the calculations for the amortization
                                  double H = P * J;//current monthly interest
                                  double C = M - H;//monthly payment minus monthly interest
                                  double Q = P - C;//new balance
                                  P = Q;//sets loop
                                  month++;
                                  String showAmort = twoPlaces.format(H + C + Q);
                                amortScroll(showAmort);
              public static void main(String[] args) {
              MortCalcWeek3 app = new MortCalcWeek3();
    }//end main
    }//end the programI appreciate any help you may provide.

         JLabel amortBox = new JLabel("Amortiaztion Table");
         JScrollPane amortScroll = new JScrollPane(amortBox);The argument passed to a JScrollPane constructor specifies what's inside the scroll pane. Here, it seems like you're trying to create a scroll pane that displays a JLabel.
    Also, I'm not sure what you're trying to do here:
    amortScroll(showAmort);I don't see a method named "amortScroll".
    You need to make a JTextArea, pass that into the JScrollPane's constructor, and add the JScrollPane to your frame.

  • How to deal with moving around like in gta2?

    Hi there,
    I'm programming an game but i was wondering how to deal with moving around like in gta2.
    my game is also top-down with you(tha player) constantly in the middle of the screen. I know how to deal with button press etc.. but how to calculate how manny pixels the map has to move in the x and y axis...
    It's difficult to explain for me.. but hope the picture is clear..
    greetings

    I was afraid for this one already.. the picture is not clear:) thanx for your response so far.. I will try again.. with the game gta2 in mind:)
    see this screenie: http://www.vollversion.de/bilder/705_1_full.jpg
    My game looks the same as gta2 top down... with the character in the middle of the screen(the one firing the flame thwower )(the player). if i press up he walks towards the police car.. if i press left or right.. he only turns around(an combination of pressing up and left is also posible) thus the character walks in the direction he's facing.
    Now i would like to know how did they do this? how to programm such a movement? Because the character is standing constnatly in the middle of the screen the map has to move like in almost every game... how to calculate the x and y axis movement of the map?
    Please.. try agian.. hopefully the screenie will help.

  • Dynamic content in scroll pane component

    As far as I can see, the contentPath for a scroll pane
    component can only point to a movie clip in the library, not to an
    instance on stage. Does this mean that the content can only be
    something created during authoring with no possibility of modifying
    it in Actionscript?

    No, I had no reply and eventually wrote my own scroll pane
    solution which allows me to directly modify the pane's content with
    ActionScript and update the scroll bar to reflect any change in the
    content's size. I'm puzzled by the help file's example in
    ScrollPane.refreshPane() because it describes a senario where:
    "for example, you've loaded a form into a scroll pane and an
    input property (for example, a text field) has been changed by
    ActionScript. In this case, you would call refreshPane() to reload
    the same form with the new values for the input properties."
    Which implies that you can use ActionScript to change the
    content then reload it. The help file on ScrollPane.contentPath is
    not very clear about what content can be used but appears to say
    that the only content types allowed are: a SWF or JPEG loaded via
    its URL or a symbol in the current library. I don't see how you
    could use ActionScript to change any of these. I've tried
    specifying an on-stage instance as the content but that
    fails.

  • Specifying text font in a scroll pane

    Below is a fragment of code that attempts to display text in a scroll pane. Basically this works OK, except for the following:
    1. Changing the font doesn't seem to make any difference. I tried "Arial", as shown, and "Curier", the display looks identical in both cases.
    2. Multiple blank spaces are replaced by a single blank space. So that "Baa baa" is displayed as "Baa baa".
    I would like to be able to display messages with many lines of text in a scroll pane preserving the format if possible, which relies on the blank spaces. I hope you can suggest how to do this better.
    Thans for you help.
    Miguel
        JLabel label = new JLabel(text);
        Font font = new Font("Arial",Font.PLAIN,12);
        label.setFont(font);
        JScrollPane scrollPane = new JScrollPane(label);

    try using a textArea instead of a label and include tabs for your multiple spaces.
    import java.awt.Font;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class FontTest extends JFrame {
         public FontTest() {
              super("Font Testing");
              String text = "This is \t a \t test";
              JTextArea text3 = new JTextArea();
              text3.setText(text);
              Font font = new Font("Courier",Font.PLAIN,12);   
              text3.setFont(font);   
              JScrollPane scrollPane = new JScrollPane(text3);
              getContentPane().add(scrollPane);
              setSize(400, 200);
              setVisible(true);
         public static void main(String[] args) {
              FontTest app = new FontTest();
    }

Maybe you are looking for

  • HT204370 Hi! problem playing HD Movies in iTunes!

    hi i have a problem all my hd movies i bought from itunes won't work when I try to play them it all goes dark and you can't play them. can someone please help me, i want to watch those movies

  • My username and password don't work to access MI424-WR Rev F router

    I'm trying to access my router to upgrade to WPA2 and disable Upnp for my FTP client and for some reason the router will not accept my username and password for the router.  Currently the stock WEP settings are in place.  Need to get this done becaus

  • Home sharing photo problems since last update

    Since the last apple tv update, can not see most home sharing pictures. I only get a white or black screen. What did you guys do, it worked fine before. Will there be a new update issued to fix this one?

  • Problems since re-install

    Hi, I upgraded to Tiger 10.4.8 and my Mac seemed to slow down considerably. Most of my programs were really slow and had problems using them. On the forum, it was decided that i should re-install panther. I have done that, but safari, itunes, ical i,

  • Please remove Class-Path from kodo-jdo-runtime.jar manifest

    This is repost. Class-Path should not be in manifest of kodo-jdo-runtime.jar It causes problems with security manager when using signed jars under webstart. It can potentially cause all kind of other problems due to class path conflicts Seems to be a