D
d.schulz81
Hi,
I can't run this Japplet in a web browser. But the eclipse applet
viewer works...
I guess it's beacause we havn't implemented the methods init, start,
stop and resize.
Can you post some standard example methods?
Should we move the code from the main method in the init method?
Any help will be appreciated...
Thanks alot
Dennis
package mn;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
public class NewJApplet extends javax.swing.JApplet {
private JPanel jPanel2;
private JPanel jPanel1;
private JPanel jPanel3;
private JPanel jPanel7;
private JLabel jLabel1;
private JLabel jLabel4;
private JPanel jPanel5;
private JLabel jLabel5;
private JTextField jTextField2;
private JSlider jSlider2;
private JPanel jPanel10;
private JLabel jLabel3;
private JPanel jPanel9;
private JCheckBox jCheckBox1;
private JPanel jPanel6;
private JPanel jPanel4;
private JSlider jSlider1;
private JLabel jLabel2;
private JButton OK;
private JTextField jTextField1;
private JButton jb1;
private JButton jb2;
{
//Set Look & Feel
try
{
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Auto-generated main method to display this
* JApplet inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
NewJApplet inst = new NewJApplet();
// inst.setSize(500,500);
frame.getContentPane().add(inst);
//((JComponent)frame.getContentPane()).setPreferredSize(new
java.awt.Dimension(
// 500,
// 500));
// frame.setSize(500,500);
frame.pack();
// ((JComponent)frame.getContentPane()).setPreferredSize(new
java.awt.Dimension(
// 500,
// 500));
// frame.setSize(500,500);
// inst.setSize(500,500);
frame.setVisible(true);
}
public NewJApplet() {
super();
initGUI();
}
private void initGUI() {
try {
BorderLayout thisLayout = new BorderLayout();
getContentPane().setLayout(thisLayout);
//this.setSize(576, 300);
{
jPanel2 = new JPanel();
getContentPane().add(jPanel2, BorderLayout.NORTH);
//jPanel2.setPreferredSize(new java.awt.Dimension(576, 78));
}
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.SOUTH);
BorderLayout jPanel1Layout = new BorderLayout();
jPanel1.setLayout(jPanel1Layout);
//jPanel1.setPreferredSize(new java.awt.Dimension(576, 103));
{
jPanel3 = new JPanel();
BorderLayout jPanel3Layout = new BorderLayout();
jPanel3.setLayout(jPanel3Layout);
//jPanel3.setPreferredSize(new java.awt.Dimension(361, 113));
{
jPanel7 = new JPanel();
jPanel7.setPreferredSize(new java.awt.Dimension(600, 35));
{
jLabel2 = new JLabel();
jPanel7.add(jLabel2);
jLabel2.setText("Signal");
jLabel2.setPreferredSize(new java.awt.Dimension(
58,
17));
}
{
jSlider1 = new JSlider();
jPanel7.add(jSlider1);
}
{
jTextField1 = new JTextField();
jPanel7.add(jTextField1);
jTextField1.setText("1000");
}
{
jLabel1 = new JLabel();
jPanel7.add(jLabel1);
jLabel1.setText("Hz");
}
{
jb1 = new JButton();
jPanel7.add(jb1);
jb1.setText("OK");
}
jPanel3.add(jPanel7, BorderLayout.NORTH);
}
{
jPanel10 = new JPanel();
//jPanel10.setPreferredSize(new java.awt.Dimension(
// 339,
// 35));
{
jLabel4 = new JLabel();
jPanel10.add(jLabel4);
jLabel4.setText("Abtastung");
jLabel4.setPreferredSize(new java.awt.Dimension(
58,
17));
}
{
jSlider2 = new JSlider();
jPanel10.add(jSlider2);
}
{
jTextField2 = new JTextField();
jPanel10.add(jTextField2);
jTextField2.setText("1000");
}
{
jLabel5 = new JLabel();
jPanel10.add(jLabel5);
jLabel5.setText("Hz");
}
{
jb1 = new JButton();
jPanel10.add(jb1);
jb1.setText("OK");
}
jPanel3.add(jPanel10, BorderLayout.SOUTH);
}
jPanel1.add(jPanel3, BorderLayout.WEST);
}
{
jPanel4 = new JPanel();
BorderLayout jPanel4Layout = new BorderLayout();
jPanel4.setLayout(jPanel4Layout);
//jPanel4.setPreferredSize(new java.awt.Dimension(186, 68));
{
jPanel6 = new JPanel();
jPanel4.add(jPanel6, BorderLayout.NORTH);
{
jCheckBox1 = new JCheckBox();
jPanel6.add(jCheckBox1);
jCheckBox1.setText("Abtastungspunkte");
}
}
{
jPanel9 = new JPanel();
jPanel4.add(jPanel9, BorderLayout.CENTER);
//jPanel9
// .setPreferredSize(new java.awt.Dimension(202, 53));
{
jLabel3 = new JLabel();
jPanel9.add(jLabel3);
jLabel3.setText("Abtasttheorem ist erfüllt");
}
{
OK = new JButton();
jPanel9.add(OK);
OK.setText("Reset");
}
}
{
jPanel5 = new JPanel();
jPanel4.add(jPanel5, BorderLayout.WEST);
}
jPanel1.add(jPanel4, BorderLayout.EAST);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
I can't run this Japplet in a web browser. But the eclipse applet
viewer works...
I guess it's beacause we havn't implemented the methods init, start,
stop and resize.
Can you post some standard example methods?
Should we move the code from the main method in the init method?
Any help will be appreciated...
Thanks alot
Dennis
package mn;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
public class NewJApplet extends javax.swing.JApplet {
private JPanel jPanel2;
private JPanel jPanel1;
private JPanel jPanel3;
private JPanel jPanel7;
private JLabel jLabel1;
private JLabel jLabel4;
private JPanel jPanel5;
private JLabel jLabel5;
private JTextField jTextField2;
private JSlider jSlider2;
private JPanel jPanel10;
private JLabel jLabel3;
private JPanel jPanel9;
private JCheckBox jCheckBox1;
private JPanel jPanel6;
private JPanel jPanel4;
private JSlider jSlider1;
private JLabel jLabel2;
private JButton OK;
private JTextField jTextField1;
private JButton jb1;
private JButton jb2;
{
//Set Look & Feel
try
{
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Auto-generated main method to display this
* JApplet inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
NewJApplet inst = new NewJApplet();
// inst.setSize(500,500);
frame.getContentPane().add(inst);
//((JComponent)frame.getContentPane()).setPreferredSize(new
java.awt.Dimension(
// 500,
// 500));
// frame.setSize(500,500);
frame.pack();
// ((JComponent)frame.getContentPane()).setPreferredSize(new
java.awt.Dimension(
// 500,
// 500));
// frame.setSize(500,500);
// inst.setSize(500,500);
frame.setVisible(true);
}
public NewJApplet() {
super();
initGUI();
}
private void initGUI() {
try {
BorderLayout thisLayout = new BorderLayout();
getContentPane().setLayout(thisLayout);
//this.setSize(576, 300);
{
jPanel2 = new JPanel();
getContentPane().add(jPanel2, BorderLayout.NORTH);
//jPanel2.setPreferredSize(new java.awt.Dimension(576, 78));
}
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.SOUTH);
BorderLayout jPanel1Layout = new BorderLayout();
jPanel1.setLayout(jPanel1Layout);
//jPanel1.setPreferredSize(new java.awt.Dimension(576, 103));
{
jPanel3 = new JPanel();
BorderLayout jPanel3Layout = new BorderLayout();
jPanel3.setLayout(jPanel3Layout);
//jPanel3.setPreferredSize(new java.awt.Dimension(361, 113));
{
jPanel7 = new JPanel();
jPanel7.setPreferredSize(new java.awt.Dimension(600, 35));
{
jLabel2 = new JLabel();
jPanel7.add(jLabel2);
jLabel2.setText("Signal");
jLabel2.setPreferredSize(new java.awt.Dimension(
58,
17));
}
{
jSlider1 = new JSlider();
jPanel7.add(jSlider1);
}
{
jTextField1 = new JTextField();
jPanel7.add(jTextField1);
jTextField1.setText("1000");
}
{
jLabel1 = new JLabel();
jPanel7.add(jLabel1);
jLabel1.setText("Hz");
}
{
jb1 = new JButton();
jPanel7.add(jb1);
jb1.setText("OK");
}
jPanel3.add(jPanel7, BorderLayout.NORTH);
}
{
jPanel10 = new JPanel();
//jPanel10.setPreferredSize(new java.awt.Dimension(
// 339,
// 35));
{
jLabel4 = new JLabel();
jPanel10.add(jLabel4);
jLabel4.setText("Abtastung");
jLabel4.setPreferredSize(new java.awt.Dimension(
58,
17));
}
{
jSlider2 = new JSlider();
jPanel10.add(jSlider2);
}
{
jTextField2 = new JTextField();
jPanel10.add(jTextField2);
jTextField2.setText("1000");
}
{
jLabel5 = new JLabel();
jPanel10.add(jLabel5);
jLabel5.setText("Hz");
}
{
jb1 = new JButton();
jPanel10.add(jb1);
jb1.setText("OK");
}
jPanel3.add(jPanel10, BorderLayout.SOUTH);
}
jPanel1.add(jPanel3, BorderLayout.WEST);
}
{
jPanel4 = new JPanel();
BorderLayout jPanel4Layout = new BorderLayout();
jPanel4.setLayout(jPanel4Layout);
//jPanel4.setPreferredSize(new java.awt.Dimension(186, 68));
{
jPanel6 = new JPanel();
jPanel4.add(jPanel6, BorderLayout.NORTH);
{
jCheckBox1 = new JCheckBox();
jPanel6.add(jCheckBox1);
jCheckBox1.setText("Abtastungspunkte");
}
}
{
jPanel9 = new JPanel();
jPanel4.add(jPanel9, BorderLayout.CENTER);
//jPanel9
// .setPreferredSize(new java.awt.Dimension(202, 53));
{
jLabel3 = new JLabel();
jPanel9.add(jLabel3);
jLabel3.setText("Abtasttheorem ist erfüllt");
}
{
OK = new JButton();
jPanel9.add(OK);
OK.setText("Reset");
}
}
{
jPanel5 = new JPanel();
jPanel4.add(jPanel5, BorderLayout.WEST);
}
jPanel1.add(jPanel4, BorderLayout.EAST);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}