Results 1 to 4 of 4
- 03-25-2012, 03:32 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
writing full program in one class only
//calling class
import javax.swing.JFrame;
class jcheckkbox {
public static void main(String args[]) {
jRadio roof = new jRadio();
roof.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
roof.setSize(300, 200);
roof.setVisible(true);
//secondary class
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class jcheckbox extends JFrame {
private JCheckBox cd;
private JCheckBox md;
private JTextField vcd;
public jcheckbox() {
super("Beer bar");
setLayout(new FlowLayout());
vcd = new JTextField("this is a code", 20);
vcd.setFont(new Font("Serif", Font.PLAIN, 22));
vcd.setToolTipText("yahoo");
add(vcd);
cd = new JCheckBox("bold");
md = new JCheckBox("italic");
add(md);
add(cd);
handler dahandler = new handler();
cd.addItemListener(dahandler);
md.addItemListener(dahandler);
}
private class handler implements ItemListener {
public void itemStateChanged(ItemEvent event) {
Font cool = null;
if (md.isSelected() && cd.isSelected())
cool = new Font("Serif", Font.BOLD + Font.ITALIC, 25);
else if (md.isSelected())
cool = new Font("Serif", Font.BOLD, 30);
else if (md.isSelected())
cool = new Font("Sans_Serif", Font.ITALIC, 30);
vcd.setFont(cool);
}}}
how to write a program in just one class i mean no need calling class for setsize or defaultcloseoperation etc because two classes are harder to compile when making a .jar or .exe out of it,i know there is another way but i want to use this method as it is a lot more easier to make buttons,textfields comboboxes with this methodLast edited by ronnie; 03-25-2012 at 03:33 PM. Reason: modification
-
Re: writing full program in one class only
Sorry, but this doesn't make sense to me. Whether or not you have one or many classes has no bearing on whether you need to set sizes or set the default close operation, and adds little complexity to creating a jar. The rest of your post makes less sense to me. please clarify and ask a specific question if you have one.
- 03-25-2012, 05:38 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Re: writing full program in one class only
so can you guide me how to create jar file with two classes in hand,there are tutorials out there but all are making jar with only one class
-
Re: writing full program in one class only
To create a Jar file with more than one class file when using the jar cf command, simply state all the files that need to be added with a space between each file after the jar file name. It's all spelled out here: Creating a Jar File
Similar Threads
-
Help with writing my own program
By DMarsh12 in forum New To JavaReplies: 4Last Post: 12-30-2011, 03:34 AM -
run last class in full size window
By sonny in forum EclipseReplies: 0Last Post: 03-05-2010, 02:56 PM -
Due Tommorow Writing a Program Please Help
By gallimaufry in forum New To JavaReplies: 4Last Post: 10-23-2008, 03:15 AM -
[SOLVED] open a program full size
By keffie91 in forum Advanced JavaReplies: 2Last Post: 10-05-2008, 10:26 AM -
how begin with writing a new program ?
By dimitrist in forum New To JavaReplies: 11Last Post: 05-13-2008, 03:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks