ActionListener Errors
i'm having a lot of problems with this file but the thing i need help most is starts
at Help in the code to the end of the file
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class JenesisShoppingGameWindow extends JFrame
private ProductCheckBoxPanel productPanel;
private GreetingPanel greet;
private ExtraItemsPanel extrasPanel;
private Container contentPane;
private JPanel buttonPanel;
private JButton calcButton;
private JButton exitButton;
private final double TAX_RATE = 0.06;
public JenesisShoppingGameWindow()
super("Jenesis Shopping Game");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
productPanel = new ProductCheckBoxPanel();
extrasPanel = new ExtraItemsPanel();
greet = new GreetingPanel();
buildButtonPanel();
contentPane.add(productPanel, BorderLayout.CENTER);
contentPane.add(extrasPanel, BorderLayout.EAST);
contentPane.add(greet, BorderLayout.NORTH);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
pack();
setVisible(true);
public void buildButtonPanel()
buttonPanel = new JPanel();
calcButton = new JButton("Calculate");
exitButton = new JButton("Exit");
calcButton.addActionListener(
new CalcButtonListener());
exitButton.addActionListener(
new ExitButtonListener());
buttonPanel.add(calcButton);
buttonPanel.add(exitButton);
help
private class CalcButtonListener implements ActionListener
public void actionPerformed (ActionEvent e)
double subtotal;
double total;
double tax;
DecimalFormat money;
money = new DecimalFormat("#,##0.00");
subtotal = productPanel.getProductCost() +
extraItemsPanel.getNonRoutineCost();
tax = extraItemsPanel.lottoMean * TAX_RATE;
total = subtotal + tax;
JOptionPane.showMessageDialog(null,
"Subtotal: $" + money.format(subtotal)+
"\nTax: $" + money.format(tax)+
"\nTotal: $" + money.format(total));
private class ExitButtonListener implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit(0);
}and i get these errors
JenesisShoppingGameWindow.java:49: interface expected here
private class CalcButtonListener implements ActionListener
^
JenesisShoppingGameWindow.java:70: interface expected here
private class ExitButtonListener implements ActionListener
^
JenesisShoppingGameWindow.java:42: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (JenesisShoppingGameWindow.CalcButtonListener)
calcButton.addActionListener(
^
JenesisShoppingGameWindow.java:44: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (JenesisShoppingGameWindow.ExitButtonListener)
exitButton.addActionListener(
^
JenesisShoppingGameWindow.java:61: cannot find symbol
symbol : variable extraItemsPanel
location: class JenesisShoppingGameWindow.CalcButtonListener
extraItemsPanel.getNonRoutineCost();
^
JenesisShoppingGameWindow.java:60: operator + cannot be applied to double,extraItemsPanel.getNonRoutineCost
subtotal = productPanel.getProductCost() +
^
JenesisShoppingGameWindow.java:60: incompatible types
found : <nulltype>
required: double
subtotal = productPanel.getProductCost() +
^
all i really need help with though is the actionlistener stuff
i fixed these problems but ran into a new one not related to this topic
how do i get something from a different method
example
public double getNonRoutineCost()
double totalCost = 0.0;
String str1;
String str2;
double extraCost;
double lottoCost;
double lottom;
str1 = extraStuff.getText();
extraCost = Double.parseDouble(str1);
str2 = lotto.getText();
lottoCost = Double.parseDouble(str2);
lottom = lottoCost * LOTTO_RATE;
totalCost = (extraCost * EXTRA_RATE) + (lottoCost * LOTTO_RATE);
return totalCost;
public double getLottoMean()
double lottoMean;
lottoMean = ;
return lottoMean;
} how do i get lottoMean in getLottoMean() to equal lottom in getNonRoutineCost()?
Similar Messages
-
Strange error while using ActionListener with RichCommandLink
Hi,
I am using Technology preview 3.
I have RichTable bound to af:table in my JSF page.
I am showing database contents inside richTable.
Inside richTable i have one extra column in which i am showing remove link. So every row of table will have remove link. I have added ActionListener as inner class for the backing bean. and this actionlistener i am adding into RichCommandLink(remove link)
But when i click on remove link I am getting weired exception. And i am not able to get why this error is coming.
This problem occures whenever I use contentDelivery parameter with <af:table>
Here is the stack trace of the error.
java.lang.InstantiationException: com.backingBean.UpdateSampleTypeB
ackingBean$MyLinkActionListener
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.myfaces.trinidad.bean.util.StateUtils$Saver.restoreState(S
tateUtils.java:286)
at org.apache.myfaces.trinidad.bean.util.StateUtils.restoreStateHolder(S
tateUtils.java:202)
at org.apache.myfaces.trinidad.bean.util.StateUtils.restoreList(StateUti
ls.java:257)
at org.apache.myfaces.trinidad.bean.PropertyKey.restoreValue(PropertyKey
.java:231)
at org.apache.myfaces.trinidad.bean.util.StateUtils.restoreState(StateUt
ils.java:148)
at org.apache.myfaces.trinidad.bean.util.FlaggedPropertyMap.restoreState
(FlaggedPropertyMap.java:194)
at org.apache.myfaces.trinidad.bean.FacesBeanImpl.restoreState(FacesBean
Impl.java:358)
at org.apache.myfaces.trinidad.component.UIXComponentBase.restoreState(U
IXComponentBase.java:881)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:861)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponent
Base.java:1154)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at org.apache.myfaces.trinidad.component.TreeState.restoreState(TreeStat
e.java:96)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processRestore
State(UIXComponentBase.java:855)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponent
Base.java:1154)
at org.apache.myfaces.trinidadinternal.application.StateManagerImpl.rest
oreView(StateManagerImpl.java:487)
at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl
.java:287)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWra
pper.java:193)
at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.resto
reView(ViewHandlerImpl.java:258)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._restoreView(Li
fecycleImpl.java:438)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(L
ifecycleImpl.java:229)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(Lifecyc
leImpl.java:155)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterC
hain.java:65)
at oracle.adfinternal.view.faces.webapp.rich.SharedLibraryFilter.doFilte
r(SharedLibraryFilter.java:135)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterL
istChain.doFilter(TrinidadFilterImpl.java:284)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter
(RegistrationFilter.java:69)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterL
istChain.doFilter(TrinidadFilterImpl.java:284)
at oracle.adfinternal.view.faces.activedata.ADSFilter.doFilter(ADSFilter
.java:74)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterL
istChain.doFilter(TrinidadFilterImpl.java:284)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invoke
DoFilter(TrinidadFilterImpl.java:208)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilt
erImpl(TrinidadFilterImpl.java:165)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilte
r(TrinidadFilterImpl.java:138)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFi
lter.java:92)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterC
hain.java:15)
at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:1
18)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:611)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:362)
at com.evermind.server.http.HttpRequestHandler.doDispatchRequest(HttpReq
uestHandler.java:915)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequ
estHandler.java:821)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:626)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:599)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpReque
stHandler.java:383)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:161)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:142)
at oracle.oc4j.network.ServerSocketReadHandler$ClientRunnable.run(Server
SocketReadHandler.java:275)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(Server
SocketAcceptHandler.java:237)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocket
AcceptHandler.java:29)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(
ServerSocketAcceptHandler.java:878)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:675)
Can anybody please provide any help on this?
Regards,
HirenHi Simon,
I am using addActionListener method of RichCommandLink
Here is how i am trying to use it.
public class backingBean {
private RichTable table;
public backingBean() {
RichColumn rc = new RichColumn();
RichCommandLink cmd = new RichCommandLink();
MyActionListener listener = new MyActionListener();
cmd.addActionListener(listener);
public RichTable getTable() {
return table;
class MyActionListener implements ActionListener {
public void processAction (ActionEvent actionEvent) throws AbortProcessingException {
// Processing related to edit components of backing bean
Hiren -
Getting index error on ActionListener in for loop
Hi, I am working on a little project where I want to create an array of buttons that each individually delete their record in an ArrayList, well everytime I press the delete button I get an index error, I have been toying around with it and just can't seem to find my error. Here is the code and thanks for looking:
for(j = 0; j < records.size(); j++)
//Set the size for the JTextFields of Names
textname[j] = new JTextField(15);
//Set the size for the JTextFields of Values
textvalue[j] = new JTextField(15);
//Create the delete button
deletebutton[j] = new JButton("Delete" + j);
deletebuttonaction[j] = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
records.remove(j);
deletebutton[j].addActionListener(deletebuttonaction[j]);
//Set the text for the JTextFields of names
textname[j].setText(records.get(j).getName());
//Set the value for the JTextFields of values
textvalue[j].setText(records.get(j).getValue());
//Add the textfields to the content pane.
contentPane.add(textname[j], BorderLayout.CENTER);
contentPane.add(textvalue[j], BorderLayout.CENTER);
contentPane.add(deletebutton[j], BorderLayout.CENTER);
}Ok I see exactly what you're saying, now I just need to devise a plan for dealing with this index error, the only thing is that it used to work on only the first click but with the code you see there I actually get my error right away
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at GUI$7.actionPerformed(GUI.java:362)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Edited by: exutable on Jun 3, 2008 4:49 AM -
How can I put all output error message into a String Variable ??
Dear Sir:
I have following code, When I run it and I press overflow radio button, It outputs following message:
Caught RuntimeException: java.lang.NullPointerException
java.lang.NullPointerException
at ExceptionHandling.ExceptTest.actionPerformed(ExceptTest.java:72)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:291)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)Caught RuntimeException: java.lang.NullPointerException
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)I hope to catch all these error message into a String Variable such as StrErrorMsg, then I can use System.out.println(StrErrorMsg) to print it out or store somewhere, not only display at runtime,
How can I do this??
Thanks a lot,
See code below.
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileInputStream;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class ExceptTest extends JFrame implements ActionListener {
private double[] a;
private JRadioButton divideByZeroButton;
private JRadioButton badCastButton;
private JRadioButton arrayBoundsButton;
private JRadioButton nullPointerButton;
private JRadioButton negSqrtButton;
private JRadioButton overflowButton;
private JRadioButton noSuchFileButton;
private JRadioButton throwUnknownButton;
public ExceptTest() {
JPanel p = new JPanel();
ButtonGroup g = new ButtonGroup();
p.setLayout(new GridLayout(8, 1));
divideByZeroButton = addRadioButton("Divide by zero", g, p);
badCastButton = addRadioButton("Bad cast", g, p);
arrayBoundsButton = addRadioButton("Array bounds", g, p);
nullPointerButton = addRadioButton("Null pointer", g, p);
negSqrtButton = addRadioButton("sqrt(-1)", g, p);
overflowButton = addRadioButton("Overflow", g, p);
noSuchFileButton = addRadioButton("No such file", g, p);
throwUnknownButton = addRadioButton("Throw unknown", g, p);
getContentPane().add(p);
private JRadioButton addRadioButton(String s, ButtonGroup g, JPanel p) {
JRadioButton button = new JRadioButton(s, false);
button.addActionListener(this);
g.add(button);
p.add(button);
return button;
public void actionPerformed(ActionEvent evt) {
try {
Object source = evt.getSource();
if (source == divideByZeroButton) {
a[1] = a[1] / a[1] - a[1];
} else if (source == badCastButton) {
Frame f = (Frame) evt.getSource();
} else if (source == arrayBoundsButton) {
a[1] = a[10];
} else if (source == nullPointerButton) {
Frame f = null;
f.setSize(200, 200);
} else if (source == negSqrtButton) {
a[1] = Math.sqrt(-1);
} else if (source == overflowButton) {
a[1] = 1000 * 1000 * 1000 * 1000;
int n = (int) a[1];
} else if (source == noSuchFileButton) {
FileInputStream is = new FileInputStream("Java Source and Support");
} else if (source == throwUnknownButton) {
throw new UnknownError();
} catch (RuntimeException e) {
System.out.println("Caught RuntimeException: " + e);
e.printStackTrace();
System.out.println("Caught RuntimeException: " + e);
} catch (Exception e) {
System.out.println("Caught Exception: " + e);
public static void main(String[] args) {
JFrame frame = new ExceptTest();
frame.setSize(150, 200);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.show();
}yes, I update as follows,
but not looks good.
import java.io.*;
public class UncaughtLogger implements Thread.UncaughtExceptionHandler {
private File file;
private static String errorMessage;
public UncaughtLogger(File file) {
this.file = file;
//Thread.setDefaultUncaughtExceptionHandler(this);
public UncaughtLogger(String str) {
this.errorMessage = str;
Thread.setDefaultUncaughtExceptionHandler(this);
//@Override()
public void uncaughtException(Thread t, Throwable e){
try {
log(e);
} catch (Throwable throwable) {
System.err.println("error in logging:");
throwable.printStackTrace();
private void log(Throwable e) throws IOException {
PrintWriter out = new PrintWriter(new FileWriter(file, true));
try {
e.printStackTrace(out);
} finally {
out.close();
private static UncaughtLogger logger = new UncaughtLogger(new File("C:/temp/log.txt"));
private static UncaughtLogger logger2 = new UncaughtLogger(errorMessage);
public static void main(String[] args) {
String s1 = "Hello World!";
s1 = null;
String s2 = s1.getClass().getName();
System.out.println(s1);
System.out.println(s2);
System.out.println("errorMessage =" + errorMessage);
} -
Error while opening a popup from managed bean
Hi,
I am trying to open a popup from bean, after another popup is closed. When I open the second popup either through ActionListener(on first popup button) or DialogListener(on first popup), I am getting the below error on browser status bar(!); and the second popup doesn't open. There is no error in the log.
*'AdfPage.PAGE.findComponent(...)' is null or not an object.*
Although the popup id is there on the jspx page.
<af:popup id="confirmationStatus" binding="#{MyBean1.confirmationStatus}">
<af:dialog cancelVisible="false"
closeIconVisible="false" binding="#{MyBean1.d2}"
title="Appointment Confirmation Status">
<af:outputText value="Appointment is successfully confirmed"/>
</af:dialog>
</af:popup>
public void confirmAppointment_dialogListener(DialogEvent dialogEvent) {
FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
String popupId = "confirmationStatus";
service.addScript(context,"AdfPage.PAGE.findComponent('" + popupId + "').show();");
Please tell me why my popup is not getting open from the managed bean and I am getting an error in below line.
service.addScript(context,"AdfPage.PAGE.findComponent('" + popupId + "').show();");To find out the right address of a component related to an other component, open your page select the component you want to add a partial trigger, go to the partial trigger property, select the down arrow at the right end and select 'Edit'. Now look for the popup in the component tree shown on the left side. When you have found the popup shuffle it the the selected side and click OK. The string you see in the field is the full address of the popup related to he component you've selected. Try the string you see there in your bean code. Remove the string from the partial trigger property, it's just to get the correct path.
One other thing to check is that your popup has the ClientComponent property set to true.
Next thing to try, is to use AdfPage.PAGE.findComponentByAbsoluteId(...)
Timo -
Error while exporting a par file from NWDSVersion: 7.0.19 to portal7.0
Hi,
When i tried to export a par file from NWDS to portal. I am getting the following error. Please can any one help me to trace out this error.
21.08.09 / 15:09] #ERROR LEVEL# com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1 > No Information
java.io.FileNotFoundException: http://sgcsapeps:50200/irj/servlet/prt/portal/prteventname/upload/prtroot/com.sap.portal.runtime.system.console.ArchiveUploader?login_submit=on&j_user=XXXXX&j_password=YYYYYYt&j_authscheme=default&uidPasswordLogon=Log%20on
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:792)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.readResponse(DeployEngine.java:363)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.uploadPar(DeployEngine.java:435)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.deploy(DeployEngine.java:221)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1.processUpload(SAPMPWizard.java:416)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1.run(SAPMPWizard.java:350)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:758)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard.performFinish(SAPMPWizard.java:531)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:608)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:321)
at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:583)
at org.eclipse.jface.window.Window.open(Window.java:563)
at org.eclipse.ui.actions.ExportResourcesAction.run(ExportResourcesAction.java:112)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:842)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:456)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:403)
at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:397)
at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:72)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
at com.tssap.util.startup.WBLauncher.run(WBLauncher.java:79)
at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.ide.eclipse.startup.Main.basicRun(Main.java:291)
at com.sap.ide.eclipse.startup.Main.run(Main.java:789)
at com.sap.ide.eclipse.startup.Main.main(Main.java:607)
Thanks in Advance.
Regards
BashaHi,
Just make sure you have maintained correct server setting to check the same open the NWDS and follow this path
Windows/ Prefereces / SAP Enterprise Portal
Check the following enteries
Alias
Host
Port
Login etc.
Regards, -
Error Importaing PAR file in NWDS
Hello All,
I am trying to import a PAR file in nwds. While doing so I am getting the follwing error:
C:\SAP\SAP\NewParProject\dist\PORTAL-INF\META-INF\CVS(Access is denied)
Reason:
Sorry an error occured creating the project.
The Plugin "com.sap.portal.plugins.config-archiver" caised an exception during the "Unpack" operation.
Can you guys help me in resolving this. This is not the first time I am getting this, but previously also when I downloaded some par from our SAP Portal, i got this error.
We are on SP 16 in nwds.
Thanks
AnirbanHello Jitender,
I think you are reffering to server log.
But as the problem is happening in NWDS in my local system, so I am attaching the NWDS log here.
[01.04.09 / 11:18] #ERROR LEVEL# com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.openPar.OpenParWizard > No Information
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:313)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:758)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.openPar.OpenParWizard.performFinish(OpenParWizard.java:232)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:608)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:321)
at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:583)
at org.eclipse.jface.window.Window.open(Window.java:563)
at org.eclipse.ui.actions.ImportResourcesAction.run(ImportResourcesAction.java:96)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:842)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:456)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:403)
at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:397)
at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:72)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
at com.tssap.util.startup.WBLauncher.run(WBLauncher.java:79)
at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.ide.eclipse.startup.Main.basicRun(Main.java:286)
at com.sap.ide.eclipse.startup.Main.run(Main.java:795)
at com.sap.ide.eclipse.startup.Main.main(Main.java:602)
Caused by: java.lang.NullPointerException
at com.sap.portal.util.eclipse.FinishResult.addInformationsInTaskView(FinishResult.java:158)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.openPar.OpenParWizard$1.run(OpenParWizard.java:100)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302)
... 35 more -
Error while running a page which contains a region
Hi ADF Experts,
I am having a jsff page fragment. The fragment has panelbox(with some content and button) and a panel group layout(which contains a region).
On click of the button the panelbox is disclosed to false and the region is to be rendered.
But on page load I am getting the below exception. Earlier the page was coming fine. After dragging the region I am getting this error.
Hierarchy is as below:-
<af:panelBox text="Search Filters" id="pb1" type="stretch"
inlineStyle="width:inherit; height:inherit;"
binding="#{pageFlowScope.TreeModel.searchFilterPanelBox}"
partialTriggers="cb3">
<af:commandButton text="Search" id="cb3" partialSubmit="true"
actionListener="#{pageFlowScope.TreeModel.searchorderProposal}"/>
</af:panelBox>
<af:panelGroupLayout id="pgl15" layout="scroll" binding="#{pageFlowScope.TreeModel.searchResultsDisplay}" rendered="false"
partialTriggers="cb3">
<af:region value="#{bindings.BTFSearchResults1.regionModel}" id="r1"/>
</af:panelGroupLayout>
The region contains
<af:panelGroupLayout id="pgl1" layout="scroll">
<af:panelGroupLayout id="pgl16" inlineStyle="width:1239px; height:inherit;"
layout="horizontal">
<!--some content-->
</af:panelGrouplayout>
onclick of the button the region is rendered as true and the disclosure of the panel box im setting as false.
But after adding the region im getting below error.
Caused by: java.io.FileNotFoundException: MDS-01500: The MDSObject /orderproposals.jsff is an XML document and cannot be loaded using StreamedObject API.
Thanks in advance,
RoyI'm not sure about this but using rendered is always a problem if you want to show show the element during a ppr (which is what you do AFAIK). Once a component has rendered='false' is removed from the component tree and can't be put back in there without a full page refresh.
Try using the visible property instead or use an af:switcher component.
Timo -
Problem with PDFBox-0.7.3 library - Runtime Error
Hello,
The problem is inside the method "chamaConversor".
" conversor.pdfToText(arquivoPdf,arquivoTxt);" make a file.txt from one file.pdf. After that it don?t return the control to "ConstrutorDeTemplate2.java", and show the following error message:
Exception in thread "AWT-EventQueue-O" java.lang.NoClassDefFoundError : org/fontbox/afm/FontMetric
at org.pdfbox.pdmodel.font.PDFont.getAFM (PDFont.java:334)
I am using the NetBeans IDE 5.5.
I have added all of these libraries below to my project from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\external:
* FontBox-0.1.0-dev.jar
* ant.jar
* bcmail-jdk14-132.jar
* junit.jar
* bcprov-jdk14-132.jar
* lucene-core-2.0.0.jar
* checkstyle-all-4.2.jar
* lucene-demos-2.0.0.jar
and PDFBox-0.7.3.jar from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\lib.
There are no more jar from PDFBox-0.7.3 directory.
All of these libraries are in "Compile-time Libraries" option in Project Properties. Should I add they to "Run-time Libraries" option?
What is going on?
Thank you!
* ConstrutorDeTemplate2.java
* Created on 11 de Agosto de 2007, 14:54
* @author
package br.unifacs.dis2007.template2;
// Java core packages
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
// Java extension packages
import javax.swing.*;
import org.pdfbox.*;
public class ConstrutorDeTemplate2 extends JFrame
implements ActionListener {
private JTextField enterField;
private JTextArea outputArea;
private BufferedWriter out;
private String word;
private PdfToText conversor = new PdfToText();
// ajusta a interface do usu?rio
public ConstrutorDeTemplate2()
super( "Testing class File" );
enterField = new JTextField("Digite aqui o nome do arquivo :" );
enterField.addActionListener( this );
outputArea = new JTextArea();
ScrollPane scrollPane = new ScrollPane();
scrollPane.add( outputArea );
Container container = getContentPane();
container.add( enterField, BorderLayout.NORTH );
container.add( scrollPane, BorderLayout.CENTER );
setSize( 400, 400 );
show();
// Exibe as informa??es sobre o arquivo especificado pelo usu?rio
public void actionPerformed( ActionEvent actionEvent )
File name = new File( actionEvent.getActionCommand() );
// Se o arquivo existe, envia para a sa?da as informa??es sobre ele
if ( name.exists() ) {
outputArea.setText(
name.getName() + " exists\n" +
( name.isFile () ?
"is a file\n" : "is not a file\n" ) +
( name.isDirectory() ?
"is a directory\n" : "is not a directory\n" ) +
( name.isAbsolute() ? "is absolute path\n" :
"is not absolute path\n" ) +
"Last modified: " + name.lastModified() +
"\nLength: " + name.length () +
"\nPath: " + name.getPath() +
"\nAbsolute path: " + name.getAbsolutePath() +
"\nParent: " + name.getParent() );
// informa??o de sa?da se "name" ? um arquivo
if ( name.isFile() ) {
String nameString = String.valueOf(name.getPath());
String nameTeste = new String(nameString);
if (nameString.endsWith(".pdf"))
nameTeste = chamaConversor(nameString);
else
if (nameString.endsWith(".doc"))
nameTeste = chamaConversorDoc(nameString); // chama conversor de arquivos DOC
else
if (nameString.endsWith(".txt"))
nameTeste = nameString;
// se o arquivo termina com ".txt"
if (nameTeste.endsWith(".txt"))
// acrescenta conte?do do arquivo ? ?rea de sa?da
try {
// Create the tokenizer to read from a file
FileReader rd = new FileReader(nameTeste);
StreamTokenizer st = new StreamTokenizer(rd);
// Prepare the tokenizer for Java-style tokenizing rules
st.parseNumbers();
st.wordChars('_', '_');
st.eolIsSignificant (true);
// If whitespace is not to be discarded, make this call
st.ordinaryChars(0, ' ');
// These calls caused comments to be discarded
st.slashSlashComments(true);
st.slashStarComments(true);
// Parse the file
int token = st.nextToken();
String word_ant = "";
outputArea.append( " \n" );
out = new BufferedWriter(new FileWriter(nameTeste, true));
while (token != StreamTokenizer.TT_EOF) {
token = st.nextToken();
if (token == StreamTokenizer.TT_EOL){
//out.write(word);
out.flush();
out = new BufferedWriter(new FileWriter(nameTeste, true));
//outputArea.append( word + "\n" );
// out.append ( "\n" );
switch (token) {
case StreamTokenizer.TT_NUMBER:
// A number was found; the value is in nval
double num = st.nval;
break;
case StreamTokenizer.TT_WORD:
// A word was found; the value is in sval
word = st.sval;
// if (word_ant.equals("a") || word_ant.equals("an") || word_ant.equals("the") || word_ant.equals("The") || word_ant.equals("An"))
outputArea.append( word.toString() + " \n " );
// out.append( word + " " );
// word_ant = word;
break;
case '"':
// A double-quoted string was found; sval contains the contents
String dquoteVal = st.sval;
break;
case '\'':
// A single-quoted string was found; sval contains the contents
String squoteVal = st.sval;
break;
case StreamTokenizer.TT_EOL:
// End of line character found
break;
case StreamTokenizer.TT_EOF:
// End of file has been reached
break;
default:
// A regular character was found; the value is the token itself
char ch = (char)st.ttype;
break;
} // fim do switch
} // fim do while
rd.close();
out.close();
} // fim do try
// process file processing problems
catch( IOException ioException ) {
JOptionPane.showMessageDialog( this,
"FILE ERROR",
"FILE ERROR", JOptionPane.ERROR_MESSAGE );
} // fim do if da linha 92 - testa se o arquivo ? do tipo texto
} // fim do if da linha 78 - testa se ? um arquivo
// output directory listing
else if ( name.isDirectory() ) {
String directory[] = name.list();
outputArea.append( "\n\nDirectory contents:\n");
for ( int i = 0; i < directory.length; i++ )
outputArea.append( directory[ i ] + "\n" );
} // fim do else if da linha 184 - testa se ? um diret?rio
} // fim do if da linha 62 - testa se o arquivo existe
// not file or directory, output error message
else {
JOptionPane.showMessageDialog( this,
actionEvent.getActionCommand() + " Does Not Exist",
"ERROR", JOptionPane.ERROR_MESSAGE );
} // fim do m?todo actionPerformed
// m?todo que chama o conversor
public String chamaConversor(String arquivoPdf){
String arquivoTxt = new String(arquivoPdf);
arquivoTxt = arquivoPdf.replace(".pdf", ".txt");
try {
conversor.pdfToText(arquivoPdf,arquivoTxt);
catch (Exception ex) {
ex.printStackTrace();
return (arquivoTxt);
// executa a aplica??o
public static void main( String args[] )
ConstrutorDeTemplate2 application = new ConstrutorDeTemplate2();
application.setDefaultCloseOperation (
JFrame.EXIT_ON_CLOSE );
} // fim do m?todo main
} // fim da classe ExtratorDeSubstantivos2
* PdfToText.java
* Created on 11 de Agosto de 2007, 10:57
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
//package br.unifacs.dis2007.template2;
* @author www
package br.unifacs.dis2007.template2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL ;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.pdmodel.encryption.AccessPermission;
import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
import org.pdfbox.util.PDFText2HTML;
import org.pdfbox.pdmodel.font.PDFont.* ;
import org.pdfbox.util.PDFTextStripper;
import org.pdfbox.util.*;
import org.pdfbox.pdmodel.*;
public class PdfToText
public void pdfToText( String pdfFile, String textFile) throws Exception
Writer output = null;
PDDocument document = null;
try
try
//basically try to load it from a url first and if the URL
//is not recognized then try to load it from the file system.
URL url = new URL( pdfFile );
document = PDDocument.load( url );
String fileName = url.getFile();
if( textFile == null && fileName.length () >4 )
File outputFile =
new File( fileName.substring( 0,fileName.length() -4 ) + ".txt" );
textFile = outputFile.getName();
catch( MalformedURLException e )
document = PDDocument.load( pdfFile );
if( textFile == null && pdfFile.length() >4 )
textFile = pdfFile.substring( 0,pdfFile.length() -4 ) + ".txt";
//use default encoding
output = new OutputStreamWriter( new FileOutputStream( textFile ) );
PDFTextStripper stripper = null;
stripper = new PDFTextStripper();
stripper.writeText( document, output );
finally
if( output != null )
output.close();
if( document != null )
document.close();
}//finally
}//end funcao
All of these libraries are in "Compile-time
Libraries" option in Project Properties. Should I add
they to "Run-time Libraries" option?Yes -
Unable to throw 'Error: A value is required' on a field from bean
Scenario: I have an input text field and a button on a page. The input text is not required initially. I want this to be set to required after the button is clicked. So, I am doing this on the action listener of the button and returning to the page. This just returns to the page but does not throw the required error. The error is thrown the second time I click on the button(No listeners are called this time as the required property is already set). I want the error message to display immediately after clicking the button, the first time(after returning from the bean).
Options Tried:
I used the following in the action listener of the bean
setValueMandatory(true); //Used this as a binding value for the required property on the input field
textValue.setValid(false); //textValue is my input text's binding to the bean
textValue.validate(facesContext);
textValue.processUpdates(facesContext);
textValue.processValidators(facesContext);
AdfFacesContext.getCurrentInstance().addPartialTarget(textValue);
FacesContext.getCurrentInstance().renderResponse();
I am able to focus on the field using the cursor but unable to throw the message. Clearly, some form submit or an action need to occur on the page to render the response(or, repaint the page programmatically). But, how do I do this from the bean?
Jdev Version: 11.1.1.4Divya,
Have you tried passing the Component instead of null in my previous code?
here is the sample i tried and it works fine.
jspx code snippet
<af:inputText label="Label 1" id="it1" binding="#{pageFlowScope.attributeValuesBean.rtx}"/>
<af:commandButton text="commandButton 1" id="cb1"
actionListener="#{pageFlowScope.attributeValuesBean.throwMessage}"/>backing bean snippet
private RichInputText rtx; // add getter and setter
public void throwMessage(ActionEvent actionEvent) {
// Add event code here...
FacesMessage fms = new FacesMessage("A value is required");
fms.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.addMessage(getRtx().getClientId(), fms);
}-Arun -
Par file deployment from nwds - sap-plugin.log error
i'm trying to deploy par file
all my setting are right, but i get error that i see in sap-plugin.log file
Server returned HTTP response code: 401 for URL: http://sapepdev:50100
does anyone knows how to fix that problem?
is my "nwds-> preference-? workbench-> proxy " settings should be like the settings in the browser?
thanks
Ronithe error in sap-plugin.log is:
[02.01.07 / 11:05] #ERROR LEVEL# com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1 > No Information
java.io.IOException: Server returned HTTP response code: 401 for URL: http://sapepdev:50100/irj/servlet/prt/portal/prteventname/upload/prtroot/com.sap.portal.runtime.system.console.ArchiveUploader?login_submit=on&j_user=amit-y&j_password=123456&j_authscheme=default&uidPasswordLogon=Log%20on
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:800)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.readResponse(DeployEngine.java:363)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.uploadPar(DeployEngine.java:435)
at com.sap.portal.developmentTools.general.wizards.upload.DeployEngine.deploy(DeployEngine.java:221)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1.processUpload(SAPMPWizard.java:416)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1.run(SAPMPWizard.java:350)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:758)
at com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard.performFinish(SAPMPWizard.java:531)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:608)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:321)
at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:583)
at org.eclipse.jface.window.Window.open(Window.java:563)
at org.eclipse.ui.actions.ExportResourcesAction.run(ExportResourcesAction.java:112)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:842)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:456)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:403)
at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:397)
at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:72)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
at com.tssap.util.startup.WBLauncher.run(WBLauncher.java:79)
at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.ide.eclipse.startup.Main.basicRun(Main.java:291)
at com.sap.ide.eclipse.startup.Main.run(Main.java:789)
at com.sap.ide.eclipse.startup.Main.main(Main.java:607) -
Error on compile - non-static variable can not be referencedfrom static con
Error on compile happening with addButton?
Thanks
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JFrame;
public class Log implements ActionListener {
JButton addButton;
public static void addComponentsToPane(Container pane) {
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridy = 3;
c.gridx = 0;
JLabel callsignLabel= new JLabel("Callsign");
pane.add(callsignLabel, c);
c.gridy = 3;
c.gridx = 1;
JLabel nameLabel= new JLabel("Name");
pane.add(nameLabel, c);
c.gridy = 3;
c.gridx = 2;
JLabel timeLabel= new JLabel("Time");
pane.add(timeLabel, c);
c.gridy = 3;
c.gridx = 3;
JLabel dateLabel= new JLabel("Date");
pane.add(dateLabel, c);
c.gridy = 3;
c.gridx = 4;
JLabel frequencyLabel= new JLabel("Freq ");
pane.add(frequencyLabel, c);
c.gridy = 3;
c.gridx = 5;
JLabel locationLabel = new JLabel("Country/State");
pane.add(locationLabel, c);
c.gridy = 5;
c.gridx = 0;
addButton = new JButton("Add");
pane.add(addButton, c);
addButton.addActionListener(this);Thank you for the reply
I am new to Java
What is wrong with the way it is coded?The error message tells you what's wrong: You're trying to reference a non-static variable from a static context.
If you don't know what that means, then click the link I provided and look at the results from that google search. You might have to go through a few before you find a satisfactory explanation. And after you've done that, if you have specific questions about things you didn't understand there, please post again. -
Why am I receiving Null pointer Exception Error.
why am I receiving Null pointer Exception Error.
Hi I am developing a code for login screen. There is no syntex error as such ut I am receving the aove mentioned error. Can some one please help me ??
------------ Main.java------------------
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Main implements ActionListener
Frame mainf;
MenuBar mb;
MenuItem List,admitform,inquiry,exit,helpn;
Menu newm,update,help;
Inquiry iq;
Admit ad;
// HosHelp hp;
Howuse hu;
Register reg;
Main()
mainf=new Frame(" Engg College V/S Mumbai University ");
mb=new MenuBar();
newm=new Menu(" New ");
update=new Menu(" Update ");
help=new Menu(" Help ");
List=new MenuItem("List");
admitform=new MenuItem("Admit");
inquiry=new MenuItem("Inquiry");
exit=new MenuItem("Exit");
helpn=new MenuItem("How to Use?");
newm.add(List);
newm.add(admitform);
newm.add(inquiry);
newm.add(exit);
help.add(helpn);
mb.add(newm);
mb.add(update);
mb.add(help);
mainf.setMenuBar(mb);
exit.addActionListener(this);
List.addActionListener(this);
inquiry.addActionListener(this);
admitform.addActionListener(this);
helpn.addActionListener(this);
mainf.setSize(400,300);
mainf.setVisible(true);
public void actionPerformed(ActionEvent ae)
if (ae.getSource()==List)
reg=new Register();
if(ae.getSource()==inquiry)
iq=new Inquiry();
if(ae.getSource()==admitform)
ad=new Admit();
if(ae.getSource()==helpn)
hu=new Howuse();
if(ae.getSource()==exit)
mainf.setVisible(false);
public static void main(String args[])
new Main();
-------------Register.java---------------------------
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Register implements ActionListener//,ItemListener
Label id,name,login,pass,repass;
Button ok,newu,cancel,check;
Button vok,iok,lok,mok,sok; //buttons for dialog boxes
TextField idf,namef,loginf,passf,repassf;
Dialog valid,invlog,less,mismat,acucreat;
Frame regis;
Checkbox admin,limit;
CheckboxGroup type;
DBconnect db;
Register()
db=new DBconnect();
regis=new Frame("Registeration Form");
type=new CheckboxGroup();
admin=new Checkbox("Administrator",type,true);
limit=new Checkbox("Limited",type,false);
id=new Label("ID :");
name=new Label("Name :");
login=new Label("Login :");
pass=new Label("Password :");
repass=new Label("Retype :");
idf =new TextField(20); idf.setEnabled(false);
namef=new TextField(30); namef.setEnabled(false);
loginf=new TextField(30); loginf.setEnabled(false);
passf=new TextField(30); passf.setEnabled(false);
repassf=new TextField(30); repassf.setEnabled(false);
ok=new Button("OK"); ok.setEnabled(false);
newu=new Button("NEW");
cancel=new Button("Cancel");
check=new Button("Check Login"); check.setEnabled(false);
vok=new Button("OK");
iok=new Button("OK");
lok=new Button("OK");
mok=new Button("OK");
sok=new Button("OK");
valid=new Dialog(regis,"Login name is valid !");
invlog=new Dialog(regis,"Login name already exist!");
less=new Dialog(regis,"Password is less than six characters !");
mismat=new Dialog(regis,"password & retyped are not matching !");
acucreat=new Dialog(regis,"You have registered successfully !");
regis.setLayout(null);
// regis.setBackground(Color.orange);
valid.setLayout(new FlowLayout());
invlog.setLayout(new FlowLayout());
less.setLayout(new FlowLayout());
mismat.setLayout(new FlowLayout());
acucreat.setLayout(new FlowLayout());
id.setBounds(35,50,80,25); //(left,top,width,hight)
idf.setBounds(125,50,40,25);
name.setBounds(35,85,70,25);
namef.setBounds(125,85,150,25);
login.setBounds(35,120,80,25);
loginf.setBounds(125,120,80,25);
check.setBounds(215,120,85,25);
pass.setBounds(35,155,80,25);
passf.setBounds(125,155,80,25);
repass.setBounds(35,190,80,25);
repassf.setBounds(125,190,80,25);
admin.setBounds(35,225,100,25);
limit.setBounds(145,225,100,25);
ok.setBounds(45,265,70,25);
newu.setBounds(135,265,70,25);
cancel.setBounds(225,265,70,25);
passf.setEchoChar('*');
repassf.setEchoChar('*');
regis.add(id);
regis.add(idf);
regis.add(name);
regis.add(namef);
regis.add(login);
regis.add(loginf);
regis.add(check);
regis.add(pass);
regis.add(passf);
regis.add(repass);
regis.add(repassf);
regis.add(ok);
regis.add(newu);
regis.add(cancel);
regis.add(admin);
regis.add(limit);
valid.add(vok);
invlog.add(iok);
less.add(lok);
mismat.add(mok);
acucreat.add(sok);
ok.addActionListener(this);
newu.addActionListener(this);
check.addActionListener(this);
cancel.addActionListener(this);
// limit.addItemListener(this);
//admin.addItemListener(this);
vok.addActionListener(this);
iok.addActionListener(this);
lok.addActionListener(this);
mok.addActionListener(this);
sok.addActionListener(this);
regis.setLocation(250,150);
regis.setSize(310,300);
regis.setVisible(true);
public void actionPerformed(ActionEvent ae)
if(ae.getSource()==check)
try{
String s2=loginf.getText();
ResultSet rs=db.s.executeQuery("select* from List");
while(rs.next())
if(s2.equals(rs.getString(2).trim()))
// invlog.setBackground(Color.orange);
invlog.setLocation(250,150);
invlog.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
invlog.setVisible(true);
break;
else
// valid.setBackground(Color.orange);
valid.setLocation(250,150);
valid.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
valid.setVisible(true);
}catch(Exception e)
e.printStackTrace();
if(ae.getSource()==newu)
try{
ResultSet rs=db.s.executeQuery("select max(ID) from List");
while(rs.next())
String s1=rs.getString(1).trim();
int i=Integer.parseInt(s1);
i++;
String s2=""+i;
idf.setText(s2);
newu.setEnabled(false);
namef.setText(""); namef.setEnabled(true);
loginf.setText(""); loginf.setEnabled(true);
passf.setText(""); passf.setEnabled(true);
repassf.setText(""); repassf.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
}catch(Exception e)
e.printStackTrace();
if(ae.getSource()==ok)
try
String s1=idf.getText();
String s2=loginf.getText();
String s3=passf.getText();
String s4=repassf.getText();
int x=Integer.parseInt(s1);
int t;
if(type.getSelectedCheckbox()==admin)
t=1;
else
t=0;
ResultSet rs=db.s1.executeQuery("select* from List");
while(rs.next())
if(s2.equals(rs.getString(2).trim()))
invlog.setBackground(Color.orange);
invlog.setLocation(250,150);
invlog.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
invlog.setVisible(true);
break;
else
if (s3.length()<6)
less.setBackground(Color.orange);
less.setLocation(250,150);
less.setSize(300,100);
ok.setEnabled(false);
cancel.setEnabled(false);
check.setEnabled(false);
less.setVisible(true);
else if(!(s3.equals(s4)))
mismat.setBackground(Color.orange);
mismat.setLocation(250,150);
mismat.setSize(300,100);
ok.setEnabled(false);
cancel.setEnabled(false);
check.setEnabled(false);
mismat.setVisible(true);
else
db.s1.execute("insert into User values("+x+",'"+s2+"','"+s3+"',"+t+")");
acucreat.setBackground(Color.orange);
acucreat.setLocation(250,150);
acucreat.setSize(300,100);
regis.setVisible(false);
acucreat.setVisible(true);
}//else
}//while
} //try
catch(Exception e1)
// e1.printStackTrace();
if (ae.getSource()==cancel)
regis.setVisible(false);
if (ae.getSource()==vok)
ok.setEnabled(true);
cancel.setEnabled(true);
check.setEnabled(true);
valid.setVisible(false);
if (ae.getSource()==iok)
ok.setEnabled(true);
cancel.setEnabled(true);
check.setEnabled(true);
invlog.setVisible(false);
if (ae.getSource()==lok)
less.setVisible(false);
cancel.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
if (ae.getSource()==mok)
mismat.setVisible(false);
cancel.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
if (ae.getSource()==sok)
acucreat.setVisible(false);
ok.setEnabled(false);
newu.setEnabled(true);
regis.setVisible(true);
public static void main(String args[])
new Register();
-----------DBConnect.java------------------------------------
import java.sql.*;
public class DBconnect
Statement s,s1;
Connection c;
public DBconnect()
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:Sonal");
s=c.createStatement();
s1=c.createStatement();
catch(Exception e)
e.printStackTrace();
----------Login.java----------------
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Login implements ActionListener
Frame log;
Label login,pass;
TextField loginf,passf;
Button ok,cancel;
Dialog invalid;
Button iok;
Register reg;
DBconnect db;
Main m;
Login()
db=new DBconnect();
log=new Frame();
log.setLocation(250,210);
login=new Label("Login :");
pass=new Label("Password :");
loginf=new TextField(20);
passf=new TextField(20);
passf.setEchoChar('*');
ok=new Button("OK");
// newu=new Button("New User");
cancel=new Button("CANCEL");
iok=new Button(" OK ");
invalid=new Dialog(log,"Invalid User!");
//log.setBackground(Color.cyan);
//log.setForeground(Color.black);
log.setLayout(null);
// iok.setBackground(Color.gray);
invalid.setLayout(new FlowLayout());
login.setBounds(35,50,70,25); //(left,top,width,hight)
loginf.setBounds(105,50,100,25);
pass.setBounds(35,85,70,25);
passf.setBounds(105,85,70,25);
ok.setBounds(55,130,70,25);
// newu.setBounds(85,120,80,25);
cancel.setBounds(145,130,70,25);
log.add(login);
log.add(loginf);
log.add(pass);
log.add(passf);
log.add(ok);
// log.add(newu);
log.add(cancel);
invalid.add(iok);//,BorderLayout.CENTER);
ok.addActionListener(this);
// newu.addActionListener(this);
cancel.addActionListener(this);
iok.addActionListener(this);
log.setSize(300,170);
log.setVisible(true);
public void actionPerformed(ActionEvent a)
if(a.getSource()==ok)
try{
String l=loginf.getText();
String p=passf.getText();
ResultSet rs=db.s.executeQuery("select * from List");
while(rs.next())
if(l.equals(rs.getString(2).trim())&& p.equals(rs.getString(3).trim()))
String tp=rs.getString(4).trim();
int tp1=Integer.parseInt(tp);
log.setVisible(false);
if(tp1==1)
m=new Main();
// m.List.setEnabled(true);
else
m=new Main();
m.List.setEnabled(false);
break;
else
invalid.setBackground(Color.orange);
invalid.setSize(300,100);
invalid.setLocation(250,210);
cancel.setEnabled(false);
ok.setEnabled(false);
invalid.setVisible(true);
}catch(Exception e1)
e1.printStackTrace();
if (a.getSource()==cancel)
log.setVisible(false);
if (a.getSource()==iok)
invalid.setVisible(false);
loginf.setText("");
passf.setText("");
cancel.setEnabled(true);
ok.setEnabled(true);
public static void main(String[] args)
new Login();
-------------inquiry.java---------------------------------
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.sql.*;
public class Inquiry implements ActionListener
Frame inqry;
Label name,addr;
TextField namef,addrf;
Button ok,cancel,dok;
Dialog invalid;
Frame result; //Result of the inquiry....
Label lrname,lraddr,lward,lrdate,lcdate;
TextField rname,raddr,ward,rdate,cdate;
Date d;
DateFormat df;
Button rok,rcancel;
Dialog success;
Button rdok;
DBconnect db;
Inquiry()
db=new DBconnect();
inqry=new Frame("Inquiry Form");
inqry.setLayout(null);
inqry.setBackground(Color.cyan);
name=new Label(" NAME ");
addr=new Label("ADDRESS");
namef=new TextField(20);
addrf=new TextField(20);
ok=new Button("OK");
cancel=new Button("CANCEL");
dok=new Button("OK");
invalid=new Dialog(inqry,"Invalid Name or Address !");
invalid.setSize(300,100);
invalid.setLocation(300,180);
invalid.setBackground(Color.orange);
invalid.setLayout(new FlowLayout());
result=new Frame(" INQUIRY RESULT "); //Result Window......
result.setLayout(null);
result.setBackground(Color.cyan);
lcdate=new Label(" DATE ");
lrname=new Label(" NAME ");
lraddr=new Label(" ADDRESS ");
lward=new Label(" WARD ");
lrdate=new Label(" ADMIT-DATE ");
cdate=new TextField(10);
rname=new TextField(20);
rname.setEnabled(false);
raddr=new TextField(20);
raddr.setEnabled(false);
ward=new TextField(20);
ward.setEnabled(false);
rdate=new TextField(10);
rdate.setEnabled(false);
cdate=new TextField(20);
d=new Date();
df=DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.KOREA);
cdate.setText(df.format(d));
cdate.setEnabled(false);
rok=new Button(" OK ");
rcancel=new Button("CANCEL");
name.setBounds(40,50,50,25);
namef.setBounds(120,50,130,25);
addr.setBounds(40,100,60,25);
addrf.setBounds(120,100,80,25);
ok.setBounds(60,145,70,25);
cancel.setBounds(140,145,70,25);
lcdate.setBounds(200,50,60,25); //Result Window......
cdate.setBounds(270,50,80,25);
lrname.setBounds(35,85,70,25);
rname.setBounds(140,85,180,25);
lraddr.setBounds(35,120,80,25);
raddr.setBounds(140,120,100,25);
lward.setBounds(35,155,80,25);
ward.setBounds(140,155,100,25);
lrdate.setBounds(30,190,80,25);
rdate.setBounds(140,190,80,25);
rok.setBounds(70,240,70,25);
rcancel.setBounds(170,240,70,25);
inqry.add(name);
inqry.add(namef);
inqry.add(addr);
inqry.add(addrf);
inqry.add(ok);
inqry.add(cancel);
invalid.add(dok);
result.add(lcdate); //Result Window......
result.add(cdate);
result.add(lrname);
result.add(rname);
result.add(lraddr);
result.add(raddr);
result.add(lward);
result.add(ward);
result.add(lrdate);
result.add(rdate);
result.add(rok);
result.add(rcancel);
ok.addActionListener(this);
cancel.addActionListener(this);
dok.addActionListener(this);
rok.addActionListener(this); //Result Window......
rcancel.addActionListener(this);
inqry.setSize(280,180);
inqry.setLocation(300,180);
inqry.setVisible(true);
result.setSize(400,280); //Result Window......
result.setLocation(200,150);
result.setVisible(false);
public void actionPerformed(ActionEvent ae)
if(ae.getSource()==ok)
try
String nm=namef.getText();
String ad=addrf.getText();
inqry.setVisible(false);
ResultSet rs=db.s.executeQuery("select * from Billinformation");
while(rs.next())
String nm1=rs.getString(2).trim();
String ad1=rs.getString(3).trim();
int k=0;
if((nm1.equals(nm))&&(ad1.equals(ad)))
String adm=rs.getString(5).trim();
String wr=rs.getString(6).trim();
String bd=rs.getString(8).trim();
String wrb=wr+"-"+bd;
result.setVisible(true);
rname.setText(nm1);
raddr.setText(ad1);
ward.setText(wrb);
rdate.setText(adm);
k=1;
break;
}//if
else if(k==1)
invalid.setVisible(true);
}//while
}//try
catch(Exception e)
e.printStackTrace();
} //getsource ==ok
if(ae.getSource()==cancel)
inqry.setVisible(false);
if(ae.getSource()==rok) //Result Window......
namef.setText("");
addrf.setText("");
result.setVisible(false);
inqry.setVisible(true);
if(ae.getSource()==rcancel)
result.setVisible(false);
if(ae.getSource()==dok)
namef.setText("");
addrf.setText("");
invalid.setVisible(false);
inqry.setVisible(true);
public static void main(String args[])
new Inquiry();
PLease Help me !!
I need this urgently.can you explain what your program tries to do... and
at where it went wrong..Sir,
We are trying to make an project where we can make a person register in our data base & after which he/she can search for other user.
The logged in user can modify his/her own data but can view other ppl's data.
We are in a phase of registering the user & that's where we are stuck. The problem is that after the login screen when we hit register (OK- button) the data are not getting entered in the data base.
Can u please help me??
I am using "jdk1.3' - studnet's edition.
I am waiting for your reply.
Thanks in advance & yr interest. -
Hello, java newb here.
I have been working on one of my assignments for school. Where as we haven't gotten into GUI yet ... the many required output options of the assignment make it seem almost crazy not to have an interface to navigate with. I have probably bitten off a lot more than I can chew by trying to use tools I'm not ready for yet. I'm trying to learn to create an interface at this time on my own, and when I can get that to work I will begin trying to integrate the actual inputs and outputs of the assignment.
Anyways, I am getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: IntroTest3/java
What I don't understand is the code compiles without errors. Its when I try to run the program that the message is displayed. Can anybody advise me as to perhaps what could be happening between compile time and run time? I don't expect anybody to give me any answers or fix my lousy code. Just trying to learn what to look for when it comes to identifying errors.I will paste the code below. By the way, yes I did insert/modify a lot of pieces from some of the tutorial codes or my textbook codes because I don't know enough to fill in the gaps on my own.
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JFrame;
import javax.swing.KeyStroke;
import java.awt.event.*;
import java.awt.*;
public class IntroTest3 extends JFrame implements ActionListener
{//BEGIN INTROTEST3 CLASS
private JDesktopPane desktop; // Declare a new desktop frame (Instance variable)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public IntroTest3() // Constructor for IntroTest3 class
{//BEGIN INTROTEST3 CONSTRUCTOR
super( "Grade Calculator v1.3" ); // Title bar text
int inset = 50; // This indents the window?
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height - inset*2);
desktop = new JDesktopPane(); // Make a new desktop frame
getContentPane().add( desktop ); // Create the content pane for the desktop frame
setJMenuBar(createMenuBar()); // Menu bar will be made in createMenuBar()
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); // Faster dragging???
}//END INTROTEST3 CONSTRUCTOR
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected JMenuBar createMenuBar()
{//BEGIN CREATEMENUBAR
//- "menuBar" is the menu bar -
JMenuBar menuBar = new JMenuBar(); // Create new menu BAR
* FIRST MENU - " ADD GRADES ". INCLUDES ITEMS: "REGISTER A NEW CLASS", *
* AND "INSERT GRADES". *
//- "add_menu" is first option on menu bar -
JMenu add_menu = new JMenu(" Add Grades "); // Create the first menu on the bar
add_menu.setMnemonic(KeyEvent.VK_A); // Set mnemonic to keystroke A?
menuBar.add( add_menu ); // Add the menu to the menu bar
//- "reg_class" is first item under menu -
//- option "add_menu" -
JMenuItem reg_class = new JMenuItem(" Register A New Class "); //New option under Add Grades menu
reg_class.setMnemonic(KeyEvent.VK_R); // Set mnemonic to keystroke R
reg_class.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_R, ActionEvent.ALT_MASK)); // Uh, whatever that is ;O
reg_class.setActionCommand("reg"); // Assign command "reg" to initiate
reg_class.addActionListener(this); // and add it to ActionListener
add_menu.add(reg_class);
//- "insert_g" is next item under menu -
//- option "add_menu" -
JMenuItem insert_g = new JMenuItem(" Insert New Grades "); //2nd option under Add Grades menu
insert_g.setMnemonic(KeyEvent.VK_I); // Set mnemonic to keystroke I
insert_g.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_I, ActionEvent.ALT_MASK)); // ....
insert_g.setActionCommand("ins"); // Assign command "ins" to initiate
insert_g.addActionListener(this); // and add it to ActionListener
add_menu.add(insert_g);
return (menuBar);
}//END CREATEMENUBAR
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// React to menu selection -
public void actionPerformed(ActionEvent e)
{//BEGIN ACTIONPERFORMED
if ("reg".equals(e.getActionCommand()))
{ //new
createFrame1();
else if ("ins".equals(e.getActionCommand()))
{ //new
createFrame2();
else
quit();
}//END ACTIONPERFORMED
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Create frame for registering a new class -
protected void createFrame1()
{//BEGIN CREATEFRAME1
RegFrame frame = new RegFrame(); // New frame RegFrame
frame.setVisible(true);
desktop.add(frame); // Add new frame to desktop
try
{ // What the fuck is THIS shit?
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}//END CREATEFRAME1
// Create frame for inserting new grades -
protected void createFrame2()
{//BEGIN CREATEFRAME2
InsFrame frame = new InsFrame(); // New frame InsFrame
frame.setVisible(true);
desktop.add(frame); // Add new frame to desktop
try
{ // What the fuck is THIS shit too?
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}//END CREATEFRAME2
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Quit the application.
protected void quit()
System.exit(0);
* COPIED CREATE AND SHOW GUI PIECE FOR TESTING
private static void createAndShowGUI()
{//BEGIN CREATEANDSHOW
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
IntroTest3 frame = new IntroTest3();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Display the window.
frame.setVisible(true);
}//END CREATEANDSHOW
public static void main(String[] args)
{//BEGIN MAIN
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable()
{//BEGIN SOME SHIT
public void run()
createAndShowGUI();
});//END SOME SHIT
}//END MAIN
// TEST TEST TEST
class InsFrame extends JInternalFrame
static final int xOffset = 40, yOffset = 40;
public InsFrame() {
super(" Insert New Grades ",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300); //Set the window's location.
setLocation(xOffset, yOffset);
// TEST TEST TEST
class RegFrame extends JInternalFrame
static final int xOffset = 30, yOffset = 30;
public RegFrame() {
super(" Register a New Class ",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300); //Set the window's location.
setLocation(xOffset, yOffset);
Something else that I don't really understand is when I had the classes RegFrame and InsFrame to create the frames, located in different files, I had problems. The end of the main file, IntroTest3 kept giving me errors saying " 'class' or 'interface' expected."
My teacher gave us this command the other day: javac -classpath . <filename>.java
He said that this tells the file that the public classes it is looking for will be at the same location (in the same directory). I tried this on some sample code in the lab and it worked with what I had, but I guess not here....
However, when I was messing around trying different things, I pasted RegFrame and InsFrame into the same file at the bottom as it is in the above code. After removing "public", it compiled.
So I'm not sure why it occured the way it did.
Anyways if anybody has any advice I would really be grateful, and I promise I'm not one of those obnoxious people who expects somebody on a forum to do their homework for them! Thank you and I'm sorry if I ramble. =(Exception in thread "main" java.lang.NoClassDefFoundError: IntroTest3/javaYou're invoking it like this, aren't you:
java IntroTest3.java
That's wrong. The argument to java should be a class name, not the name of the source file or even the filename of the class.
So what's happening is that the JVM thinks that you're telling it to execute the class called "java" in a package called "IntroTest3".
You should be doing:
java IntroTest3 -
No errors but no sound output . Help !
Dear Java People,
I have a program that has a good look with buttons but the
sound actionPerformed() play() sound does not work.
Below is the coding and below that is the original version
Thank you in advance
Norman
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
public class MyMusicApplet3 extends JApplet implements ActionListener
AudioClip[] acSounds= new AudioClip[9];
public void init()
try
acSounds[0] = getAudioClip(getCodeBase(),"seashore21" + ".mid");
acSounds[1] = getAudioClip(getCodeBase(),"seashore22" + ".mid");
acSounds[2] = getAudioClip(getCodeBase(),"seashore23" + ".mid");
acSounds[3] = getAudioClip(getCodeBase(),"seashore24" + ".mid");
acSounds[4] = getAudioClip(getCodeBase(),"seashore25" + ".mid");
acSounds[5] = getAudioClip(getCodeBase(),"seashore26" + ".mid");
acSounds[6] = getAudioClip(getCodeBase(),"seashore27" + ".mid");
acSounds[7] = getAudioClip(getCodeBase(),"seashore28" + ".mid");
acSounds[8] = getAudioClip(getCodeBase(),"seashore29" + ".mid");
catch (Exception e)
System.out.println("Error here " );
Container myContentPane = getContentPane();
myContentPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
myContentPane.add(getButton("1", Color.orange, Color.blue));
myContentPane.add(getButton("2", Color.blue, Color.yellow));
myContentPane.add(getButton("3", Color.black, Color.white));
myContentPane.add(getButton("4", Color.black, Color.pink));
myContentPane.add(getButton("5", Color.white, Color.red));
myContentPane.add(getButton("6", Color.blue, Color.green));
myContentPane.add(getButton("7", Color.black, Color.cyan));
myContentPane.add(getButton("8", Color.black, Color.yellow));
myContentPane.add(getButton("9", Color.black, Color.cyan));
public void actionPerformed(ActionEvent e)
String command = e.getActionCommand();
int index = Integer.parseInt(command)-1;
acSounds[index].play();
public JButton getButton(String label, Color fore, Color back)
{ JButton button = new JButton("sound "+label);
button.setPreferredSize(new Dimension(90,90));
button.setFont(new Font("Arial", Font.BOLD,14));
button.setBorder(BorderFactory.createRaisedBevelBorder());
button.setForeground(fore);
button.setBackground(back);
button.addActionListener(this);
button.setActionCommand(label);
return button;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
public class MyMusicApplet_1 extends JApplet implements ActionListener
JButton myJButton;
AudioClip acSound_1;
AudioClip acSound_2;
AudioClip acSound_3;
AudioClip acSound_4;
AudioClip acSound_5;
AudioClip acSound_6;
AudioClip acSound_7;
AudioClip acSound_8;
AudioClip acSound_9;
JButton myJButtonSound1;
JButton myJButtonSound2;
JButton myJButtonSound3;
JButton myJButtonSound4;
JButton myJButtonSound5;
JButton myJButtonSound6;
JButton myJButtonSound7;
JButton myJButtonSound8;
JButton myJButtonSound9;
public void init()
try
acSound_1 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_2 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_3 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_4 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_5 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_6 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_7 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_8 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
acSound_9 = getAudioClip(new URL ("c:/Program Files/Cakewalk/Cakewalk Pro Audio 9/seashore.wrk"));
catch (MalformedURLException e)
System.out.println("Error here " );
Container myContentPane = getContentPane();
myContentPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
Dimension buttonSize = new Dimension(190,100);
Font myFont = new Font("Arial", Font.BOLD,14);
Border myEdge = BorderFactory.createRaisedBevelBorder();
//create 1st button's object
myJButtonSound1 = new JButton("sound #1");
myJButtonSound1.addActionListener(this);
//set the button's border and size, font background and foreground
myJButtonSound1.setBorder(myEdge);
myJButtonSound1.setPreferredSize(buttonSize);
myJButtonSound1.setFont(myFont);
myJButtonSound1.setBackground(Color.orange);
myJButtonSound1.setForeground(Color.black);
//create 2nd button's object
myJButtonSound2 = new JButton("sound #2");
myJButtonSound2.addActionListener(this);
//set the button's border and size, font, background and foreground
myJButtonSound2.setBorder(myEdge);
myJButtonSound2.setPreferredSize(buttonSize);
myJButtonSound2.setFont(myFont);
myJButtonSound2.setBackground(Color.blue);
myJButtonSound2.setForeground(Color.black);
//create 3rd button's object
myJButtonSound3 = new JButton("sound #3");
myJButtonSound1.addActionListener(this);
//set the button's border and size, font, background and foreground
myJButtonSound3.setBorder(myEdge);
myJButtonSound3.setPreferredSize(buttonSize);
myJButtonSound3.setFont(myFont);
myJButtonSound3.setBackground(Color.cyan);
myJButtonSound3.setForeground(Color.black);
//create 4th button's object
myJButtonSound4 = new JButton("sound #4");
myJButtonSound4.addActionListener(this);
//set the button's border and size, font background and foreground
myJButtonSound4.setBorder(myEdge);
myJButtonSound4.setPreferredSize(buttonSize);
myJButtonSound4.setFont(myFont);
myJButtonSound4.setBackground(Color.pink);
myJButtonSound4.setForeground(Color.black);
//create 5th button's object
myJButtonSound5 = new JButton("sound #5");
myJButtonSound5.addActionListener(this);
//set the button's border and size, font background and foreground
myJButtonSound5.setBorder(myEdge);
myJButtonSound5.setPreferredSize(buttonSize);
myJButtonSound5.setFont(myFont);
myJButtonSound5.setBackground(Color.red);
myJButtonSound5.setForeground(Color.black);
//create 6th button's object
myJButtonSound6 = new JButton("sound #6");
myJButtonSound6.addActionListener(this);
//set the button's border and size, font, background and foreground
myJButtonSound6.setBorder(myEdge);
myJButtonSound6.setPreferredSize(buttonSize);
myJButtonSound6.setFont(myFont);
myJButtonSound6.setBackground(Color.green);
myJButtonSound6.setForeground(Color.black);
//create 7th button's object
myJButtonSound7 = new JButton("Choice #7");
myJButtonSound7.addActionListener(this);
//set the button's border and size, font, background and foreground
myJButtonSound7.setBorder(myEdge);
myJButtonSound7.setPreferredSize(buttonSize);
myJButtonSound7.setFont(myFont);
myJButtonSound7.setBackground(Color.cyan);
myJButtonSound7.setForeground(Color.black);
//create 8th button's object
myJButtonSound8 = new JButton("Choice #8");
myJButtonSound8.addActionListener(this);
//set the button's border and size, font background and foreground
myJButtonSound8.setBorder(myEdge);
myJButtonSound8.setPreferredSize(buttonSize);
myJButtonSound8.setFont(myFont);
myJButtonSound8.setBackground(Color.yellow);
myJButtonSound8.setForeground(Color.black);
//create 9th button's object
myJButtonSound9 = new JButton("Choice #9");
myJButtonSound9.addActionListener(this);
//set the button's border and size, font background and foreground
myJButtonSound9.setBorder(myEdge);
myJButtonSound9.setPreferredSize(buttonSize);
myJButtonSound9.setFont(myFont);
myJButtonSound9.setBackground(Color.blue);
myJButtonSound9.setForeground(Color.black);
//add the buttons to the content pane
myContentPane.add(myJButtonSound1);
myContentPane.add(myJButtonSound2);
myContentPane.add(myJButtonSound3);
myContentPane.add(myJButtonSound4);
myContentPane.add(myJButtonSound5);
myContentPane.add(myJButtonSound6);
myContentPane.add(myJButtonSound7);
myContentPane.add(myJButtonSound8);
myContentPane.add(myJButtonSound9);
public void actionPerformed(ActionEvent e)
myJButton = (JButton)e.getSource();
if(myJButton == myJButtonSound1)
acSound_1.play();
if(myJButton == myJButtonSound2)
acSound_2.play();
if(myJButton == myJButtonSound3)
acSound_3.play();
if(myJButton == myJButtonSound4)
acSound_4.play();
if(myJButton == myJButtonSound5)
acSound_5.play();
if(myJButton == myJButtonSound6)
acSound_6.play();
if(myJButton == myJButtonSound7)
acSound_7.play();
if(myJButton == myJButtonSound8)
acSound_8.play();
if(myJButton == myJButtonSound9)
acSound_9.play();Norman-
All outawater suggested is that you lop out the code that you are using
for playing sounds and make sure that works, since that seems to be
where your problem is. The rest of your (copious amounts of) applet-
based code is just a distraction at this point.
No, I have no clues as to your possible error. Though the first step that I would take, if this were my code, would be to isolate the part
that's giving me troubles and get it as simple as possible - i.e. make
sure I can write a console app that plays the midi file I want. Then I
would build up from there - i.e. dump that into an applet with one
button that does that.
Good luck to you
Lee
Maybe you are looking for
-
How can I get video out to my TV from my old G4 AGP 450mHz?
Hi all, just wondering if anyone has any idea how to get video out from my old G4 tower? It's an AGP model (1st gen), 450mHz. All I've found so far is a link to very expensive Radeon cards, well beyond what I need, which is: - S-video or even RCA out
-
My iPod Is Seriously Messed Up
I've had my iPod for about two weeks now. I bought it used at a GameStop, because there is no Apple Store anywhere near me. It worked perfectly for the first day, then when I had it in my pocket, my music suddenly turned off and I checked to see wh
-
Transfer customer specific Roles assigned to a customer from R/3 to CRM
Hello dear all, on R/3 side there are customer specific roles defined and assigned to customers. These roles are sales area depending. On CRM side we plant to uses the Employee Responsible relationship to build up these customer specific roles. To di
-
Hard drive not the cure after all
I had a suspected hard drive failure last week See: http://discussions.apple.com/thread.jspa?threadID=2338353&tstart=0 New drive in put osx in all seemed cool, I put ilife 09 in all cool, put iwork 09 in had it check permissions and it repaired some.
-
Move music: IPod to iTunes
I did this once before with some third party software (shareware), but tossed the info. Does anyone know the shareware for moving music from iPod to iTunes. I had to wipe and rebuild my Mac Mini this week and all my music was backed up on my iPod. No