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

Similar Messages

  • 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.

  • JSplitPane update problem

    If someone could help, I would greatly appreciate it. The problem involves a JSplitPane, which is a Tab within a JTabbedPane, where
    the TopComponent (which contains a JComboBox) passes an argument to the Class that represents the BottomComponent to display detail information. The Class(Mgmt_Contact - BottomComponent) is
    receiving the parameter and processes but the data does not display. I have SOP messages that indicate the data is being formatted correctly. I'm really confused and desperately need help. The problem deals with addressing the BottomComponent of the JSplitPane from the Class that represents the TopComponent.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Home extends JFrame{
    private JTabbedPane tabbedPane;
    public Home(){
    super("The Travel Agency Model");
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    system.exit(0);
    }); // end of WindowListener
    tabbedPane = new JTabbedPane(SwingConstants.LEFT);
    tabbedPane.setBackground(Color.blue);
    tabbedPane.setForeground(Color.white);
    populateTabbedPane();
    getContentPane().add(tabbedPane);
    buildMenu();
    } // end of constructor
    private void buildMenu(){
    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item = new JMenuItem("Exit");
    item.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    System.exit(0);
    }); //end of addActionListener
    menu.add(item);
    mb.add(menu);
    setJMenuBar(mb);
    } // end of buildMenu
    // create tabs with titles
    private void populateTabbedPane(){
    tabbedPane.addTab("Management", null,
    new Management(), "Select the Management ");
    } // end of populateTabbedPane
    public static void main(String[] args){
    Home dl = new Home();
    dl.pack();
    dl.setSize(800, 620);
    dl.setBackground(Color.white);
    dl.setVisible(true);
    // end of Home class
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Management extends JPanel implements ChangeListener{
    private JTabbedPane propPane;
    public Management(){
    propPane = new JTabbedPane(SwingConstants.TOP);
    propPane.setSize(795, 550);
    propPane.addChangeListener(this);
    populateTabbedPane();
    add(propPane);
    } // end of constructor
    // create tabs with titles
    private void populateTabbedPane(){
    propPane.addTab("Management", null, new Mgmt(), "Management");
    propPane.addTab("Management Contact", null, new Management_Contact(),
    "Management Contact");
    } // end of populateTabbedPane
    public void stateChanged(ChangeEvent e){
    System.out.println("\n\n ****** Management.java " + propPane.getSelectedIndex() + " " + propPane.getTabPlacement());
    public static void main(String[] args){
    Home dl = new Home();
    dl.pack();
    dl.setSize(800, 620);
    dl.setBackground(Color.white);
    dl.setVisible(true);
    } // end of Management class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    public class Mgmt extends JPanel{
    public Mgmt() {
    } // end of Mgmt class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Management_Contact extends JPanel {
    Mgmt_Class mgmt = null;
    Mgmt_Contact mgmtContact = null;
    public Management_Contact() {
    JSplitPane split = new JSplitPane();
    split.setOrientation(JSplitPane.VERTICAL_SPLIT);
    Mgmt_Header hdr = new Mgmt_Header();
    split.setTopComponent(hdr);
    Mgmt_Contact mgmtContact = new Mgmt_Contact();
    JScrollPane scrollPane = new JScrollPane(mgmtContact,
    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setPreferredSize(new Dimension(650,300));
    split.setBottomComponent(scrollPane);
    add(split);
    } // end of Management class
    import java.util.Vector;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Mgmt_Header extends JPanel implements ActionListener{
    private JComboBox cmbMgmt;
    private JTextField txtMgmtAddr1;
    private JTextField txtMgmtAddr2;
    private JPanel pWork;
    private Box vertBox;
    private Box topBox;
    private Box midBox;
    private Box botBox;
    private Mgmt_Class mClass = null;
    private Mgmt_Contact cnt = null;
    Vector mgmtVct = null;
    public Mgmt_Header(){
    vertBox = Box.createVerticalBox();
    topBox = Box.createHorizontalBox();
    midBox = Box.createHorizontalBox();
    botBox = Box.createHorizontalBox();
    mClass = new Mgmt_Class();
    mgmtVct = new Vector();
    cmbMgmt = new JComboBox();
    cmbMgmt.addItem(" ");
    mgmtVct = mClass.bldMgmtHeader();
    for (int x1=0; x1<mgmtVct.size() ;x1++ )
    mClass = (Mgmt_Class)mgmtVct.get(x1);
    cmbMgmt.addItem(mClass.getManagementName());
    System.out.println("MgmtHeader " + mgmtVct.size() + " " + cmbMgmt.getItemCount());
    cmbMgmt.setEditable(false);
    cmbMgmt.setBackground(Color.white);
    cmbMgmt.setName("cmbMgmt");
    cmbMgmt.setPreferredSize(new Dimension(250,27));
    cmbMgmt.setFont(new Font("Times-Roman",Font.PLAIN,12));
    cmbMgmt.addActionListener(this);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.CENTER));
    pWork.setBorder(BorderFactory.createTitledBorder(" Select Management Name or Enter Code "));
    pWork.add(new JLabel("Name: "));
    pWork.add(cmbMgmt);
    topBox.add(pWork);
    txtMgmtAddr1 = new JTextField("Address line 1",15);
    txtMgmtAddr1.setEditable(false);
    txtMgmtAddr2 = new JTextField("Address line 2",15);
    txtMgmtAddr2.setEditable(false);
    midBox.add(midBox.createVerticalStrut(10));
    botBox.add(new JLabel("Address:"));
    botBox.add(topBox.createHorizontalStrut(15));
    botBox.add(txtMgmtAddr1);
    botBox.add(topBox.createHorizontalStrut(15));
    botBox.add(txtMgmtAddr2);
    vertBox.add(topBox);
    vertBox.add(midBox);
    vertBox.add(botBox);
    add(vertBox);
    } // end of constructor
    public void actionPerformed(ActionEvent evt){
    if (evt.getSource() instanceof JComboBox){
    if (((JComboBox)evt.getSource()).getName() == "cmbMgmt"){
    int sel = ((JComboBox)evt.getSource()).getSelectedIndex();
    System.out.println("ActionListener " + sel + " " +
    ((JComboBox)evt.getSource()).getItemAt(sel) + " " +
    cmbMgmt.getItemAt(sel));
    Mgmt_Class mClass = (Mgmt_Class)mgmtVct.get(sel - 1);
    System.out.println("From Vector " + mClass.getAddress1() + " " +
    mClass.getAddress2() + " " + mClass.getManagementCode());
    txtMgmtAddr1.setText(mClass.getAddress1());
    txtMgmtAddr2.setText(mClass.getAddress2());
    System.out.println("\n\nListener " + ((JComboBox)evt.getSource()).getSelectedItem() + " " + (((JComboBox)evt.getSource()).getSelectedIndex()) );
    int mCode = mClass.getManagementCode();
    Mgmt_Contact cnt = new Mgmt_Contact(mCode);
    System.out.println("\n After new Mgmt_Contact constructor");
    } // end of JComboBox
    } // end of actionPerformed
    } // end of Mgmt_Header class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    public class Mgmt_Contact extends JPanel{
    private Mgmt_Contact_Class contact = null;
    private JTextField txtFName = null;
    private JTextField txtLName = null;
    private JTextField txtAddr1 = null;
    private JTextField txtAddr2 = null;
    private JButton btnUpd = null;
    private JButton btnNew = null;
    private JButton btnDel = null;
    private JButton btnNext = null;
    private JButton btnPrior = null;
    private JPanel cntct = null;
    private JPanel pWork = null;
    private JPanel pWest = null;
    private JPanel pSouth = null;
    private JPanel pCenter = null;
    public Mgmt_Contact() {
    System.out.println("\n MgmtContact default constructor");
    contact = new Mgmt_Contact_Class();
    bldPage();
    System.out.println("\n ******* After bldPage() routine");
    public Mgmt_Contact(int mCode) {
    System.out.println("\n MgmtContact second constructor " + mCode);
    Vector mgmtVct = new Vector();
    contact = new Mgmt_Contact_Class();
    mgmtVct = contact.bldMgmtContactTbl(mCode);
    contact =(Mgmt_Contact_Class)mgmtVct.get(0);
    System.out.println("\n ******* Management Contact Table *** " + contact.getFirstName());
    bldPage();
    System.out.println("\n ******* After bldPage() routine");
    public void bldPage(){
    System.out.println("\n MgmtContact bldPage ");
    cntct = new JPanel();
    cntct.setLayout(new BorderLayout());
    pWest = new JPanel();
    pWest.setLayout(new GridLayout(0,1));
    pCenter = new JPanel();
    pCenter.setLayout(new GridLayout(0,1));
    pSouth = new JPanel();
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    pWest.add(new JLabel("First :"));
    txtFName = new JTextField(15);
    txtFName.setText(contact.getFirstName());
    System.out.println("\n First Name " + txtFName.getText() + " " +
    contact.getFirstName());
    txtFName.setPreferredSize(new Dimension(200,27));
    pWork.add(txtFName);
    pWork.add(new JLabel("Last :"));
    txtLName = new JTextField(15);
    txtLName.setText(contact.getLastName());
    txtLName.setPreferredSize(new Dimension(200,27));
    pWork.add(txtLName);
    pCenter.add(pWork);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    pWest.add(new JLabel("Address :"));
    txtAddr1 = new JTextField(15);
    txtAddr1.setText(contact.getAddress1());
    txtAddr1.setPreferredSize(new Dimension(200,27));
    pWork.add(txtAddr1);
    pWork.add(new JLabel(" "));
    txtAddr2 = new JTextField(15);
    txtAddr2.setText(contact.getAddress2());
    txtAddr2.setPreferredSize(new Dimension(200,27));
    pWork.add(txtAddr2);
    pCenter.add(pWork);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    btnNew = new JButton(" Add ");
    btnUpd = new JButton("Update");
    btnDel = new JButton("Delete");
    btnNext = new JButton(" Next ");
    btnPrior = new JButton(" Prior ");
    pSouth.add(btnNew);
    pSouth.add(btnUpd);
    pSouth.add(btnDel);
    pSouth.add(btnNext);
    pSouth.add(btnPrior);
    cntct.add("West", pWest);
    cntct.add("Center", pCenter);
    cntct.add("South", pSouth);
    add(cntct);
    } // end of Mgmt_Contact class

    Repaint/revalidate will work but what I didn't explain is that the components on each side are also containers and the user events for the contained, non-opaque components are handled transparently to my code.
    Is there a way to get the JSplitPane to automatically update both sides so that I don't have to catch all possible user events? (Scrolling, key punching, tree expanding, button pressing, etc).
    OR
    How can I detect that the split pane is updating one side so I can run repaint/revalidate on the other side?
    Thanks!

  • JSplitPane, JScrollPane, JPanel & resize

    My program has 2 nested JSplitpanes, that divide the screen in 4 parts like a cross.
    I added a JScrollPane to one of the quaters and added a JPanel to the JScrollPane. The JPanel uses a CardLayout since I want to switch the components that I show there.
    One of the components I show on the JPanel is a JTree. If I expand the tree the panel becomes scrollable to show the whole tree. This is what I want because I want to be able to view the whole tree.
    The problem is, that if I switch to another component on the panel the panel stays that large even though I just want it to have the visible size
    This is how the panel looks like before switching to the tree and expanding it:
    http://img272.imageshack.us/img272/8695/noscroll3zj.jpg
    This is how the panel looks like after switching to the tree, expanding it and switching back:
    http://img272.imageshack.us/img272/6690/scroll3ef.jpg
    I want to restore the panel to its initial state but I cannot figure out how. Please help.

    If I add a panel to the split pane (to make it card layout) I can't use it for scrolling anymoreThis simple example works for me:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SplitPaneCard extends JFrame
         JSplitPane splitPane;
         JPanel cards;
         public SplitPaneCard()
              splitPane = new JSplitPane();
              getContentPane().add(splitPane, BorderLayout.CENTER);
              JTextArea textArea1 = new JTextArea(5, 10);
              textArea1.setText("1\n2\n3\n4\n5\n6\n7");
              textArea1.setForeground( Color.RED );
              JScrollPane scrollPane1 = new JScrollPane( textArea1 );
              JTextArea textArea2 = new JTextArea(5, 10);
              textArea2.setText("1234567");
              textArea2.setForeground( Color.BLUE );
              JScrollPane scrollPane2 = new JScrollPane( textArea2 );
            cards = new JPanel( new CardLayout() );
            cards.add(scrollPane1, "red");
            cards.add(scrollPane2, "blue");
            splitPane.setRightComponent( cards );
              JPanel buttonPanel = new JPanel();
              getContentPane().add(buttonPanel, BorderLayout.SOUTH);
              JButton red = new JButton("Show Red Text Area");
              red.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      CardLayout cl = (CardLayout)(cards.getLayout());
                      cl.show(cards, "red");
              buttonPanel.add(red);
              JButton blue = new JButton("Show Blue Text Area");
              blue.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      CardLayout cl = (CardLayout)(cards.getLayout());
                      cl.show(cards, "blue");
              buttonPanel.add(blue);
         public static void main(String[] args)
              final SplitPaneCard frame = new SplitPaneCard();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

  • 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.

  • JSplitPane, JScrollPane and JTree resizing

    Hi,
    In a JSplitPane, I have, in the left part, a JScrollPane, containing a JTree and, in the right part, I have an other panel.
    When I click on different nodes in the JTree, the width of the left part changes, so the JSplitPane separator moves. How to avoid that ? I would prefer a scrolling move inside the JScrollPane !
    I am using JDK 1.3
    Thanks
    Olivier Scalbert

    Try to define the JScrollPane as
    public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
    Use vsbPolicy and hsbPolicy like the VERTICAL_SCROLLBAR_AS_NEEDED
    HORIZONTAL_SCROLLBAR_AS_NEEDED respectively.
    Then define the setPreferredSize to your JScrollPane. This preferredSize must be smaller than the size of the Component view if you want to see the ScrollBar.
    By the way, when you define your JSplitPane have to define the setOneTouchExpandable(true);?

  • 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.

  • 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.

  • 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);

  • JSplitPane Movement Problem

    Hi,
    I have a JSPlitPane, on the left side, I have a JTree and on the right, I have a Panel with Toolbars.
    The problem is, when I move the divider to the right, it goes at some point and stick there, this is becuase of Toolbar width, I tried setting the toolbar width on PropertyChange Listener but it seems that propertyChange listener doesn't call at that points. My code is as follows:
    jSplitPane1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent e) {
                setPanelSize();
                repaint();
    private void setPanelSize() {
          int panelWidth = rightPane.getWidth() - DIFF_BW_PANE_PANEL;
          ideToolBar.setSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.setPreferredSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.setMaximumSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.validate();
          ideToolBar.updateUI();
          System.out.println("ToolBar Width: " + ideToolBar.getSize() + " Panel Size: " + activePanel.getSize());
       }Thanks

    So, if the right panel becomes too narrow to display the whole toolbar, do want it to be cut off? If so, I would try calling  ideToolbar.setMinimumSize(new Dimension(0, ideToolbar.getHeight())); right after you create the toolbar (and leave out all that dynamic sizing code).
    Or just move the toolbar out of the panel--I suspect it shouldn't be there anyway.

  • 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 Divider problem...

    I'm having problem with the JSplitPane divider. Ive learned that the MouseListener class is most likely the reason why the divider isn't performing as expected. I had to learn how to use the MouseListener interface and I've also learned that the divider is an instance of BasicSplitPaneDivider. I've finally got the divider to PARTIALLY work if I only set the following:
    1) setting the setContinuousLayout(true)
    //setting it to false wont work for some reason, I want to fix that, too. By setting it to false, the divider wont move :(.
    and
    2) if I move the mouse slowly, so the divider can follow the mouse. If I move my mouse too fast, then my divider will suddenly stop the moment the mouse cursor hovers away from the divider.
    Can anyone help me fix the divider problem? Thanks in advance! Here's my code below:
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.awt.event.MouseEvent;
    import javax.swing.event.MouseInputAdapter;
    import javax.swing.plaf.basic.BasicSplitPaneDivider;
    public class JSplitPaneDemo{
         public static void main(String args[]){
              //Practice p = new Practice("SplitPane Divider Works Now?");
              JSplitPaneDemo x = new JSplitPaneDemo();
              x.new Practice("SplitPane Divider Works Now?");
         public class DendrogramListener extends MouseInputAdapter
              Container contentPane;
              Component button1, button2, button3;
              JSplitPane splitter;
              Point mLocation;
              JFrame myFrame;
              MyGlassPane glass;
              private boolean inDrag = false;
              private boolean inButton = false;
              private boolean inDivider = false;
              public DendrogramListener(JFrame frame)
                   this.myFrame = frame;
                   this.contentPane = frame.getContentPane();
                   this.mLocation = new Point();
              public DendrogramListener(AbstractButton aButton, AbstractButton b2, AbstractButton b3, MyGlassPane glass1, Container cP, JSplitPane split){
                   this.button1 = aButton;
                   this.button2 = b2;
                   this.button3 = b3;
                   this.glass = glass1;
                   this.contentPane = cP;
                   this.mLocation = new Point();
                   this.splitter = split;
              public void mouseDragged(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void mouseMoved(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void mouseClicked(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void mousePressed(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void mouseReleased(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
                   inDrag = false;
              public void mouseEntered(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void mouseExited(MouseEvent arg0) {
                   // TODO Auto-generated method stub
                   redispatchMouseEvent(arg0);
              public void redispatchMouseEvent(MouseEvent e){
                   inButton = false;
                   inDrag = false;
                   inDivider = false;
                   Component component = null;
                   JButton tempButton;
                   Container container = contentPane;
                   Point glassPanePoint = e.getPoint();
                   mLocation = e.getPoint();
                   Point containerPoint = SwingUtilities.convertPoint(glass, glassPanePoint, contentPane);
                   int eventID = e.getID();
                 component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
                 if (component == null) {
                      //System.out.println("NULL");
                     return;
                 if (component instanceof JButton) {
                     inButton = true;
                 if(component instanceof BasicSplitPaneDivider){
                      inDivider = true;
                      testForDrag(eventID);
                 if (inButton || inDivider)
                           Point componentPoint = SwingUtilities.convertPoint(glass, glassPanePoint, component);
                          component.dispatchEvent(new MouseEvent(component,
                                                               eventID,
                                                               e.getWhen(),
                                                               e.getModifiers(),
                                                               componentPoint.x,
                                                               componentPoint.y,
                                                               e.getClickCount(),
                                                               e.isPopupTrigger()));
                   testForDrag(eventID);
             private void testForDrag(int eventID) {
                 if (eventID == MouseEvent.MOUSE_PRESSED) {
                     inDrag = true;
         public class MyGlassPane extends JComponent {
              int x0, y0;
              Point mLocation;
              public MyGlassPane(AbstractButton aButton, AbstractButton b2, AbstractButton b3, Container cP, JSplitPane splitter){
                   DendrogramListener dl = new DendrogramListener(aButton, b2, b3, this, cP, splitter);
                   addMouseListener(dl);
                   addMouseMotionListener(dl);
             public void setPoint(Point p) {
                 mLocation = p;
         public class Practice extends JFrame implements ActionListener
              private MyGlassPane glassPane;
              public Practice(String str)
                   super(str);
                   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   setDefaultLookAndFeelDecorated(true);
                   addComponents(this);
                   pack();
                   setVisible(true);
              public Practice addComponents(final Practice p)
                   JPanel leftPane = new JPanel();
                   JPanel midPane = new JPanel();
                   JPanel rightPane = new JPanel();
                   JLabel l1 = new JLabel("Left panel");
                   JLabel r1 = new JLabel("Right panel");
                   JLabel m1 = new JLabel("Middle panel");
                   JButton b1 = new JButton("Button 1");
                   JButton b2 = new JButton("Button 2");
                   JButton b3 = new JButton("Button 3");
                   leftPane.add(l1);
                   leftPane.add(b3);
                   b3.setActionCommand("b3");
                   b3.addActionListener(this);
                   leftPane.setPreferredSize(new Dimension(200, 300));
                   midPane.add(m1);
                   midPane.add(b1);
                   midPane.setPreferredSize(new Dimension(200, 300));
                   rightPane.add(r1);
                   rightPane.add(b2);
                   rightPane.setPreferredSize(new Dimension(200, 300));
                   JSplitPane splitter2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rightPane, midPane);
                   splitter2.setOneTouchExpandable(true);
                   splitter2.setContinuousLayout(true);
                   JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, splitter2);
                   splitter.setOneTouchExpandable(true);
                   splitter.setContinuousLayout(true);
                   getContentPane().add(splitter);
                   glassPane = new MyGlassPane(b1, b2, b3, p.getContentPane(), splitter);
                   this.setGlassPane(glassPane);
                   glassPane.setVisible(true);
                   return p;
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
                   if("b3".equals(arg0.getActionCommand())){
                        JOptionPane.showMessageDialog(this, "Button 3 Pressed!");
    }

    The problem with your listener is that you are only dispatching events to the
    button or divider when the mouse is directly over that component. This results
    in the behavior you see with the divider: you have to move the mouse slowly
    to keep it over the divider otherwise it gets over some other component and
    you stop dispatching the events to it.
    You actually have a similar problem with the buttons: if you click on one, it
    gets the event but if you then drag the mouse out of the button and release
    the mouse, it still triggers the button! This is not how buttons work: if you
    release the mouse when it is not over the button, it shouldn't trigger.
    Try this for your listener:
         public class DendrogramListener extends MouseInputAdapter {
              Component redispatch;
              boolean inside;
              Container contentPane;
              Component button1, button2, button3;
              JSplitPane splitter;
              Point mLocation;
              JFrame myFrame;
              MyGlassPane glass;
              private boolean inDrag = false;
              private boolean inButton = false;
              public DendrogramListener( JFrame frame ) {
                   this.myFrame = frame;
                   this.contentPane = frame.getContentPane();
                   this.mLocation = new Point();
              public DendrogramListener( AbstractButton aButton, AbstractButton b2,
                        AbstractButton b3, MyGlassPane glass1, Container cP,
                        JSplitPane split ) {
                   this.button1 = aButton;
                   this.button2 = b2;
                   this.button3 = b3;
                   this.glass = glass1;
                   this.contentPane = cP;
                   this.mLocation = new Point();
                   this.splitter = split;
              public void mouseDragged( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void mouseMoved( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void mouseClicked( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void mousePressed( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void mouseReleased( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
                   inDrag = false;
                   inButton = false;
              public void mouseEntered( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void mouseExited( MouseEvent arg0 ) {
                   redispatchMouseEvent( arg0 );
              public void redispatchMouseEvent( MouseEvent e ) {
                   int eventID = e.getID();
                   Point glassPanePoint = e.getPoint();
                   Point containerPoint = SwingUtilities.convertPoint( glass, glassPanePoint, contentPane );
                   if ( !inDrag && !inButton && eventID == MouseEvent.MOUSE_PRESSED ) {
                        redispatch = SwingUtilities.getDeepestComponentAt( contentPane, containerPoint.x, containerPoint.y );
                        inButton = ( redispatch instanceof JButton );
                        inside = inButton;
                        if ( !inButton )
                             inDrag = ( redispatch instanceof BasicSplitPaneDivider );
                   if ( inButton || inDrag ) {
                        if ( inButton )
                             eventID = possiblySwitchEventID( eventID, containerPoint );
                        Point componentPoint = SwingUtilities.convertPoint( glass, glassPanePoint, redispatch );
                        redispatch.dispatchEvent( new MouseEvent( redispatch, eventID, e.getWhen(), e.getModifiers(),
                                  componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger() ) );
              private int possiblySwitchEventID( int eventID, Point containerPoint ) {
                   int switchedID = eventID;
                   Component deepest = SwingUtilities.getDeepestComponentAt( contentPane, containerPoint.x, containerPoint.y );
                   if ( deepest == redispatch ) {
                        if ( ! inside )
                             switchedID = MouseEvent.MOUSE_ENTERED;
                        inside = true;
                   } else {
                        if ( inside )
                             switchedID = MouseEvent.MOUSE_EXITED;
                        inside = false;
                   return switchedID;
         }: jay

  • 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.

Maybe you are looking for

  • Open programs on Lion

    On my Macbook Pro, I used to be able to do a 3-4 finger horizontal swipe on my touchpad and it would show all programs that were open and had not been shut down completely, the windows had just been closed.  With Lion, the swipe I used with Snow Leop

  • Premiere Pro CC 2014 - Video playing faster than audio - Out Of Sync?

    Hi All, It's been some time since I've had to write about any problems here. Sooo, I've got Adobe Premiere Pro CC 7.2.2.  (Using AJA KONA IoExpress BoB)   I've imported a 5 minute AVI file (video=1920x1080, Data=65587kbps, Total=66355kbps, 30fps. - -

  • What  is  "WM"  and how does it relate to  Abap work

    Hello, What is "WM" is it one of the modules in SAP , or just describes interface development in SAP. Thanks

  • WHY WHEN I EXPORT A DOCUMENT TO WORD CAN´T EDIT?

    WHY WHEN I EXPORT A DOCUMENT TO WORD CAN´T EDIT?

  • [MOVED] Question(s) regarding dzen2

    While I am still absorbing the knowledge to configure dzen2, there's something that I can't stil manage to create in my head. The only thing that I can't seem to figure out how to make in dzen is the window list, and was wondering if anyone else knew