Kawda java gena danne?
mamm coding ekak liwwa. eke mata one quote karapu text ekath ekkama image ekak display karanda. any help??
mamm coding ekak liwwa. eke mata one quote karapu text ekath ekkama image ekak display karanda. any help??
rochel1977 said:Kawda java gena danne?
mamm coding ekak liwwa. eke mata one quote karapu text ekath ekkama image ekak display karanda. any help??

Zeus said:I'll try machan but im amateur too
Lets see we can help it![]()
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ImageIcon;
public class Quote extends JFrame
{
public static void main(String arg[])
{
final JLabel quote = new JLabel();
JPanel pquote = new JPanel();
JPanel pradio = new JPanel();
quote.setFont(new Font("Helvetica", Font.PLAIN, 24));
final ButtonGroup group = new ButtonGroup();
JRadioButton mahatir = new JRadioButton("Dr.Mahatir",true);
JRadioButton paklah = new JRadioButton("Pak Lah",false);
JRadioButton pckang = new JRadioButton("Phua Chu Kang",false);
pquote.setBackground(Color.green);
pradio.setBackground(Color.yellow);
group.add(mahatir);
group.add(paklah);
group.add(pckang);
pradio.add(mahatir);
pradio.add(paklah);
pradio.add(pckang);
JCheckBox bold = new JCheckBox("BOLD");
JCheckBox italic = new JCheckBox("ITALIC");
class VoteItemListener implements ItemListener {
public void itemStateChanged(ItemEvent ex) {
String item = ((AbstractButton) ex.getItemSelectable()).getActionCommand();
boolean selected = (ex.getStateChange() == ItemEvent.SELECTED);
if(selected)
{
if(item.equals("Dr.Mahatir"))
quote.setIcon(new ImageIcon(getClass().getResource("/1.jpg")));
else if(item.equals("Pak Lah"))
quote.setIcon(new ImageIcon(getClass().getResource("/2.jpg")));
else if(item.equals("Phua Chu Kang"))
quote.setIcon(new ImageIcon(getClass().getResource("/3.jpg")));
}
}
}
ItemListener itemListener = new ItemListener() {
public void itemStateChanged(ItemEvent itemEvent) {
AbstractButton abstractButton = (AbstractButton)itemEvent.getSource();
int state = itemEvent.getStateChange();
if (state == ItemEvent.SELECTED) {
quote.setFont(quote.getFont().deriveFont(quote.getFont().getStyle()+Font.ITALIC));
}
else
quote.setFont(quote.getFont().deriveFont(Font.PLAIN));
}
};
ItemListener itemListenerBold = new ItemListener()
{
public void itemStateChanged(ItemEvent itemEvent)
{
AbstractButton abstractButton = (AbstractButton)itemEvent.getSource();
int state = itemEvent.getStateChange();
if (state == ItemEvent.SELECTED)
{
quote.setFont(quote.getFont().deriveFont(quote.getFont().getStyle()+Font.BOLD));
}
else
quote.setFont(quote.getFont().deriveFont(Font.PLAIN));
}
};
bold.addItemListener(itemListenerBold);
italic.addItemListener(itemListener);
pquote.add(quote);
pquote.add(bold);
pquote.add(italic);
ItemListener al = new VoteItemListener();
mahatir.addItemListener(al);
paklah.addItemListener(al);
pckang.addItemListener(al);
JFrame frame = new JFrame("Quote");
frame.setLayout(new BorderLayout());
frame.add(pquote, BorderLayout.CENTER);
frame.add(pradio, BorderLayout.PAGE_END);
frame.setSize(500, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
amila325 said:plz put ur code in here so we cn look in to that.... and plz wrap it withinCode:blocks "[ code ] [ / code ]" without spaces and quotes :P[/quote] [SIZE=4][COLOR=Green] Seems like "keruma" just showed up :D[/COLOR][/SIZE]
rochel1977 said:thx malli. mata podi coding ekak thamai one. ee kiyane code eka liyala iwarai. radiobutton eka click karadi mata text ekath wadenda one image ekath ekka. menna code eka


amila325 said:plz put ur code in here so we cn look in to that.... and plz wrap it withinCode:blocks "[ code ] [ / code ]" without spaces and quotes :P[/QUOTE] ela i posted it amila. i just want these text to appear also once i click the radio buttons [code]if(item.equals("Dr.Mahatir")) quote.setText("Malaysian Boleh!"); else if(item.equals("Pak Lah")) quote.setText("Work with me: )"); else if(item.equals("Phua Chu Kang")) quote.setText("Don't play-play!");
Zeus said:MEnna mehema siddiyak have
Oya NetBeans ne use karanna atte ?
NetBenas valin genarated codeuth oya meke dalada thiyenne ??
Anna evanam api danne na
Oya liyapuva vitarak dunnanam tavath lesiyi
And balanna referance ehama harida kiyala
![]()
amila325 said:"Keruma"??? in a good or bad way![]()


Ops oyata amila gema pihitayi ehenamrochel1977 said:ne malaya net beans neme. mama use karanne JCreator

this is not a netbeans codingZeus said:MEnna mehema siddiyak have
Oya NetBeans ne use karanna atte ?
NetBenas valin genarated codeuth oya meke dalada thiyenne ??
Anna evanam api danne na
Oya liyapuva vitarak dunnanam tavath lesiyi
And balanna referance ehama harida kiyala
![]()
... dnt wory

lol it's k manZeus said:Oh cmon I didnt mean to tease or disgrace u man
Besides that u r the only one whjo can help Rochel man @ this stage ne![]()

easiest way is to add a label and add the picture thererochel1977 said:ela i posted it amila. i just want these text to appear also once i click the radio buttons
Code:if(item.equals("Dr.Mahatir")) quote.setText("Malaysian Boleh!"); else if(item.equals("Pak Lah")) quote.setText("Work with me: )"); else if(item.equals("Phua Chu Kang")) quote.setText("Don't play-play!");
......amila325 said:this is not a netbeans coding... dnt wory
![]()
![]()

amila325 said:easiest way is to add a label and add the picture there![]()
......
hihi thanx man....Zeus said:So u r the only player in this match
Keep up man![]()
class MyPanel extends JPanel {
private Image img;
public MyPanel(Image img) {
this.img = img;
//do what ever u need to do in the jpanel layouts and everything
}
public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, null);
}
}