JSrollPane

Hello!
I've filled a JScrollPane with some components. When I try to add a some new components and repaint the scroll pane, the picture on the screen starts to twitch. What can I do in this case? Help me, please.
TIA

I have a similar problem when I go to this Japanese restaurant down the street. i order the calamari and when I put the hot sauce on, it starts twitching. Most of the time is will twitch right out of my chopsticks.

Similar Messages

  • Problem using JSrollPane

    Hi everyone I have a quick question:
    I have a JTabbedPane object which contains two tabs. Each tab has a JPanel object and each JPanel object has a JScrollPane with JTextArea object. When I update the data in the JTextArea the first time I get the scroll bars but if I change tabs and then go back to the tab with the updated data the scroll bars disappear.
    I thought it was the problem with revalidating so I then added a revalidate statement for the scrollPane everytime I update the data in the JTextField. That didn't make any difference. Then I added a revalidate statement for the scrollPane in a listener method which gets called when tabs change so when you get back to the tab with the data, the scrollpane would revalidate but that still doesn't work.
    What am I doing wrong?

    I can't really write a small example because I have a pretty complicated structure in my application.
    I mean when I write small examples they work perfectly fine. I guess what I'm looking for is just ideas of what you think might cause such a problem.
    The structure of my program is something like this:
    I have a a class Receive, which is a base class
    Then I have 10 other classes which derive from Receive.
    Receive has all the GUI components which have protected access so the derrived classes can access them.
    The derrived classes then have a method which through Data Distribution Services protocols get messages.
    Then a JTextArea object in the base class gets updated by
    textArea.setText(messageString);So then the message appear in the GUI, but when you change tabs and then go back to the previous tab the scrolls are all messed up.
    I set my objects like this
    frame=new JFrame();
    dataPane=new JPanel();
    textArea=new JTextArea();
    scrollPanel=new JScrollPanel(textArea);
    scrollPanel.setPreferedSize(new Dimension(400,300));
    tabPane.addTab("Tab", scrollPanel);
    dataPane.add(tabPane);
    frame.add(dataPane, BorderLayout.CENTER);

  • Word wrap with JScrollPane

    Quick question. Trying to get word wrap in a JTextField
    using JSrollPane. Below is a small snippet of code
    from my program...
    displayArea = new JTextArea ( );
    JScrollPane scroll = new JScrollPane ( displayArea,
       JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); Doesn't using JScrollPane.HORIZONTAL_SCROLLBAR_NEVER automatically
    introduce word wrap? I'm not getting it in my program. Somebody please correct me. Thanks!

    displayArea.setLineWrap (true);
    displayArea.setWrapStyleWord (true);I thought it wasn't added automatic.
    Kind regards,
      Levi

  • JTextField max length, JTextArea automatic scrolling

    i cant find how to do 2 things,
    i would like to limit the size of the text entered in a JTextField
    i could probably do this by making its KeyListener trim off the extra from getText() and use setText(whateverIsLeft) but i was hoping there was a better way of doing this with something that is already there as this is a lot of work considering soemoen could just hold down a button and it would have to do it several times a second
    also i need to set a JTextArea inside a JScrollPane so that when new text is appended to it, it scrolls the jtextpane down to the bottom, i could just make it write it at the top instead of appending it to the bottom but i REALLY dont want to =p
    thanks

    i've got the same probelm with the JSrollPane
    this is what i usually do
    public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
    ta.setText(ta.getText() + "\n" + tf.getText());
    tf.setText("");
    jsp.setPreferredSize(new Dimension(0, 0));
    jsp.revalidate();
    where tf is a JTextField, ta is a JTextArea and jsp is the JScrollPane in which ta is added
    this worked great so far but when i try to set it through this
    BufferedReader in = new BufferedReader(
    new InputStreamReader(port.getInputStream()));
    it just refuses to work and i haven't got the slightest clue why ...
    here is the Thred i use :
    private class Reciever extends Thread {
    private BufferedReader in = null;
    private String change = "";
    public String getChange() {
    return change;
    public Reciever() {
    Socket port = conMan.getPort();
    try {
    in = new BufferedReader(new InputStreamReader(port.getInputStream()));
    } catch (IOException e) {
    e.printStackTrace();
    System.err.println("[system] : I/O Exception ");
    } catch (NullPointerException e) {
    e.printStackTrace();
    System.err.println("[system] : Null Pointer Exception ");
    start();
    public void run() {
    for (; ;) {
    try {
    change = in.readLine();
    setText(change);//this is the method that sets the text in the JTextArea
    } catch (SocketException e) {
    Main.getStatus().setMsg("Closed " + conMan.getPort());
    return;
    } catch (IOException e2) {
    e2.printStackTrace();
    return;
    and the setText(); method :
    public void setText(String txt) {
    if (txt != null && !txt.equals(null) && !txt.equals("")) {
    receive.setText(receive.getText() + "\n" + txt);
    i tryed all of the above ways nothing works so far ...

  • Window with a slider

    I am trying to create a panel within an application that is set in size and contains a grid with fixed number of cells in each row, but a variable number of rows. What class can I use to get a slider to keep it in the panel?

    You need to set the prefered size of a JSrollPane and drop into it a JTable. Sunone / forte makes this job resonably easy. Next you need to overide the "public int getRowCount()" method of an AbstractTableModel and set this model within your JTable using the command "setModel(new myTableModel());"
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.table.AbstractTableModel;
    * Grid.java
    * Created on 31 October 2003, 13:21
    public class Grid extends JPanel{
        /** Creates a new instance of Grid */
        public Grid() {
            JTable      jTable      = new JTable();
            JScrollPane jScrollPane = new JScrollPane();
            AbstractTableModel myTableModel = new MyTableModel();
            setLayout(new java.awt.BorderLayout());
            addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentShown(java.awt.event.ComponentEvent evt) {
            jScrollPane.setPreferredSize(new java.awt.Dimension(850, 450));
            add(jScrollPane, java.awt.BorderLayout.CENTER);
            jTable.setModel(myTableModel);
            jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
            jTable.setRowSelectionAllowed(false);
            jTable.setShowHorizontalLines(false);
            jTable.getTableHeader().setReorderingAllowed(false);
            jTable.setRowHeight(18);
            jTable.setRowMargin(0);
            jTable.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
            jScrollPane.setPreferredSize(new java.awt.Dimension(850, 450));
            jScrollPane.setViewportView(jTable);
    }Code for the table model...
    import javax.swing.table.AbstractTableModel;
    * MyTableModel.java
    * Created on 31 October 2003, 13:52
    public class MyTableModel extends  AbstractTableModel{
        /** Creates a new instance of MyTableModel */
        public MyTableModel() {
        public int getRowCount() {
            return 5;
            //return myRowCounter;
        public int getColumnCount() {
            return 6;
            //return myColumnCounter;
        /** Returns the value for the cell at <code>columnIndex</code> and
         * <code>rowIndex</code>.
         * @param     rowIndex     the row whose value is to be queried
         * @param     columnIndex      the column whose value is to be queried
         * @return     the value Object at the specified cell
        public Object getValueAt(int rowIndex, int columnIndex) {
            return "Cell contents";
    }I draw you attention to the document accessable from link at
    http://java.sun.com/j2se/1.4.2/docs/api/
    Titled "How to use tables". I don't believe that everything in this document is clear, but it is a good starting place. Essentially, I used it in combination with this forum to work out the answers to your questions only a matter of months ago.
    I have only tested the above code for compilation. But I have no reason to think that it does not work.
    David.

  • One JTable in a JScrollPane.

    Hi all,
    I have one JTable with JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    This table is in a JScrollPane. I want this JSrollPane to fit the table, not the JFrame that contains all of them.
    The JTable is not big at all, only 4 columns, so when I resize the JFrame and I make it smaller enough to cover a piece of the JTable, the JScrollPane should show its scrollbars.
    Thanks in advance.
    Dani.

    import javax.swing.*;
    import java.awt.Dimension;
    public class Test extends JFrame {
    public Test() {
    super();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500,500);
    JTable table = new JTable(20,4);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JScrollPane scroll = new JScrollPane(table);
    scroll.setMinimumSize(new Dimension(304,0));
    JPanel panel = new JPanel();
    // panel.add(...)
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,scroll,panel);
    split.setDividerLocation(304);
    getContentPane().add(split);
    public static void main(String [] args) {
    new Test().show();

  • WRAP ON in JTextPane PROBLEM!

    I know that are a lot of topics about this wrap on/off in JTextPane. The problem is that I've tried a lot of them and doesn't satisfy my issue.
    I load a html text from somewhere. And I set the JTextPane with that text. This text have around 3000 character without any \n (new line). The JTextPane put this text on one line. I want the JTextPane to wrap the text so I can have on each line a number of chars. How can I do it?
    JTextPane content type is html/text.
    JTextPane belongs to a JPane in CENTER (JPane layout is BorderLayout)
    this JPane belongs to a JSrollPane
    I'm using this method to setup the text for JTextPane:
    editorPanel.setText(currDocText); // where currDocText is String variable
    Please help! I'm about to 'kill' my keyboard.. :-)
    10x in advance
    god help you to find a solution for my problem..

    Try using a JTextArea? It does wrapping.
    : jay

  • Please help me with file JAR

    Hi to all!!!!!
    I have finished an application and I have created the respective file .jar, the problems arise when I want to execute some item of the main menu, which had to take to another screen. It is here where nothing happens.
    Exactly frame does not happen anything in those where I use the jtable component of swing, since the rest of the components that I use is AWT.
    The other case is that it shows frame that to me where I do not have a jtable (only component AWT) but when it had to show a message to me, nothing happens. In order to show a message I use the JOptionPane of swing.
    For this case send me the following message in the console: "UIDefaults.getUI() failed: for nonComponentUI class: com.sun.java.swing.JOptionPane[, 0, 0, 0x0, invalid ] "
    For the first case is equal only changes:
    com.sun.java.swing.JSrollPane[,0,0,0x0,invalid] or com.sun.java.swing.JTable[,0,0,0x0,invalid ]
    Lamentably makes the application with components AWT and I only use in some frames the JTable component and the JScrollPane of swing. And to show to messages the JOptionPane.
    The problem is to use component AWT and SWING
    Is very well that when I execute the application with JBuilder2 I do not have any problem, everything.
    But when I create .jar and I execute, they appear the problems. But my consultation is:
    Why happens this? How it is possible to be solved? Exists some solution?
    Beforehand thank you very much.

    Is very well that when I execute the application with JBuilder2
    I do not have any problem, everything.
    But when I create .jar and I execute, they appear the problems. As far as I know, JBuilder comes with it's own JDK. So it could well be that you are running with JDK 1.1 in JBuilder and a newer JDK when executing the .jar file

  • How to prevent displaying outer rectangle of JscrollPane

    HI All,
    I want prevent the displaying JSrollPane outer rectanlge means no outer rectangle formed JSrollPane should be displayed
    below is the code, if the code is run then Rectagle will appear which is title fitted to JScrollPane.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Rectangle;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    public class Sample extends JFrame
         private static final long serialVersionUID = 1L;
         public Sample()
              Dimension size = new Dimension(
                   150, 150);
              Dimension FRAME_SIZE = new Dimension(
                   700, 500);
              setLocation(size.width, size.height);
              setSize(FRAME_SIZE);
              setBackground(Color.WHITE);
              setTitle("JFrame ");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel = new JPanel();
              JScrollPane sp = new JScrollPane(
                   panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                   JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
              sp.setBounds(new Rectangle(
                   10, 10, 400, 400));
              this.setLayout(null);
              super.getContentPane().add(sp);
         public static void main(String[] args)
              JFrame frame = new Sample();
              frame.setVisible(true);
    }any helps arround this will deeply appreciated.
    Thanks
    Dorairaj M

    Yes I realized about the solution
    by setting empty border (BorderFactory.createEmptyBorder())
    Thanks
    Dorairaj M

  • GridBagLayout error

    Hi
    I'm creating a program with a couple of rows and columns. In the 6 first rows I have some JTextFields and som buttons. In the last row I have a JSrollPane which contains a JTable. I want the rows with buttons and textfields to take up an equal amount of space(12,5% each) and the JScrollPane to take 25%. All of this works just fine, and the weightY gives me no problem.....until i set the widthX higher than 1 for the JScrollPane. When I do this the JScrollPane suddenly takes 75% of the height.
    My question...Why????
    Thanks in advance.

    Hi
    I had a few of those problems to. Sorted it out by doing the following when using the GridBagLayout.
    1.     Place your components on the Panel that you will be applying the GridBagLayout on without having set any Layout for that Panel.
    2.     Then you set your sizes which also have to include setMinimimSize & the setPreferrredSize.
    3.     Once you are happy with where everything is and eeverything is set. Then you apply the GridBagLayou to the Panel.
    Take note that I use the visual composition of VisualAge for Java3.0, but I've found when I tried in JBuilder it also worked on the same principle.
    So I hope that this will work
    Ciao

Maybe you are looking for

  • How to select  multiple vendors in out going payment

    Hi, We are issuing Letter to Bank asking to issue DD against 10 Vendors. In this case Bank issuing DD and making debit as one entry. In Outgoing payment is it possible to select 10 vendors at time ( Is there any other way instead of 10 outgoing payme

  • Cant unlock phone! Help!

    Hi all! Does anyone happen to know Verizon default pin code? My 4 year old was playing with my brand new S5 and apparently the phone locked on her. So instead of asking me to do pattern she must have tried to do it herself.  Which in turn locked my p

  • Installing 'Yosemite'; 'Mavericks'

    Hello, I had Mavericks installed on my original 160 GB HDD. It was working fine for a long time, until... A Month ago the original HDD crashed and since my last backup was about a year old, so far I'm unable to install any new OS X past Snow Leopard.

  • N8 Anna LOG problem

    I have upgraded to Anna and now I have a problem with LOG - communication details. Before upgrading to Anna, N8 was showing logs for calls, 3G, GPRS, WIFI connections, but now it shows only calls!? Solved! Go to Solution.

  • Grant issue for oracle package LT_EXPORT_PKG

    Hi, I am having oracle 10g with version 10.2.0.4 While giving execute grant on "LT_EXPORT_PKG" to one of my schema it gives error : USING SYS USER: GRANT EXECUTE ON LT_EXPORT_PKG TO <SCHEMA-NAME>; ERROR at line 1: ORA-04042: procedure, function, pack