🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
1 messages
1 total messages Started by philippe usenet Fri, 06 Jun 2003 11:01
this must be trivial - Splitting JScrolPanes
#558
Author: philippe usenet
Date: Fri, 06 Jun 2003 11:01
87 lines
4279 bytes
HiAll

I'm splitting a Container in two halves using e JSPlitPane.

What I'm trying to understand is the way JSPlitPanes resize according to 
their contents.

I would have expected their default behavior to be : Size the panes to 
their content size. It's not. Or is it ?

When the app starts, you only see a JTable filled with atomic 
components, this is a search facility for a DB system. You only see 
this, and as much lines as you created to build you query. Good.

When you click the submit button, after gathering the results, I put 
them in a JTable, split the Container, put the aforementioned search 
pane in the upper pane, and the result JTable in the lower.

the reason I extended JScrollPane is that I want my user to be able to 
repeat the splitting process, : I want all my JScrollPanes to be able to 
split themselves.

Fact is, it works so far. I only have a cosmetic problem, those are the 
most irritating.

So you built your query and clicked, but in order to see your results 
you have to *resize the window manually* ! I'm trying to describe this : 
You drag the lower resize handle, the divider is stuck to the bottom 
until you reach its supposed location, and it then stays in the middle 
of the Spane. Only after that can you see you result JTable.

I'm doing something stupid, I *know* it, but don't know *what*

Included is my derived JScrollPane class, named PnFenetre, for your 
reference. The whole app code is quite lenghy but I can provide it.

##code start
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;

//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
public class PnFenetre
extends JScrollPane {
Dimension minimumSize = new Dimension(400, 450);
Container _fenetreMere; // A ref. to the "mother" of the pane
boolean _isSepared; // Check if we are already splitted
PnListe _listeTable; // the result table
JComponent _fenetreFille; // The "daughter" pane ref.

//////////////////////////////////////////////////////////////
public PnFenetre(Container fenetreMere, JComponent fenetreFille) {
super(fenetreFille);
// _isSepared = false;
_fenetreMere = fenetreMere;
_fenetreFille = fenetreFille;
}

//////////////////////////////////////////////////////////////

public void separe(JComponent fille) {
if (_isSepared == true) {
return;
}
_fenetreMere.remove(this);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
PnFenetre scrollFille = new PnFenetre(splitPane, fille);
scrollFille.setPreferredSize(minimumSize);
splitPane.setTopComponent(this);
splitPane.setBottomComponent(scrollFille);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(150);
splitPane.setContinuousLayout(true);
splitPane.setResizeWeight(0.5);

_fenetreMere.setLayout(new GridLayout(1, 1));
_fenetreMere.add(splitPane, BorderLayout.CENTER);
_fenetreMere.setSize(minimumSize);
_fenetreMere.doLayout();
_fenetreMere.repaint();

_isSepared = true;
}
} // PnFenetre
## code end
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads