Ignore:
Timestamp:
2024-02-27T19:13:43+13:00 (3 months ago)
Author:
anupama
Message:
  1. ScrollPane wasn't being used and it didn't workout with the way the code used the scrollbar to calculate positioning, so I instantiated and used a JScrollBar instead in the same manner the awt ScrollBar was being used. 2. JResultTitle bar (JResultBox's row of column headings) wasn't appearing and neither was the scrollbar, or else the centre pane (ResultCanvas with results) wasn't appearing. The layout wasn't working except on resize. The solution was that ordering of adding to the layout had an effect. (Instantiating the objects added to the layout was order dependent also, as one kept a pointer to the other.) The solution turned to setPreferredSize() on the JResultTitle in its constructor, rather than calling setSize(). This fixed the layout and now I don't want to fiddle with it any more as it works out for the JApplet just as for the Applet, and still works when the JPhind JApplet class is run as an application from the commandline as well.
Location:
main/trunk/greenstone3/src/java/org/greenstone/applet/phind
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JResultBox.java

    r38782 r38799  
    4040
    4141import javax.swing.JPanel;
    42 import javax.swing.JScrollPane;
    4342import javax.swing.JScrollBar;
    4443import javax.swing.JLabel;
     
    7170    JResultCanvas c;
    7271    JResultTitle t;
    73     JScrollPane scrollpane;
    7472    JScrollBar s;
    7573    JPanel label;
     
    137135    // Porting from awt to swing
    138136    // http://fizyka.umk.pl/~jacek/docs/javatutorial/uiswing/converting/how.html
     137   
     138    s = new JScrollBar(JScrollBar.VERTICAL);   
     139    disableScrollbar();
     140    s.addAdjustmentListener(this);
     141
    139142    this.setLayout(new BorderLayout());
    140 
    141     scrollpane = new JScrollPane(this);//,
    142     //JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    143     //JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    144     s = new JScrollBar(JScrollBar.VERTICAL);
    145     scrollpane.setVerticalScrollBar(s);
    146    
    147     disableScrollbar();
    148     scrollpane.getVerticalScrollBar().addAdjustmentListener(this);
    149 
     143   
    150144    c = new JResultCanvas(this);
    151     this.add(c, BorderLayout.CENTER);
    152 
    153 
    154     t = new JResultTitle(this);
     145    t = new JResultTitle(this); // calls setPreferredSize() which finally made layout work
     146   
    155147    this.add(t, BorderLayout.NORTH);
    156 
     148   
     149    JPanel centrePane = new JPanel();
     150    centrePane.setLayout(new BorderLayout());
     151    centrePane.add(s, BorderLayout.EAST);
     152    centrePane.add(c, BorderLayout.CENTER);
     153    this.add(centrePane, BorderLayout.CENTER);
     154   
    157155    buffer = "";
    158156    finished = false;
     
    191189
    192190    void disableScrollbar() {
    193     JScrollBar s = scrollpane.getVerticalScrollBar();
    194191    if (s.isEnabled()) {
    195192        s.setValues(0, 1, 0, 1);
  • main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JResultCanvas.java

    r38782 r38799  
    5757import java.awt.event.MouseAdapter;
    5858import java.net.URL;
    59 import java.applet.Applet;
    6059import java.util.Date;
    6160
  • main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JResultTitle.java

    r38782 r38799  
    7272    Dimension d = getSize();
    7373    d.height = phind.fontSize + 10;
    74     setSize(d);
    75    
     74    setPreferredSize(d);
    7675   
    7776    }
Note: See TracChangeset for help on using the changeset viewer.