Posts: 79
Threads: 21
Joined: Jan 2012
Reputation:
0
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.Event.*;
public class potpie extends JFrame{
private JList leftlist;
private JList rightlist;
private JButton move;
private String foods[] ={"pizza", "burger" , "hotdog" , "chinese", "pastry"};
public potpie(){
super("the prakhar");
setLayout(new FlowLayout());
leftlist = new JList(foods);
leftlist.setVisibleRowCount(3);
leftlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(leftlist));
move = new JButton("lets move ! :p ");
thehandler handler= new thehandler();
move.addActionListener(handler);
}
public class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){
rightlist.setListData(leftlist.getSelectedValues());
rightlist = new JList();
rightlist.setVisibleRowCount(3);
rightlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(rightlist));
}
}
}
iam getting errors on these lines -->
move.addActionListener(handler);
public class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
I'm not a java programmer, so it might be wrong to mention a few things, but I know of which would be VERY bad for C++. You may have created a few memory leaks.
Use code tags though.
[ code ]code goes here [ /code ]
Remove the spaces after "[" and before "]" for both code tag elements though, I was using that as an example.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
01-22-2012, 06:06 PM
(This post was last modified: 01-22-2012, 06:07 PM by AceInfinity.)
Creating and allocating a variable to heap memory without destroying it after use. Like I said though, I don't really do Java programming, I do Javascript, but that's entirely unrelated, and C++.
Posts: 556
Threads: 36
Joined: Jun 2011
Reputation:
14
Usually memory leaks go undetected by the compiler though, right? This shouldn't prevent him from running the application.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
01-22-2012, 06:20 PM
(This post was last modified: 01-22-2012, 06:21 PM by AceInfinity.)
By the compiler itself, usually yes. There are IDE's that might give you some help on detecting them though, but you can't rely on them as they aren't very accurate and can generate false warnings if you need to keep it in memory to delete it later for your specific program. And that kind of thing can't be interpreted by the IDE or the compiler as neither has a brain like we do.
But no it shouldn't prevent him from running the application. If it continually gets used though and your RAM usage maxes or gets too high then you're in danger. I've had certain instances on my computer not with my program but with games that are known to have problems with later versions of windows making bad calls and my rundll32 was increasing in memory usage at a very fast pace. Using up 2 000 000 K of my RAM before I found out through my task manager, and decided to Reboot because I was noticing slow computer use. That kind of thing is lucky for my though that my system has 8GB RAM.
Posts: 79
Threads: 21
Joined: Jan 2012
Reputation:
0
my querry is solved , i used "E" instead of "e" vents , strange i dint got any error when i used Event
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
01-23-2012, 01:53 AM
(This post was last modified: 01-23-2012, 01:53 AM by AceInfinity.)
So not as dangerous as C++ but more like VB.net where things are taken care of for you automatically? I've only ever used Netbeans for an IDE for Java a couple times.