|
hello, i sort of new to java..
i need to know how and from where can i call the main method to an already exsisting class..
I used jformdesigner to make this..
------------
import java.awt.*;
import javax.swing.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import com.jgoodies.uif_lite.panel.*;
/*
* Created by JFormDesigner on Mon Jan 22 12:40:17 CST 2007
*/
/**
*
*/
public class usb extends JFrame {
public usb() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license
dialogPane = new JPanel();
contentPanel = new JPanel();
simpleInternalFrame1 = new SimpleInternalFrame();
label1 = new JLabel();
buttonBar = new JPanel();
okButton = new JButton();
cancelButton = new JButton();
CellConstraints cc = new CellConstraints();
//======== this ========
setTitle("SAMPLE");
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//======== dialogPane ========
{
dialogPane.setBorder(Borders.DIALOG_BORDER);
// JFormDesigner evaluation mark
dialogPane.setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog",
java.awt.Font.BOLD, 12),
java.awt.Color.red), dialogPane.getBorder()));
dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange
(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
dialogPane.setLayout(new BorderLayout());
//======== contentPanel ========
{
contentPanel.setLayout(new FormLayout(
ColumnSpec.decodeSpecs("default:grow"),
new RowSpec[] {
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC
}));
//======== simpleInternalFrame1 ========
{
simpleInternalFrame1.setTitle("RS Media");
Container simpleInternalFrame1ContentPane =
simpleInternalFrame1.getContentPane();
simpleInternalFrame1ContentPane.setLayout(new FormLayout(
new ColumnSpec[] {
new ColumnSpec("max(pref;5dlu)"),
new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT,
FormSpec.DEFAULT_GROW),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
FormFactory.PREF_COLSPEC
},
new RowSpec[] {
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC
}));
//---- label1 ----
label1.setText("No Robot Found");
label1.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
simpleInternalFrame1ContentPane.add(label1, cc.xy(2, 3));
}
contentPanel.add(simpleInternalFrame1, cc.xy(1, 1));
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
//======== buttonBar ========
{
buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
buttonBar.setLayout(new FormLayout(
new ColumnSpec[] {
FormFactory.GLUE_COLSPEC,
FormFactory.BUTTON_COLSPEC,
FormFactory.RELATED_GAP_COLSPEC,
FormFactory.BUTTON_COLSPEC
},
RowSpec.decodeSpecs("pref")));
//---- okButton ----
okButton.setText("OK");
buttonBar.add(okButton, cc.xy(2, 1));
//---- cancelButton ----
cancelButton.setText("Cancel");
buttonBar.add(cancelButton, cc.xy(4, 1));
}
dialogPane.add(buttonBar, BorderLayout.SOUTH);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
setSize(400, 300);
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license
private JPanel dialogPane;
private JPanel contentPanel;
private SimpleInternalFrame simpleInternalFrame1;
private JLabel label1;
private JPanel buttonBar;
private JButton okButton;
private JButton cancelButton;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
-------------
could someone please help with the class and call the above..
|
|
|
Hi
Looking through your code i couldnt find a main() method, first i would create one. I.e.
public static void main(String args[]){
}
Then create an object of your class which should then allow it to run i.e.
public static void main(String args[]){
class demo = new class();
}
As your class extends JFrame, you dont have to bother with creating frames.
Hope this helps
|
|
|
hey thanks for the answer..
I tried:
public static void main( String[] args ) {
usb frame = new usb();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setVisible(true);
}
but i still get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: usb
any ideas?
<Added>
Environmental Var.
PATH=c:\j2sdk1.4.2_13\bin;
CLASSPATH=%CLASSPATH%;
|
|
|
Ok i cant compile your code, as i do not have the jgoodies package. (just to added if you have designed this interface with software thats fine, but i would first recommend to code interface on your own, writing your own code. It will allow you to make it more effiecient, make the code flexible and maintaintable and you learn more).
Anyway i would add this main method:
public static void main(String args[]){
usb myusb = new usb();
}
to your code, just before the last } of the usb class. I dont see why that shouldnt work, although i have not used this jgoodies package before, i have always used swing(awt before).
Hope this helps.
|
|
|
I anchored that problem-now i charge to put numbers 1-100 is account 1, again i charge to yield all the odd numbers out of account 1 and put them into account 2-i am putting them into account 2 i just charge to apperceive how to yield them out of account 1, pass4sure 642-504 and actuality is the new main. You're still adhering files. I'm not traveling to download them, so unless you POST CODE, pass4sure 642-165 I'm not traveling to advice you. Now do what I told you Break the cipher down as baby as accessible (thus allowance me to advice you) pass4sure 642-661 and again column it in the bulletin itself.
|
|
|
|
|
|
|
|
|
|