මුලින්ම මචන් වෙනම එකක් හදා ගනින් මේ විදියට.
ඊලගට ඕන තැනදි ඒ class එකට කතා කලාම හරි.Code:public class LoadPanel { public void loadPanel(JPanel fromPanel, JPanel toPanel) { toPanel.removeAll(); GroupLayout layout = new GroupLayout(toPanel); toPanel.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(fromPanel, -1, -1, 32767)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(fromPanel, -1, -1, 32767)); System.gc(); } }
තේරුනේ නැත්නම් නම් අහපන්z.Code:private void jButton1ActionPerformed(ActionEvent evt) { new LoadPanel().loadPanel(<Panel name>, <load panel name>); }![]()




machan meka nam wada karanda one. balapan wadada kiyala. mama dan haduwe.
JFrame form1 = new JFrame();
JPanel Pnl1 = new JPanel();
JPanel Pnl2 = new JPanel();
form1.add(Pnl1);
Pnl1.add(Pnl2);
Pnl1.setBackground(Color.red);
Pnl2.setBackground(Color.BLUE);
form1.pack();
form1.setVisible(true);




load panel කියන්නෙ අලුතෙන් load කරන්න යන panel එකයි. මුලින්ම උබේ image එක අනුව නිල් පාට කොටසට වෙනම panel එකක් දාගන්න. ඊට පස්සෙ ඒකට component name එක main_panel කියල දාගන්න. ඊලගට openone කියන panel එක නෙ එතනට load කරන්න ඕනෙ. ඒකට අර මම උඩින් දුන්න class එක වෙනම java class එකක් අරන් ලියාගන්න.new LoadPanel().loadPanel(<Panel name>, <load panel name>);
machan meke <load panel name> kiyana 1ta load wenna oona panel 1a object 1 thibbama hariyanna oona neda ? mama ahema karala baluwa aath harigiye nane machoo
thanks machoo help walataaa![]()
මේ විදියට වෙන්න ඕනෙ. ඔය object මගුල් හදාගන්න එපා. මේ විදියට method එක හදාගෙන කරගන්න. එතකොට උබේ ඔය තියෙන buttons ඔක්කොටම ආයිත් codes ලියන්න දෙයක් නෑ. ඕන වෙලාවට method එකට call කරගන්න.private void jButton1ActionPerformed(ActionEvent evt) {
new LoadPanel().loadPanel(openone, main_panel);
}

load panel කියන්නෙ අලුතෙන් load කරන්න යන panel එකයි. මුලින්ම උබේ image එක අනුව නිල් පාට කොටසට වෙනම panel එකක් දාගන්න. ඊට පස්සෙ ඒකට component name එක main_panel කියල දාගන්න. ඊලගට openone කියන panel එක නෙ එතනට load කරන්න ඕනෙ. ඒකට අර මම උඩින් දුන්න class එක වෙනම java class එකක් අරන් ලියාගන්න.
දැන් jbutton action performed එකේ ඒ java class එකේ method එකට call කරගන්න.
මේ විදියට වෙන්න ඕනෙ. ඔය object මගුල් හදාගන්න එපා. මේ විදියට method එක හදාගෙන කරගන්න. එතකොට උබේ ඔය තියෙන buttons ඔක්කොටම ආයිත් codes ලියන්න දෙයක් නෑ. ඕන වෙලාවට method එකට call කරගන්න.![]()
මම කියන දේ කරන්න බැරිද එතකොට මචෝ ? 

කනගාටුවෙන් උනත් කියන්න තියෙන්නෙ උබට Java බෑ කියල තමයි මචන්. මීට වඩා තේරුම් කරන්න බෑ. කරන්න ඕන දේ උපරිම හොදට සරලව තමා දාල තියෙන්නෙ. ඇයි බන් කරන හැටි වෙනුවට Variable name වලින්ම code එකම දීලත් project එක දාගන්න බෑ කියනව නම් ඉතිං java බෑ තමා.අනේ මන්දා මචන් මෙහෙම හරියන්නේත් නැනේමම කියන දේ කරන්න බැරිද එතකොට මචෝ ?
![]()


කනගාටුවෙන් උනත් කියන්න තියෙන්නෙ උබට Java බෑ කියල තමයි මචන්. මීට වඩා තේරුම් කරන්න බෑ. කරන්න ඕන දේ උපරිම හොදට සරලව තමා දාල තියෙන්නෙ. ඇයි බන් කරන හැටි වෙනුවට Variable name වලින්ම code එකම දීලත් project එක දාගන්න බෑ කියනව නම් ඉතිං java බෑ තමා.![]()
මුලින්ම මචන් වෙනම එකක් හදා ගනින් මේ විදියට.
ඊලගට ඕන තැනදි ඒ class එකට කතා කලාම හරි.Code:public class LoadPanel { public void loadPanel(JPanel fromPanel, JPanel toPanel) { toPanel.removeAll(); GroupLayout layout = new GroupLayout(toPanel); toPanel.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(fromPanel, -1, -1, 32767)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(fromPanel, -1, -1, 32767)); System.gc(); } }
තේරුනේ නැත්නම් නම් අහපන්z.Code:private void jButton1ActionPerformed(ActionEvent evt) { new LoadPanel().loadPanel(<Panel name>, <load panel name>); }![]()
