View Single Post
  #5 (permalink)  
Old 07-27-2007, 04:53 PM
praveenrn praveenrn is offline
Member
 
Join Date: Jul 2007
Posts: 5
praveenrn is on a distinguished road
need solution to get rid of problem caused due to migration from jdk 1.3 to 1.5/1.6
Hi,

Thanks Iam able to get back my Look and Feel almost by using System properties

System.setProperty("swing.noxp","true");
System.setProperty("swing.useSystemFontSettings"," false");


But there is also one more problem left.

I said already that iam migrating application from 1.3 to 1.6/1.5.
I have one class using JScrollBar throwing NullPointer Exception which is working very much fine in jdk 1.3 vesion.

but in the following code iam able to observe that incrButton is assigned with an JButton in version 1.3 But in 1.5 it is assigned with null value. The problem is ihave code that is written Listener on this button. Even though iam able to get the Button in scrollbar. and then i commeted or assigned null and compiled in 1.3 version the buttons are not displayed,what i mean to say is incrButton variable in BasicScrollBarUI is reffering the Button that is visible in scrollbar. But in 1.5 version incrButton is not assigned with JButton and still the Button as able to see in ScrollBar.

An Code is like that Listener has been added to that button because of this NullPointer Exception is coming.

I would like to ask how can i write listener on ArrowButtons in Basic ScrollBarUI. in 1.5

How to get rid of it.

what needs to to be updated for this to be worked in new version


Thanks in Advance....

-----------------------------------------------------------------------
ERROR is



java.lang.NullPointerException
at pms.ExtGridControl$3.installDefaults(ExtGridContro l.java:38)
at javax.swing.plaf.basic.BasicScrollBarUI.installUI( Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JScrollBar.setUI(Unknown Source)
at pms.ExtGridControl$2.updateUI(ExtGridControl.java: 45)
at javax.swing.JScrollBar.<init>(Unknown Source)
at javax.swing.JScrollBar.<init>(Unknown Source)
at javax.swing.JScrollBar.<init>(Unknown Source)
at pms.ExtGridControl$2.<init>(ExtGridControl.java:33 )
at pms.ExtGridControl.createVerticalScrollBar(ExtGrid Control.java:33)
at javax.swing.JScrollPane.<init>(Unknown Source)
at javax.swing.JScrollPane.<init>(Unknown Source)
at com.borland.jbcl.view.GridView.<init>(GridView.jav a:47)
at com.borland.jbcl.control.GridControl.<init>(GridCo ntrol.java:44)

--------------------------------------------------------------------------


Code


import com.borland.jbcl.control.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;

/**
* extends GridControl:
* inserts a new row if the user clicks into the empty area or scrolls down
*/
public class ExtGridControl extends GridControl{
public ExtGridControl() {

super();
addMouseListener(new MouseAdapter() {

public void mouseReleased(MouseEvent e) {
if (null ==hitTest(e.getPoint().x,e.getPoint().y))
addRow();
}
});
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public JScrollBar createVerticalScrollBar() {
JScrollBar scrollBar = new JScrollBar() {
public void updateUI() {
BasicScrollBarUI myUI = new BasicScrollBarUI (){
protected void installDefaults() {

super.installDefaults();
incrButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(MouseEvent e) {
checkAddRow();
}
});
}
};
setUI(myUI);

}
};
return scrollBar;
}

void checkAddRow() {
try {
if (getRowCount() == getDataSet().getRowCount()) {
SwingUtilities.invokeLater( new Runnable(){
public void run() {
addRow();
}
});
}
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this,ex.getMessage() );
}

}

private void jbInit() throws Exception {
this.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(KeyEvent e) {
this_keyReleased(e);
}
});
}

void this_keyReleased(KeyEvent e) {
if (e.getKeyCode()== e.VK_ENTER || e.getKeyCode() == e.VK_DOWN)
addRow();

}
}

Last edited by praveenrn : 08-03-2007 at 07:21 AM.
Reply With Quote