java - No Main Function -
ok, trying run , tells me there no main (i have tried putting 1 in , termination , syntax error) wrong and/or put main function?
here code
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class stylelistener extends jpanel { private static final long serialversionuid = 1l; private jcheckbox bold, italic; private jlabel saying; private jsplitpane splitpane; public stylelistener() { splitpane = new jsplitpane(jsplitpane.vertical_split); splitpane.setonetouchexpandable(true); splitpane.setpreferredsize(new dimension(300,200)); splitpane.setbackground(color.green); splitpane.setdividerlocation(100); jpanel subpanel1 = new jpanel(); subpanel1.setpreferredsize(new dimension(300, 100)); subpanel1.setbackground(color.cyan); saying = new jlabel ("say style!"); saying.setfont (new font ("helvetica", font.plain, 36)); subpanel1.add (saying); splitpane.settopcomponent(subpanel1); jpanel subpanel2 = new jpanel(); subpanel2.setpreferredsize(new dimension(300, 100)); subpanel2.setbackground(color.green); bold = new jcheckbox ("bold"); bold.settooltiptext("check box make text fatter."); bold.setbackground (color.green); italic = new jcheckbox ("italic"); italic.settooltiptext("check box make text slantier looking."); italic.setbackground (color.green); subpanel2.add (bold); subpanel2.add (italic); splitpane.setbottomcomponent(subpanel2); add(splitpane); stylelistener listener = new stylelistener(); bold.additemlistener (listener); italic.additemlistener (listener); public void itemstatechanged (itemevent event) { int style = font.plain; if (bold.isselected()) style = font.bold; if (italic.isselected()) style += font.italic; saying.setfont (new font ("helvetica", style, 36)); }
it's class file.. before trying copy classes should make sure have main function..
try hello world project , add class file project..
Comments
Post a Comment