hi,
i hv attached some fragments of my code below.
pl, tell y i am not able to get coloured scrollbars and also y whnevr i select any radiobutton(labeled as hidden 1, hiden2 etc)
the scrollpane size is same but scrollbar disaapers and all the radiobuttons get messed up and stuck yo each other making it difficult to make out wch radiobutton to select.
code is:
// Creating hidden layers label and combobox...
hiddenlyrlbl = new JLabel(" Hidden Layers ");
hiddenlyrlbl.setForeground(Color.black);
c2.gridx = 0;
c2.gridy = 2;
c2.gridwidth = 1;
c2.gridheight = 1;
gb2.setConstraints(hiddenlyrlbl, c2);
panel2.add(hiddenlyrlbl);
hiddenlyrcmb = new JComboBox();
hiddenlyrcmb.addItem("0");
for(int i = 1; i <= lv.arraylength; i++)
{
hiddenlyrcmb.addItem(String.valueOf(i));
}
hiddenlyrcmb.addItemListener(this);
hiddenlyrcmb.setEditable(true);
c2.gridx = 1;
c2.gridy = 2;
c2.gridwidth = 1;
c2.gridheight = 1;
gb2.setConstraints(hiddenlyrcmb, c2);
panel2.add(hiddenlyrcmb);
//Creating Hidden Layer Panel which has a label(nonelbl)...
hiddenlyrPnl = new JPanel();
hiddenlyrPnl.setLayout(new GridLayout(0, 1));
hiddenlyrPnl.setBorder(new TitledBorder("Hidden Layer"));
int ver = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int hor = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
jsp = new JScrollPane(hiddenlyrPnl, ver, hor);
jsp.doLayout();
jsp.setPreferredSize(new Dimension(140,130));
jsp.getHorizontalScrollBar().setBackground(Color.cyan);
jsp.getHorizontalScrollBar().setForeground(Color.red);
Color cll = jsp.getHorizontalScrollBar().getForeground();
jsp.getVerticalScrollBar().setBackground(Color.cyan);
jsp.setOpaque(true);
jsp.getVerticalScrollBar().setForeground(Color.red);
Color cl = jsp.getVerticalScrollBar().getForeground();
jsp.getVerticalScrollBar().setForeground(cl);
nonelbl = new JLabel("None");
hiddenlyrPnl.add(nonelbl);
c2.gridx = 0;
c2.gridy = 3;
c2.gridwidth = 2;
c2.gridheight =1;
gb2.setConstraints(jsp, c2);
panel2.add(jsp);
//-------------------------------------------------------------------------------------
// this code is inside actionPerformed()
if (hiddenchosen)
{
for(int i = 0 ; i < hiddenlyrbut.length; i++ )
{
try
{
if (e.getSource() == hiddenlyrbut[i])
{
lrnrulecmb.setEnabled(false);
String s = e.getActionCommand();
hbutindex = i;
createHiddenPanels(s);
Hnodestf.setText(String.valueOf(currHnodes[i]));
Hbiascmb.setSelectedItem(String.valueOf(currHbias[i]));
Hlrnratecmb.setSelectedItem(String.valueOf(currHLrate[i]));
Hactvcmb.setSelectedItem(currHactvselection[i]);
//hiddenchosen = false;
paramPnl = new JPanel();
gb4 = new GridBagLayout();
c4 = new GridBagConstraints();
paramPnl.setLayout(gb4);
c4.fill = GridBagConstraints.BOTH;
c4.anchor = GridBagConstraints.NORTH;
gb4.setConstraints(paramPnl, c4);
paramPnl.add(hiddenDefPanel);
switchParamPanel(paramPnl);
}
}
//-------------------------------------------------------------------------------------
// Creates hidden radio buttons and adding it to hiddenlyrPnl...
void createhiddenlyrPnl(int n)
{
hiddenlyrbut = new JRadioButton[n];
currHactvselection = new String[n];//variable array to store current Hactvcmb choice
currHnodes = new int[n];//denotes no.of neurons in each hidden layer.
currHbias = new double[n];//denotes bias in each hidden layer.
currHLrate = new double[n];//denotes learning rate for each hidden layer.
hiddenlyrPnl.removeAll();
hiddenlyrPnl.setLayout(new GridLayout(n, 1));
if (n == 0)
{
nonelbl = new JLabel("None");
hiddenlyrPnl.add(nonelbl);
}
else
{
if(n<0)
return;
else
{
for(int i = 0; i < n; i++)
{
currHnodes[i] = lv.hnodes[i] = 3;
currHbias[i] = lv.Hbias[i] = -1.0d;
currHLrate[i] = lv.HLrate[i] = 0.7d;
currHactvselection[i] = "Unipolar Sigmoidal";
hiddenlyrbut[i] = new JRadioButton("Hidden Layer" + " " + (i+1));
hiddenlyrPnl.add(hiddenlyrbut[i]);
hiddenlyrbut[i].addActionListener(this);
bg1.add(hiddenlyrbut[i]);
}
}
}
cp.invalidate();
cp.doLayout();
cp.validate();
cp.repaint();
}
//------------------------------------------------------------------------------------
void createHiddenPanels(String s)
{
//create o/p def panel
hiddenDefPanel = new JPanel();
hiddenDefPanel.setBorder(new TitledBorder(s + " Definition"));
gb7 = new GridBagLayout();
c7 = new GridBagConstraints();
hiddenDefPanel.setLayout(gb7);
c7.fill = GridBagConstraints.HORIZONTAL;
nodeslabel = new JLabel(" Nodes ");
nodeslabel.setForeground(Color.black);
c7.gridx = 0;
c7.gridy = 0;
c7.gridwidth = 1;
c7.gridheight = 1;
gb7.setConstraints(nodeslabel, c7);
hiddenDefPanel.add(nodeslabel);
Hnodestf = new JTextField(6);
Hnodestf.setText(" 5 ");
Hnodestf.setEditable(true);
Hnodestf.addActionListener(this);
c7.gridx = 1;
c7.gridy = 0;
c7.gridwidth = 1;
c7.gridheight = 1;
c7.insets = new Insets(0, 20, 5, 150);
gb7.setConstraints(Hnodestf, c7);
hiddenDefPanel.add(Hnodestf);
biaslbl = new JLabel(" Bias ");
biaslbl.setForeground(Color.black);
c7.gridx = 0;
c7.gridy = 1;
c7.gridwidth = 1;
c7.gridheight = 1;
c7.insets = new Insets(0, 0, 0, 0);
gb7.setConstraints(biaslbl, c7);
hiddenDefPanel.add(biaslbl);
Hbiascmb = new JComboBox();
Hbiascmb.addItem("-1");
Hbiascmb.addItem("0");
Hbiascmb.addItem("1");
Hbiascmb.setEditable(true);
Hbiascmb.addItemListener(this);
c7.gridx = 1;
c7.gridy = 1;
c7.gridwidth = 1;
c7.gridheight = 1;
c7.insets = new Insets(0, 20, 5, 150);
gb7.setConstraints(Hbiascmb, c7);
Hbiascmb.setOpaque(true);
Hbiascmb.setBackground(Color.white);
Hbiascmb.setForeground(Color.blue);
hiddenDefPanel.add(Hbiascmb);
lrnratelbl = new JLabel(" Learning rate ");
lrnratelbl.setForeground(Color.black);
c7.gridx = 0;
c7.gridy = 2;
c7.gridwidth = 1;
c7.gridheight = 1;
c7.insets = new Insets(0, 0, 0, 0);
gb7.setConstraints(lrnratelbl, c7);
hiddenDefPanel.add(lrnratelbl);
Hlrnratecmb = new JComboBox();
Hlrnratecmb.addItem("0.7");
Hlrnratecmb.addItem("0.8");
Hlrnratecmb.setEditable(true);
Hlrnratecmb.addItemListener(this);
c7.gridx = 1;
c7.gridy = 2;
c7.gridwidth = 1;
c7.gridheight = 1;
c7.insets = new Insets(0, 20, 5, 150);
gb7.setConstraints(Hlrnratecmb, c7);
hiddenDefPanel.add(Hlrnratecmb);
//actvfuncPnl contains label, combobox, and advance JButton.
actvPnl = new JPanel();
actvPnl.setBorder(new TitledBorder("Activation Setting"));
c7.gridx = 0;
c7.gridy = 3;
c7.gridwidth = 2;
c7.gridheight = 2;
c7.fill = GridBagConstraints.HORIZONTAL;
c7.insets = new Insets(0, 0, 0, 0);
gb13 = new GridBagLayout();
c13 = new GridBagConstraints();
actvPnl.setLayout(gb13);
c13.fill = GridBagConstraints.BOTH;
gb7.setConstraints(actvPnl, c7);
hiddenDefPanel.add(actvPnl, c7);
actvlabel = new JLabel("Activation Function");
actvlabel.setForeground(Color.black);
c13.gridx = 0;
c13.gridy = 0;
c13.gridwidth = 1;
c13.gridheight = 1;
gb13.setConstraints(actvlabel, c13);
actvPnl.add(actvlabel);
Hactvcmb = new JComboBox();
Hactvcmb.addItem(" Unipolar Sigmoid");
Hactvcmb.addItem(" Bipolar Sigmoid");
Hactvcmb.addItem(" Tan Hyperbolic");
Hactvcmb.addItem(" Unipolar Sine");
Hactvcmb.addItem(" Bipolar Sine");
Hactvcmb.addItem(" Unipolar Cosine");
Hactvcmb.addItem(" Bipolar Cosine");
Hactvcmb.addItem(" Decaying Exponential");
Hactvcmb.addItem(" Unipolar ArcTangent");
Hactvcmb.addItem(" Bipolar ArcTangent");
Hactvcmb.addItem(" Gaussian1");
Hactvcmb.addItem(" Gaussian2");
Hactvcmb.addItem(" net to the power'n'");
Hactvcmb.addItem(" Min function");
Hactvcmb.addItem(" Max function");
Hactvcmb.addItem(" Slow Sigmoid");
Hactvcmb.addItem(" Non-saturating Activation Function");
Hactvcmb.addItem(" Bipolar Logarithmic");
Hactvcmb.addItem(" Min-Max function");
Hactvcmb.addItem(" Unipolar Threshold");
Hactvcmb.addItem(" Bipolar Threshold");
Hactvcmb.addItem(" Signum function");
Hactvcmb.addItem(" Linear function");
Hactvcmb.addItem(" Unipolar Threshold Piecewise Linear");
Hactvcmb.addItem(" Bipolar Threshold Piecewise Linear");
Hactvcmb.addItem(" Cauchy Transfer function");
Hactvcmb.addItemListener(this);
Hactvcmb.addActionListener(this);
c13.gridx = 1;
c13.gridy = 0;
c13.gridwidth = 2;
c13.gridheight = 1;
gb13.setConstraints(Hactvcmb, c13);
actvPnl.add(Hactvcmb);
Hactvadvbut = new JButton("Advance...");
Hactvadvbut.setOpaque(true);
Hactvadvbut.setBackground(Color.darkGray);
Hactvadvbut.setForeground(Color.white);
Hactvadvbut.setBorder(new BevelBorder(BevelBorder.RAISED));
Hactvadvbut.addActionListener(this);
c13.gridx = 1;
c13.gridy = 1;
c13.gridwidth = 1;
c13.gridheight = 1;
gb13.setConstraints(Hactvadvbut, c13);
actvPnl.add(Hactvadvbut);
}
//------------------------------------------------------------------------------------------
//in itemS choosing total no.of hiddenlayers to be constructed------------------------------
if (ie.getSource() == hiddenlyrcmb)
{
try
{
hiddenchosen = true;
String str = (String) ie.getItem();
int numh = Integer.parseInt(str);
lv.numhiddenlayers = Integer.parseInt(str);
lv.hnodes = new int[lv.numhiddenlayers];
lv.Hbias = new double[lv.numhiddenlayers];
lv.HLrate = new double[lv.numhiddenlayers];
lv.hiddenlyrInfo = new double[lv.numhiddenlayers][4];
createhiddenlyrPnl(numh);
}
//-----------------------------------------------------------------------------------
thanx