JScrollpane problems in w98

Hi
i created a jpanel, painted some 2D-Graphics on it (within the paintComponent-method) but it don't fit on the screen because its too large. So i put the panel in a JScrollPane. But when i drag the Scrollbutton up or down my graphics are fractured very bad. The problem don't exist under wMe. I use sdk1.3.
thanks, hope somebody can help me!

Hello trankiemhung,
Thanks for using Apple Support Communities.
I found the following information that will help resolve your issue:
Using Game Center
http://support.apple.com/kb/HT4314
Additional Information
If you are having difficulty logging in to Game Center or staying connected
Verify that you are connected to the Internet.
If you are unable to create or sign in to your Game Center account from within a game, try creating or signing in to your account using the Game Center app.
Try signing out of your Game Center account, then sign back in. If you can't sign in to your Game Center account with an Apple ID, try resetting your password or using another email address. To manage your Apple ID account, go to My Apple ID.
When using a Wi-Fi connection, verify that your Wi-Fi router is configured for Game Center.
Take care,
Alex H.

Similar Messages

  • Obnoxious JTextPane and JScrollPane problem.

    I have written a Tailing program. All works great except for one really annoying issue with my JScollPane. I will do my best to explain the problem:
    The program will continue tailing a file and adding the text to the JTextPane. When a user scrolls up on the JScrollPane, the program still adds the text to the bottom of the JTextPane and the user can continue to view what they need.
    Here is the problem: I have text being colored throughout the text pane. For instance, the word ERROR will be in red. The problem is when the program colors the text, it moves the scroll pane to the line where word that was colored is at. I don't want that. If the user moves the scroll bar, I want the scroll bar to always stay there. I don't want the program to move to the text that was just colored.
    Is there a way to turn that off? I can't find anything like that anywhere.

    Coloring text will not cause the scrollpane to scroll.
    You must be playing with the caret position or something.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Strange JScrollPane problem in JApplet

    I've got a JApplet which is giving me a strange problem with the scrollbar of a JScrollPane. The JScrollPane is populated with a JList whose ListModel is a DefaultListModel. I specify to always show the vertical and never show the horizonatal scroll bars.
    Once the JList content goes beyond the visible range of the viewport, it seems to be working as usual - the scrollbar reflects the amount of content. However, if I click on the scroll arrows, nothing happens. And, if I click on the scroll bar itself, it disables. Basically, the scrolling portion of the component dies. I don't get any exceptions during runtime or problems compiling the code.
    I've tried making the ListModel and JList as dynamic elements (i.e. not members of the class). I've tried adding .validate(). I've tried everything of which I can think. I'm at a loss. The most troubling part of this is that if the project is set up as an application instead of an applet, it works fine.
    I'm using J2 1.6.
    Here's sample code that reproduces the problem:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ScrollTest extends JApplet
      private DefaultListModel exOddLM;
      private JList            exOddJL;
      private JScrollPane      exOddSP;
      private JButton          click;
      public ScrollTest() {
        this.setup();
      public void init() {
        this.setup();
      public void setup() {
        this.setLayout(null);
        this.setSize(400, 442);
        this.exOddLM = new DefaultListModel();
        this.exOddJL = new JList(this.exOddLM);
        this.exOddSP = new JScrollPane(this.exOddJL);
        this.exOddSP.setBounds(0, 0, 200, 200);
        this.exOddSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        this.exOddSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        this.click   = new JButton("add more");
        this.click.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent me) { addMore(); }
        this.click.setBounds(0, 200, 200, 18);
        this.add(this.exOddSP);
        this.add(this.click);
      private void addMore() {
        for(int x = 0; x < 5; x++) {
          this.exOddLM.addElement(Integer.toString(x));
    }

    It had to be something simple, didn't it? (=
    Thanks!
    I guess I was thinking that an applet wouldn't call the constructor. Don't know why I would have thought that. After removing the double call, it works great.
    Thanks again Rodney!!!
    You know, this actually explains a good deal of other problems I was having with the actual program (a homework assignment). One of them, I had added a KeyListener to an entry field on the form, and it was giving me all sorts of weird double-letter posts and letter-delete problems.
    This also explains why it was working well as an application.

  • JTabbedPane and JScrollPane problem

    Hi all,
    I'm trying to make working JScrollPane into JTabbedPane. I have been trying several times to make it but with no acceptable effects :( I attached below the simple code to show what I'm interested in.
    PANEL1 has its dimension. I'd like to make that the JScrollPane will be active and enabled to roll when user change JFrame size to less than PANEL1 on pane1.
    Please help!
    Thanks for everyone,
    Greetings,
    import java.lang.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Sample     {
    static JFrame fr;
    static JPanel pane1, pane2, pane3;
    static JLabel AAA, BBB, CCC;
    static JPanel PANEL1;
    static JTabbedPane panel;
    public static void main(String args[])     {
              fr = new JFrame("Sample");
              pane1 = new JPanel();
              pane1.setLayout(null);
              pane2 = new JPanel();
              pane2.setLayout(null);
              pane3 = new JPanel();
              pane3.setLayout(null);
              panel = new JTabbedPane();
              Font myfont1 = new Font("SansSerif",0,20);
              Font myfont2 = new Font("SansSerif",0,15);
              Font myfont3 = new Font("SensSerif",1,15);
              AAA = new JLabel("AAA");
              BBB = new JLabel("BBB");
              CCC = new JLabel("CCC");
              AAA.setFont(myfont2);
              BBB.setFont(myfont2);
              CCC.setFont(myfont2);
              AAA.setBounds(20,20,300,20);
              BBB.setBounds(20,50,300,20);
              CCC.setBounds(20,80,300,20);
              PANEL1 = new JPanel();
              PANEL1.setLayout(null);
              PANEL1.setBackground(java.awt.Color.CYAN);
              PANEL1.setBounds(20,15,250,300);
              PANEL1.add(AAA);
              PANEL1.add(BBB);
              PANEL1.add(CCC);
              pane1.add(PANEL1);
              panel.insertTab("A", null, pane1, null, 0);
              panel.setSelectedIndex(0);
              panel.insertTab("B", null, pane2, null, 1);
              panel.setSelectedIndex(0);
              panel.insertTab("C", null, pane3, null, 2);
              panel.setSelectedIndex(0);
              panel.setBounds(0,0,550,450);
              fr.setLayout(null);
              //fr.setResizable(false);
              fr.setBackground(java.awt.Color.CYAN);
              fr.setForeground(java.awt.Color.CYAN);
              fr.add(panel);
              fr.pack();
              fr.setSize(550, 450);
              fr.setLocationRelativeTo(null);
              fr.setVisible(true);
    }

    Unfortunately no :( Besides, I can't understand at
    all this line:
    JTabbedPane (panel)TabbedPane = ... new
    w JTabbedPane(...).add/insertTab( ... new
    JScrollPane(new JPanel(...)) ... )It's to big cut-off like for me. Can you insert it
    into my Sample?
    Regards and thanks,It's only my "dev speak". Put a ";" and a var name (, ...) whereever needed, and remove some"()".
    (Sorry, normally I don't help dev beginners on so more complex problems, with just an easy answer.)

  • Tricky little JScrollPane problem

    I have a JScrollPane that contains a JPanel with BorderLayout called "mainPanel".
    I have a kind of web appearance with a left child panel of vertical JLabels, a north child panel for title, and a center child panel as a work area inserted into "mainPanel". Simple enough!
    The problem is in the center panel, when I insert a child JPanel into it with either FlowLayout or VerticalFlowLayout withthe panel extending completely across the center panel from left to right.
    This child panel is hidden-to-the-eye panel because of the background being color same as center panel.
    I then add controls to the child panel.
    The problem is the scrollbars appear for the child panel that extends the full width of the center panel, instead of the controls, which I DONT want. I want the scrollbar to only show for the controls.
    How can I get JScrollPane to ignore child JPanels like it does with the top level JPanel "mainPanel".
    thanks

    There's a post around from a couple of years ago where I tried to get flowlayout to behave in a scrollpane. I got it to work fairly well, but eventually gave up. I think the real answer is to not use flowlayout in a scrollpane, but you can search for that post if you want.

  • Small JScrollPane problem

    Hi,
    I have a text area and wish to add a JScrollPane into the text area. I dont want to add the text area into the scroll pane in the following manner:
    JScrollPane pane = new JScrollPane(textArea);Instead I want to use the default constructor:
    JScrollPane pane = new JScrollPane( );and then add in the textarea afterwards. The problem is that I cannot seem to find any method to add the component into the scroll pane.
    Please help me by also submitting code.
    Thanks in advance
    Rizwan

    pane.setViewportView(textarea);

  • JScrollPane problems

    Hello. I have been trying to get the JScrollPane working on this project with little success. The problem is, the center panel draws a picture based on user dimensions and the picture can get quite big, which draws partially off screen. Is there a way to add a scrollpane to the entire frame or individual panels based on the redrawn size? If so, how do I apply it to the specific code shown below?
    import java.awt.BorderLayout;
    import java.awt.Toolkit;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    * This class constructs the frame on screen.
    public class DViewer extends JFrame {
      private static JFrame frame;
      private static JPanel dDPanel;
      * Construct  frame and panels
      public DViewer() {
      super();
      frame = new JFrame();
      frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
      frame.setTitle("Designer");
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      dDPanel = new JPanel(new BorderLayout());
      dDPanel.add(new DComponent(), BorderLayout.CENTER);
      dDPanel .add(new UserDI(), BorderLayout.NORTH);
      dDPanel .add(new USOptions(), BorderLayout.WEST);
      dDPanel .add(new Selecter(), BorderLayout.SOUTH);
      JScrollPane scrollPane = new JScrollPane();
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      frame.add(dDPanel );
      frame.setVisible(true);
      public static void repaintD() {
      BorderLayout layout = (BorderLayout) dDPanel.getLayout();
      dDPanel.remove(layout.getLayoutComponent(BorderLayout.CENTER));
      dDPanel add(new DeckComponent(), BorderLayout.CENTER);
      frame.revalidate();
      frame.repaint();

    Hi, yes it's possible. Have a look at this chapter of the Swing tutorials: How to Use Scroll Panes (The Java&amp;trade; Tutorials &amp;gt; Creating a GUI With JFC/Swing &amp;gt…

  • JSplitPane / JScrollPane Problem

    Hi,
    i use a JSplitPane to divide a navigation-panel (JTree) and a viewer-panel (JEditorPane)
    this works fine with only one problem. the JEditorPane used to display the data has no ScollBars. I�ve already added a JScrollPane instead of the JEditorPane directly but that does not seem to work out.
    how ever, i think this depends on the fact that the JScrollPane (which contains the JEditorPane) is added as the right part of the JSplitPane.
    any ideas how to fix this problem, or how it is caused?
    thx anyway
    cu Errraddicator

    Hi,
    i use a JSplitPane to divide a navigation-panel (JTree) and a viewer-panel (JEditorPane)
    this works fine with only one problem. the JEditorPane used to display the data has no ScollBars. I�ve already added a JScrollPane instead of the JEditorPane directly but that does not seem to work out.
    how ever, i think this depends on the fact that the JScrollPane (which contains the JEditorPane) is added as the right part of the JSplitPane.
    any ideas how to fix this problem, or how it is caused?
    thx anyway
    cu Errraddicator

  • JTabbedPane/JSplitPane/JScrollPane problem

    Hi
    I'm making a simple webbrowser with the JDesktop (jdic) parser (using your standard browser as parser)...
    The problem I have :
    I have a "JTabbedPane" containing a "JSpitPane". This JSplitPane contains a "JCombobox" (as URL field) and a "JScrollPane".
    The "JScrollPane" contains the jdic WebBrowser...
    When I resize the JFrame of my application bigger, everything will resize okay. When I'm making my JFrame smaller, the JScrollPane doesn't resize correctly , so the scrollbars are gone !
    I tried already a lot of things like putting the jdic WebBrowser directly in the JSplitPane, using a JPanel instead of the JSplitPane, ...
    It only works correctly if I add the jdic Webbrowser directly to the JTabbedPane...
    I know it's difficult to understand but I hope somebody can help me !
    If you know another solution to add a JCombobox and a jdic Webbrowser together, let me know !"
    Thx in advance!
    grtz
    Unzip

    Hi,
    The JPanels which you have inside each tab of the JTabbedPanes should have BorderLayout and the JScrollPanes which hold the JTables should be added with the BorderLayout.CENTER constraint. This will make sure that the JScrollPanes that contain the JTables occupy as much space as possible.
    Hope this helps,
    Ranga.

  • About show scrollbar of the JScrollPane problem.

    Hi,
    JPanel main=new JPanel();
    main.setLayout(null);
    JPanel child=new JPanel();
    child.setBounds(...,...,...,...);
    main.add(child);
    JScrollPane jsp=new JScrollPane();
    jsp.getViewPoint().add(main);The problem is that when the child panel 's bounds is out of the visable region of the main panel ,the jscrollpane doesn't show its scrollbar.
    I want show scrollbar so that I can show the invisable child panel.
    How to resolve it?

    Hi,
    JPanel main=new JPanel();
    main.setLayout(null);WRONG 1.
    JPanel child=new JPanel();
    child.setBounds(...,...,...,...);
    main.add(child);
    JScrollPane jsp=new JScrollPane();
    jsp.getViewPoint().add(main);WRONG 2.
    >
    The problem is that when the child panel 's bounds is
    out of the visable region of the main panel ,the
    jscrollpane doesn't show its scrollbar.
    I want show scrollbar so that I can show the
    invisable child panel.
    How to resolve it?WRONG 3.
    You don't set preferred size for the view component.

  • JTree and JScrollPane problems

    Hello all.
    bear with me a second, so I can explain what is happenning with my code. I have got a java application that is accessing an SQL database (either Oracle or postgreSQL) and inputing the data into a tree.
    More specifically it takes the "enrollment" data and draws into the scrollpane the courses and students enrolled. Everything seems to be working perfectly with the building of the tree.
    but I have a drop down list that can select which years to display (1-4th year). I want the tree in the scrollPane to update when u change the year in the drop down list.
    I have added an ActionListener to the drop down list and it picks up the right selection, and I create a new tree object with the new year details and nothing is changed in the scrollpane.
    This is what the GUI looks like:
    This is my tree class which creates teh tree and adds it to the scrollPane object:
    package Interface;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.sql.*;
    import Database.Database;
    public class Tree{
         JTree tree;
         JScrollPane scrollPane;
         public Tree(GridBagConstraints c, Container contentPane, GridBagLayout gridBag, int year){
              //Set up the default table.
              TreeNode root = buildTree("Enrollments", year);
              tree = new JTree(root);
              //Set up a scrollPane for the tree.
              scrollPane = new JScrollPane(tree);
              //Set constraints for the ScrollPane
              c.fill = GridBagConstraints.BOTH;
              c.weightx = 1;
              c.weighty = 1;
              c.gridwidth = 2;
              c.gridx = 0;
              c.gridy = 1;
              c.anchor = GridBagConstraints.CENTER;
              gridBag.setConstraints(scrollPane, c);
              contentPane.add(scrollPane);     
              //Set defaults for teh Tree object.
              tree.expandRow(0);
              tree.setRootVisible(false);
              tree.setEditable(true);     
         public DefaultMutableTreeNode buildTree(String s, int year){
              //Set root of tree.
              DefaultMutableTreeNode node = new DefaultMutableTreeNode(s);
              //Create a database object.
              Database db = new Database();
              //change this bit to get the name's of the courses and add into array.
              ResultSet className = db.query("SELECT name FROM courses WHERE year = "+year);
              DefaultMutableTreeNode course = null;
              DefaultMutableTreeNode name = null;
              try {
                        while(className.next()){
                             String classStr = className.getString("name");
                             course = new DefaultMutableTreeNode(classStr);
                             node.add(course);
                             ResultSet firstName = db.query("SELECT students.name FROM students, enrollments, courses WHERE students.id = enrollments.studentID AND enrollments.courseid = courses.id AND courses.name = '"+classStr+"'");
                             while(firstName.next()){
                                  String nameStr = firstName.getString("name");
                                  name = new DefaultMutableTreeNode(nameStr);
                                  course.add(name);
                   catch(Exception e){
                        System.err.println("" + e.getMessage());
                        e.printStackTrace(System.err);
              return node;
    }This is the GUI class that calls on the tree class and draws the GUI. and the actionlistener for the drop down list.
    package Interface;
         import java.awt.*;
         import javax.swing.*;
         import java.awt.event.*;
    import java.sql.*;
         public class GUI extends JFrame implements ActionListener{
              private static final long serialVersionUID = 1L;     
              DropDownMenu yearDrop;
              ScrollPane scrollPane;
              JMenuItem menuItemSave;
              JMenuItem menuItemQuit;
              JMenuBar menuBar;
              JMenu menu;
              JButton save;
              JButton quit;
              Tree tree;
              String year[] = { "First Year", "Second Year", "Third Year", "Fourth Year" };
              Container contentPane = getContentPane();
              GridBagLayout gridBag = new GridBagLayout();
              GridBagConstraints c = new GridBagConstraints();
              public GUI(){
                   setSize(500,500);
                   setTitle("UTAS Enrollments");
                   contentPane.setLayout(gridBag);          
                   save = new JButton("Save");
                   quit = new JButton("Quit");
                   menuItemSave = new JMenuItem("Save");
                   menuItemQuit = new JMenuItem("Quit");
                   menuItemSave.setMnemonic('s');
                   menuItemQuit.setMnemonic('q');
                   yearDrop = new DropDownMenu(year, c, contentPane, gridBag);
                   tree = new Tree(c, contentPane, gridBag, 1);
                   menuBar = new JMenuBar();
                   menu = new JMenu("File");
                   menu.setMnemonic('f');
                   menuBar.add(menu);
                   menu.add(menuItemSave);
                   menu.add(menuItemQuit);
                   setJMenuBar(menuBar);
                   //Set constraints for the Save button
                   c.fill = GridBagConstraints.NONE;
                   c.weightx = 1;
                   c.weighty = 0;
                   c.gridwidth = 1;
                   c.gridx = 0;
                   c.gridy = 2;
                   c.anchor = GridBagConstraints.WEST;
                   save.setMnemonic('s');
                   gridBag.setConstraints(save, c);
                   contentPane.add(save);
                   //Set constraints for the Quit button
                   c.fill = GridBagConstraints.NONE;
                   c.weightx = 1;
                   c.weighty = 0;
                   c.gridwidth = 1;
                   c.gridx = 1;
                   c.gridy = 2;
                   c.anchor = GridBagConstraints.EAST;
                   quit.setMnemonic('q');
                   gridBag.setConstraints(quit, c);
                   contentPane.add(quit);
                   //Add ActionListener to the interactive buttons on the GUI.
                   //QUIT MENU
                   menuItemQuit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             quitAction();
                   //SAVE MENU
                   menuItemSave.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             saveAction();
                   //QUIT BUTTON
                   quit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             quitAction();
                   //SAVE BUTTON
                   save.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             saveAction();
                   //DROPDOWN LIST
                   yearDrop.dropDown.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             listAction();
              public void listAction(){
                   System.out.println("getSelected: "+ year[yearDrop.getSelected()]);
                   tree = new Tree(c, contentPane, gridBag, (yearDrop.getSelected()+1));
                   repaint();
         I have taken out the quitAction and saveAction methods to save space.
    I would have thought creating a new Tree object over the original tree would have updated the scrollPane.
    Any ideas would be awesome.
    Thanks in advance.

    and I create a new tree object with the new year details and nothing is changed in the scrollpane.Creating a new Tree doesn't add the tree to the scroll pane. It just changes the reference of the tree variable to point to the new Tree object. To update the scroll pane you would need to do:
    scrollPane.setViewportView( tree );
    Or another option is to just create a new TreeModel and then change the model that your existing tree is using:
    TreeModel model = new TreeModel(...);
    tree.setModel( model );

  • JTextPane/JScrollPane problems

    in my JTextPane i would like to be able to set the tab size (like you can with JTextArea), and for some reason my JScrollPane doesn't want to scroll the JTextPane horizontally, it just wraps the text. any help and sample code is very appreciated.
    TravenE

    Well normally I'd tell you to search the forums because I've answered both of these question several times before. But since the search isn't currently working for me I'm assuming it isn't working for you either, so here are my suggestons.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TextPaneTabs extends JFrame
         public TextPaneTabs()
              JTextPane textPane = new JTextPane();
              textPane.setFont( new Font("monospaced", Font.PLAIN, 12) );
              JScrollPane scrollPane = new JScrollPane( textPane );
              scrollPane.setPreferredSize( new Dimension( 200, 200 ) );
              getContentPane().add( scrollPane );
              setTabs( textPane, 4 );
         public void setTabs( JTextPane textPane, int charactersPerTab)
              FontMetrics fm = textPane.getFontMetrics( textPane.getFont() );
              int charWidth = fm.charWidth( 'w' );
              int tabWidth = charWidth * charactersPerTab;
              TabStop[] tabs = new TabStop[10];
              for (int j = 0; j < tabs.length; j++)
                   int tab = j + 1;
                   tabs[j] = new TabStop( tab * tabWidth );
              TabSet tabSet = new TabSet(tabs);
              SimpleAttributeSet attributes = new SimpleAttributeSet();
              StyleConstants.setTabSet(attributes, tabSet);
              int length = textPane.getDocument().getLength();
              textPane.getStyledDocument().setParagraphAttributes(0, length, attributes, false);
         public static void main(String[] args)
              TextPaneTabs frame = new TextPaneTabs();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestNoWrap extends JFrame
         JTextPane textPane;
         JScrollPane scrollPane;
         public TestNoWrap()
              JPanel panel = new JPanel();
              panel.setLayout( new BorderLayout() );
              setContentPane( panel );
              // no wrap by adding text pane to a panel using border layout
              textPane = new JTextPane();
              textPane.setText("1234567890 1234567890 1234567890");
              JPanel noWrapPanel = new JPanel();
              noWrapPanel.setLayout( new BorderLayout() );
              noWrapPanel.add( textPane );
              scrollPane = new JScrollPane( noWrapPanel );
              scrollPane.setPreferredSize( new Dimension( 200, 100 ) );
              panel.add( scrollPane, BorderLayout.NORTH );
              // no wrap by overriding text pane methods
              textPane = new JTextPane()
                   public void setSize(Dimension d)
                        if (d.width < getParent().getSize().width)
                             d.width = getParent().getSize().width;
                        super.setSize(d);
                   public boolean getScrollableTracksViewportWidth()
                        return false;
              textPane.setText("1234567890 1234567890 1234567890");
              scrollPane = new JScrollPane( textPane );
              scrollPane.setPreferredSize( new Dimension( 200, 100 ) );
              panel.add( scrollPane );
         public static void main(String[] args)
              TestNoWrap frame = new TestNoWrap();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

  • Layout Problem in a JScrollPane

    Hi Friends. I have the following problem.
    Fact 1:
    When I add components to a JPanel with a FlowLayout, the components rearrange themself to the next line when the length exceeds the viewable area(horizontally).
    Goal:
    I want to add the JPanel to a scrollPane and I dont want the horizontal scrolling. I want that when I add the components to the JPanel, components are added to the new line, when the horizontal viewable area is used up.(Something like the "fact" mentioned above ... but the difference here is, I want the JPanel inside a JScrollPane)
    Problem :
    When i add the JPanel to the scrollPane and adds components to JPanel... all components come into one line and don't wraps up themself.
    I have also tried with various properties.. telling no horizontal scrollbar etc... but it doesnt helps..... the components are laid off in one single long line.
    Please help me with this problem.
    Thanks a lot in advance.
    Warm Regards,
    Nishant

    hi friends,
    yeah now after a lot of RnD , I am able to implement a solution to the problem... it might not be a good one, but for me it is decent enuf.
    I tried everything , extending a custom JPanel from Scrollable and all sorts of things, but nothing was very helpful.
    One single thing which is most important is the preferredSize of the JPanel, which if you can set properly with the addition/deletion or resizing ,..... the problem is solved.
    so the problem remains only to set the appropiate preferredSize of the Jpanel. unfortunately, the JPanel's respective preferredSize, maximumSize, minimumSize etc are not of much help.
    so I decided to look for the components inside the JPanel and look for the last component position and the height.... but unfortunately (I dont know the reason), I get the position of all components, except the last one correct. So my choice of component now is last but one. I calculated the position of last but one component and added the (height of this component + height of last component + some buffer ), to get the height of the panel.
    and set the preferredSize of the Jpanel appropiately, for ex. in the action, adding components to the panel.. etc .. etc...
    the code snippet is as follows..and it works absolutely fantastic for my requirements, atleast...
    Component[] tmpC = _oLeftPanel.getComponents();
    if(tmpC.length >1)
         double kbuffer = 25D;
         //doing for last but one comp.
         Component kcomp1 = tmpC[tmpC.length - 2];
         double kh1 = kcomp1.getY();
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         //doing it for the last component
         kcomp1 = tmpC[tmpC.length - 1];
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         Dimension kdim = new Dimension((int)_oLeftScrollPane.getViewport().getViewSize().getWidth(), (int)kh1);
         _oLeftPanel.setPreferredSize(kdim);

  • Opening a HTML file through GUI

    Hi guys I am new to java and HTML and now I need to open a HTML file which is saved on disk and search for a word my code is as shown below.......
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class Test_Find extends JFrame {
        public Test_Find() {
            initComponents();
            setExtendedState(JFrame.MAXIMIZED_BOTH);
            textarea.setText(initialText);
            textarea.setCaretPosition(0);
            setVisible(true);
            textarea.requestFocusInWindow();
        private void initComponents() {
            scrollTextarea = new JScrollPane();
            textarea = new JTextArea();
            toolbar = new JToolBar();
            findB = new JButton();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setTitle("Test Find");
            scrollTextarea.setViewportView(textarea);
            getContentPane().add(scrollTextarea, BorderLayout.CENTER);
            toolbar.setFloatable(false);
            findB.setText("Find");
            findB.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    findBActionPerformed(evt);
            toolbar.add(findB);
            getContentPane().add(toolbar, BorderLayout.NORTH);
        private void findBActionPerformed(ActionEvent evt) {
            String input = JOptionPane.showInputDialog(
                    "Find what:", pattern);
            if(input==null){
                input="";
            pattern=input;
            doFind();
        private int doFind(){
            textarea.requestFocusInWindow();
            currentCaretPosition = textarea.getCaretPosition();
            text = textarea.getText();
            if(!pattern.equals("")){
                int pos=0;
                pos = text.toLowerCase().indexOf(pattern.toLowerCase(), currentCaretPosition);
                if(pos>-1){
                    scrollTextarea.getHorizontalScrollBar().setValue(0);
                    textarea.setCaretPosition(pos+pattern.length());
                    highlight(textarea, pattern);
                    return 1;//found
            }else{
                removeHighlights(textarea);
                return 0;//no pattern
            return -1;//not found
        // Creates highlights around all occurrences of pattern in textComp
        public void highlight(JTextComponent textComp, String pattern) {
            // First remove all old highlights
            removeHighlights(textComp);
            try {
                Highlighter hilite = textComp.getHighlighter();
                Document doc = textComp.getDocument();
                String text = doc.getText(0, doc.getLength());
                int pos = 0;
                // Search for pattern
                while ((pos = text.toLowerCase().indexOf(pattern.toLowerCase(), pos)) >= 0) {
                    // Add highlight around pattern using private painter
                    hilite.addHighlight(pos, pos+pattern.length(), textPainter);
                    pos += pattern.length();
            } catch (BadLocationException e) {
        // Removes only our private highlights
        public void removeHighlights(JTextComponent textComp) {
            Highlighter hilite = textComp.getHighlighter();
            Highlighter.Highlight[] hilites = hilite.getHighlights();
            for (int i=0; i<hilites.length; i++) {
                if (hilites.getPainter() instanceof TextPainter) {
    hilite.removeHighlight(hilites[i]);
    // An instance of the private subclass of the default highlight painter
    private Highlighter.HighlightPainter textPainter = new TextPainter(Color.yellow);
    // A private subclass of the default highlight painter
    class TextPainter extends DefaultHighlighter.DefaultHighlightPainter {
    public TextPainter(Color color) {
    super(color);
    public static void main(String args[]) {
    new Test_Find();
    private String input, pattern, text;
    private int currentCaretPosition;
    private JButton findB;
    private JScrollPane scrollTextarea;
    private JTextArea textarea;
    private JToolBar toolbar;
    private String initialText =
    "Swing JTable and JScrollPane Problem\n" +
    " tlloreti 4 Jul 5, 2005 4:15 PM\n" +
    "by Tom.Sanders \u00bb \n" +
    "Swing CTRL-A (select all) ignored in applet\n" +
    " ilmbeachgirl 4 Jul 5, 2005 4:10 PM\n" +
    "by ilmbeachgirl \u00bb \n" +
    "Swing drawing problem\n" +
    " gnosnahz 0 Jul 5, 2005 4:09 PM\n" +
    "by gnosnahz \u00bb \n" +
    "Java Event Handling events effecting panels in multiple tabs\n" +
    " sean_hagen 1 Jul 5, 2005 4:06 PM\n" +
    "by es5f2000 \u00bb \n" +
    "Swing Searching text in files & highlighting that text\n" +
    " sketty 1 Jul 5, 2005 3:57 PM\n" +
    "by camickr \u00bb \n" +
    "Swing JTextField displaying prtially its contents\n" +
    " SreeJay 1 Jul 5, 2005 3:55 PM\n" +
    "by camickr \u00bb \n" +
    "Swing how to get BufferedImage of a JPanel\n" +
    " praveen.Arora 1 Jul 5, 2005 3:53 PM\n" +
    "by camickr \u00bb \n" +
    "Swing Creating a form from a xml schema..\n" +
    " zoltern 0 Jul 5, 2005 3:51 PM\n" +
    "by zoltern \u00bb \n" +
    "Swing Da Suckers: Java and Windows XP\n" +
    " [email protected] 1 Jul 5, 2005 3:42 PM\n" +
    "by [email protected] \u00bb \n" +
    "Java 2D Rescaling using JAI\n" +
    " G-Rehuku 0 Jul 5, 2005 3:30 PM\n" +
    "by G-Rehuku \u00bb \n" +
    "Swing how to get Page Preview of multiple page JPanel\n" +
    " Sonu.Arora 0 Jul 5, 2005 2:20 PM\n" +
    "by Sonu.Arora \u00bb \n" +
    "Swing IDE for Swing Development\n" +
    " JavaEnthusiastt 8 Jul 5, 2005 2:17 PM\n" +
    "by uhrand \u00bb \n" +
    "Java 2D Can't connect to X11 window server\n" +
    " kusigubi 0 Jul 5, 2005 2:06 PM\n" +
    "by kusigubi \u00bb \n";
    }Since I am new to the field requesting the kind quick help by java experts here to help me change the code so that I would be able to search a web apge saved on disk and search and highlight a word in that page ....
    Thanks in advance........
    Looking forward for your kind suggestions.......                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Since I am new to the field requesting the kind quick help by java experts here to help me change the code so that I would be able to search a web apge saved on disk and search and highlight a word in that page ....
    Thanks in advance........
    Looking forward for your kind suggestions......1) Did you write that code? If yes, proceed to 2). If no, I charge 150 euros/hr. Let me know when you want me to start.
    2) Post the code for a program that opens a text file with the following in it:
    hello world
    and prints the contents out using System.out.println().
    3) Modify the program in 2) to determine if the file contains the word "yes". Post the code.
    4) An html file is no different than the text file in 2).

  • Peronal Oracle8 loading error message

    Can somebody please tell me how to fix this error message.
    I am unable to complete laoding Oracle8 personal edition Release 8.0.4.0.0
    The message said that the program has performed an illegal operation and will be shut down. Contact the program vendor.
    Detailes: ORAINST caused an invalid page fault in module MSVCRT.DLL at 014f;7801518f.
    Thanks

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Akin ():
    Can somebody please tell me how to fix this error message.
    I am unable to complete laoding Oracle8 personal edition Release 8.0.4.0.0
    The message said that the program has performed an illegal operation and will be shut down. Contact the program vendor.
    Detailes: ORAINST caused an invalid page fault in module MSVCRT.DLL at 014f;7801518f.
    Thanks<HR></BLOCKQUOTE>
    Ihave the same problem under W98, try to uninstall all Oracle Products first, reboot yur pc and re-install. Is the only way that I found. I hope this help you.
    null

Maybe you are looking for

  • Mail server setup problems

    we are in the process of setting up a SL mail server and have pretty much everything running nicely, except mail. our setup is as follows: • previous email provider mx records are still active but have allocated higher priority to new server's mx rec

  • 10g RAC on Oracle VM/Windows 2003 server

    Is there any documentation/thread/blog which describes installation of 10g clusterware on Windows 2003 VM on Oracle VM 2.1.2 using just direct attached storage? I created 2 Windows 2003 VMs. For OCR and Voting disks, I created shared virtual disks. T

  • Help on decrypting fatal system log messages

    I am still learning Solaris and E450. My E450 with 2 CPUs went down with the following message. It first said it's related to memory error on CPU (cache?) then it said it may not be the memory problem. Can someone shed some lights on what this is abo

  • Can i install os lion on an external drive

    Is it possible to install OS Lion on an external Hard Drive and use that to boot up a laptop computer? Thanks, AS

  • Total No of PRs

    Hi, Is there any report for Total No of PRs (without details) for a given period. Thanks,