Class, interface, or enum expected errors in BULK
Solved/Closed
zlloyd1
Posts
10
Registration date
Tuesday 11 December 2012
Status
Member
Last seen
4 February 2013
-
27 Jan 2013 à 19:49
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 29 Jan 2013 à 20:35
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 29 Jan 2013 à 20:35
Related:
- Java: class, interface, or enum expected
- Minecraft java download - Download - Sandbox
- Bus interface - Guide
- Ubuntu restart network interface - Guide
- Java servlet development kit - Guide
- Samsung java apps - Phones, PDA & GPS Forum
1 response
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
29 Jan 2013 à 07:29
29 Jan 2013 à 07:29
stupid question but is your file named "newclass2.java" (case included)
Beside wrong calls, are you not missing
public class newclass2 extends JFrame implement ActionListener
I would suggest comment of every thing and start with empty shell of class
public class newclass2 extends JFrame implement ActionListener{
}
and one by one start adding lines. It will help you in identifying area where you have issues
Beside wrong calls, are you not missing
public class newclass2 extends JFrame implement ActionListener
I would suggest comment of every thing and start with empty shell of class
public class newclass2 extends JFrame implement ActionListener{
}
and one by one start adding lines. It will help you in identifying area where you have issues
29 Jan 2013 à 07:47
import java.awt.BorderLayout; import java.awt.Desktop; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class newclass2 extends JFrame implements ActionListener { private String s1, s2; private String s3; private JFrame f = new JFrame("text testing"); private JTextField txt = new JTextField(24); private JTextField txt2 = new JTextField(24); private JButton b1 = new JButton("Submit"); private JButton b2 = new JButton("Exit"); public newclass2() { f.setLayout(new BorderLayout()); JPanel p = new JPanel(); p.setLayout(new FlowLayout()); p.add(new JLabel("text1")); p.add(txt); p.add(new JLabel("text2")); p.add(txt2); f.add(p, BorderLayout.CENTER); JPanel p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.add(b1); p2.add(b2); b1.addActionListener(this); b2.addActionListener(this); f.add(p2, BorderLayout.SOUTH); f.setVisible(true); f.setSize(480, 480); } public void actionPerformed(ActionEvent e) { if (e.getSource() == b1) { // txtemp1 = (""); // txttemp2 = (""); String txttemp1 = txt.getText().trim(); String txttemp2 = txt2.getText().trim(); String s3 = ("text here" + txttemp1) + (txttemp2); String data = s3; try { BufferedWriter readz = new BufferedWriter(new FileWriter( new File("C:/users/zlloyd1/desktop/test1.doc"))); readz.write(data); readz.newLine(); readz.close(); System.out.println("Done"); } catch (Exception e2) { System.out.println("Error message text"); } } if (e.getSource() == b2) { JFileChooser choosa = new JFileChooser( "C:/users/zlloyd1/desktop/test1.doc"); int x = choosa.showOpenDialog(null); if (x == JFileChooser.APPROVE_OPTION) { File file = choosa.getSelectedFile(); try { Desktop.getDesktop().open(file); } catch (Exception e3) { System.out.println("Error text"); } } } } public static void main(String args[]) { new newclass2(); } }29 Jan 2013 à 15:24
Beside wrong calls, are you not missing
public class newclass2 extends JFrame implement ActionListener I am not sure exactly what you are saying here, but I have that line in my code??
Also, what wrong calls please??
29 Jan 2013 à 15:38
It should be public class newclass2 extends JFrame implements ActionListener
My stupid, but as I said, I knew it was something small I didn't see that I had done wrong!!
29 Jan 2013 à 20:35