Changing the color of Java custom scrollbar
Dear Guys, I need a sample script for changing the color of Java custom scrollbox.
Please do the needful.
Thanks and Regards, Morison
Dear Guys, I need a sample script for changing the color of Java custom scrollbox.
Please do the needful.
Thanks and Regards, Morison
Hello Morison
After doing a little research, I have found a code for you that will help you to change the color of the Java scrollbox. Also I have provided you with one link in case you need more information regarding this issue.
 public class ScrollBarTest extends javax.swing.JFrame { Â
/** Creates new form ScrollBarTest */ Â
public ScrollBarTest() { Â
initComponents();Â Â Â
}Â Â
private void initComponents() {//GEN-BEGIN:initComponents Â
jTextArea1 = new javax.swing.JTextArea("Test",10,10); Â
//jTextArea1.set Â
jScrollPane1 = new javax.swing.JScrollPane(jTextArea1); Â
button = new javax.swing.JButton("TestButton"); Â
addWindowListener(new java.awt.event.WindowAdapter() { Â
public void windowClosing(java.awt.event.WindowEvent evt) { Â
exitForm(evt);Â Â
}Â Â
});Â Â
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); Â
getContentPane().add(button, java.awt.BorderLayout.SOUTH); Â
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); Â
setSize(new java.awt.Dimension(200, 150)); Â
setLocation((screenSize.width-150)/2,(screenSize.height-100)/2);Â Â
}//GEN-END:initComponents Â
/** Exit the Application */ Â
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm Â
System.exit(0);Â Â
}//GEN-LAST:event_exitForm Â
/**Â
* @param args the command line argumentsÂ
*/Â Â
public static void main(String args[]) { Â
try{Â Â
javax.swing.UIManager.put("ScrollBar.thumb", new javax.swing.plaf.ColorUIResource(33,129,176)); Â
javax.swing.UIManager.put("Button.foreground", new javax.swing.plaf.ColorUIResource(0,0,0)); Â
}catch(Exception e){ Â
e.printStackTrace();Â Â
}Â Â
ScrollBarTest test = new ScrollBarTest(); Â
test.show();Â Â
} Â
// Variables declaration – do not modify//GEN-BEGIN:variables Â
private javax.swing.JScrollPane jScrollPane1; Â
private javax.swing.JTextArea jTextArea1; Â
private javax.swing.JButton button; Â
// End of variables declaration//GEN-END:variables Â
}
I hope you will find this information useful.
Randolph