Having trouble with Class.forName & Class.newInstance
i have a string name of a JPanel class i want to place on a TabbedPane. the JPanel class is in another package, that i import.
i have been trying all kinds of ways to do this, and it is not working. does anyone have any ideas on how to do this?
i need: myTabPane.addTab("financial calc", new myBzPanel());
i tried: myTabPane.addTab("financial calc", Class.newInstance(Class.forName("myBzPanel()"));
without any success.
any ideas appreciated. thanks.
The Class.newInstance() method does not take any arguement and you passed a wrong stuff to the Class.forName(String) method.
Class c = Class.forName("mypackage.myBzPanel");
myBzPanel bz = (myBzPanel)c.newInstance();
myTabPane.addTab("financial calc", bz);
Similar Messages
-
New to java, having trouble with classes
I am new to java and I am having problems importing classes in my first program, please help
hi
please tell, what`s your problem exatly? -
Having trouble with First Class mail
I'm trying to use my email at school (Benito Juarez Community Academy) and also set up Gradespeed but having trouble with both.
In composing mail, the screen will only accept a line or so and no more. I can mail that but message is incomplete. Also, can't get into Gradespeed. All I get is a multicolored pinwheel that is a security check but never stops spinning.See this thread: [[/en-US/questions/894442]] OWA 2010/Firefox 8 and ASHX Attachments
-
I am unable to figure out what I am having trouble with this, here is the code
public class Tools3
protected long item_number;
protected String product_name;
protected long units_in_stock;
protected double price_of_each_unit;
protected static double total_price_of_inventory;
public Tools3( long pitem_number, String pproduct_name, long punits_in_stock, double pprice_of_each_unit)
item_number = pitem_number;
product_name = pproduct_name;
units_in_stock = punits_in_stock;
price_of_each_unit = pprice_of_each_unit;
total_price_of_inventory = punits_in_stock * pprice_of_each_unit;
// Overloaded constructor for empty balance
public Tools3()
item_number = 0;
public void set_item_number( long pitem_number )
item_number = pitem_number;
public void set_product_name( String pproduct_name )
product_name = pproduct_name.toString();
public void set_units_in_stock( long punits_in_stock )
units_in_stock = punits_in_stock;
public void set_price_of_each_unit( double pprice_of_each_unit )
price_of_each_unit = pprice_of_each_unit;
public long get_item_number()
return item_number;
public String get_product_name()
return product_name;
public long get_units_in_stock()
return units_in_stock;
public double get_price_of_each_unit()
return price_of_each_unit;
public double calculate_total_price()
return units_in_stock * price_of_each_unit;
public double calculate_total_price_of_inventory(Tools3[] mytools)
double rettotal = 0;
for (int i = 0; i < mytools.length; i++)
rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_each_unit());
return rettotal;
public void sort_by_names(Tools3[] mytools)
int a,b;
int sortTheStrings = mytools.length - 1;
String tempproduct_name;
long tempitem_number;
long tempunits_in_stock;
double tempprice_of_each_unit;
//need to implement a bubble sort here
for (a = 0; a < sortTheStrings; ++a)
for (b = 0; b < sortTheStrings; ++b)
if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
//move name
tempproduct_name = mytools.product_name;
mytools.product_name = mytools[b+1].product_name;
mytools[b+1].product_name = tempproduct_name;
//move item_number
tempitem_number = mytools.item_number;
mytools.item_number = mytools[b+1].item_number;
mytools[b+1].item_number = tempitem_number;
//move units_in_stock
tempunits_in_stock = mytools.units_in_stock;
mytools.units_in_stock = mytools[b+1].units_in_stock;
mytools[b+1].units_in_stock = tempunits_in_stock;
//move price_of_each_unit
tempprice_of_each_unit = mytools.price_of_each_unit;
mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
mytools[b+1].price_of_each_unit = tempprice_of_each_unit;
//end of tools3.java classResults from javac
C:\Java>javac Tools3.java
Tools3.java:77: cannot find symbol
symbol : method get_units_in_stock()
location: class Tools3[]
rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
ach_unit());
^
Tools3.java:77: cannot find symbol
symbol : method get_price_of_each_unit()
location: class Tools3[]
rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
ach_unit());
^
Tools3.java:94: cannot find symbol
symbol : variable product_name
location: class Tools3[]
if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
^
Tools3.java:97: cannot find symbol
symbol : variable product_name
location: class Tools3[]
tempproduct_name = mytools.product_name;
^
Tools3.java:98: cannot find symbol
symbol : variable product_name
location: class Tools3[]
mytools.product_name = mytools[b+1].product_name;
^
Tools3.java:101: cannot find symbol
symbol : variable item_number
location: class Tools3[]
tempitem_number = mytools.item_number;
^
Tools3.java:102: cannot find symbol
symbol : variable item_number
location: class Tools3[]
mytools.item_number = mytools[b+1].item_number;
^
Tools3.java:105: cannot find symbol
symbol : variable units_in_stock
location: class Tools3[]
tempunits_in_stock = mytools.units_in_stock;
^
Tools3.java:106: cannot find symbol
symbol : variable units_in_stock
location: class Tools3[]
mytools.units_in_stock = mytools[b+1].units_in_stock;
^
Tools3.java:109: cannot find symbol
symbol : variable price_of_each_unit
location: class Tools3[]
tempprice_of_each_unit = mytools.price_of_each_unit;
^
Tools3.java:110: cannot find symbol
symbol : variable price_of_each_unit
location: class Tools3[]
mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
^
11 errors -
I have created a simple application where a user can order items and then i'm saving the order and all the items (details of order) to the dataBase.
i'm using jdk1.5 with jboss and mySql (also hibernate).
i'm having troubles with saving the details of the order, the relevant code is-
order entity -
@Entity
public class Orders implements Serializable
@Id @GeneratedValue
private long orderId; //generated in db
private String name;
public Orders(String userName)
this.userName=userName;
public long getOrderId() { return orderId; }
//getters and setters...
detailsOfOrder entity -
@Entity
public class DetailsOfOrders implements Serializable
@Id
private long orderId;
@Id
private int productId;
private int quantity;
public DetailsOfOrders(long orderId,int productId)
this.productId=productId;
this.orderId=orderId;
public long getOrderId() { return orderId; }
public int getProductId() { return productId; }
//getters and setters...
}session bean (order method) -
List<SCItem> listOfItems; //SCItem is a regular class
Orders order=new Orders(userName);
manager.persist(order);
long orderId=order.getOrderId(); //get order id after persisting
for(SCItem item : listOfItems) //save details of order
DetailsOfOrders detail=new DetailsOfOrders(orderId,"1");
manager.persist(detail); //exception occures here
}when i'm trying to make an order i'm getting the exception-
javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
what is the problem?
thanks in advanced.yes, the entity classes have no-arg constructors (i just tried to write it shortly here...)
about the other thing , well i'm sorry , the right code is-
session bean (order method) -
List<SCItem> listOfItems; //SCItem is a regular class
Orders order=new Orders(userName);
manager.persist(order);
long orderId=order.getOrderId(); //get order id after persisting
for(SCItem item : listOfItems) //save details of order
DetailsOfOrders detail=new DetailsOfOrders(orderId,item.getProductId());
manager.persist(detail); //exception occures here
}what else could it be? -
Having trouble with my signed applet(if it's properly signed that is)
hi
I'm having trouble with my supposedly signed applet. I'm trying to execute a specific program in this case trilian from my browser. i'm using firefox
first my java code
package applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class RunApplet extends JApplet {
JButton jButton = new JButton();
FlowLayout flowLayout1 = new FlowLayout();
public RunApplet() {
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
private void init() throws Exception {
try {
this.getContentPane().setLayout(flowLayout1);
this.setSize(new Dimension(100, 200));
jButton.setText("Trillian");
jButton.addActionListener(new RunApplet_jButton_actionAdapter(this,
"\"C:\\Program Files\\Trillian\\trillian.exe\""));
this.getContentPane().add(jButton, null);
} catch (Exception e) {
e.printStackTrace();
class RunApplet_jButton_actionAdapter implements ActionListener {
private RunApplet adaptee;
private String programPath;
RunApplet_jButton_actionAdapter(RunApplet adaptee, String programPath) {
this.adaptee = adaptee;
this.programPath = programPath;
public void actionPerformed(ActionEvent e) {
try {
Runtime.getRuntime().exec(this.programPath);
} catch (IOException ex) {
}And my applet code
<html>
<body>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<object
classid = "clsid:CAFEEFAC-0015-0000-0005-ABCDEFFEDCBA"
codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab#Version=5,0,50,5"
>
<PARAM NAME = CODE VALUE = "applet.RunApplet.class" >
<PARAM NAME = ARCHIVE VALUE = "myfile.jar" >
<param name = "type" value = "application/x-java-applet;jpi-version=1.5.0_05">
<param name = "scriptable" value = "false">
<comment>
<embed
type = "application/x-java-applet;jpi-version=1.5.0_05" \
CODE = "applet.RunApplet.class" \
ARCHIVE = "myfile.jar"
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">
<noembed>
</noembed>
</embed>
</comment>
</object>
<!--
<applet CODE = "applet.RunApplet.class" ARCHIVE = "myfile.jar">
</applet>
-->
<!--"END_CONVERTED_APPLET"-->
</body>
</html>Creating my key:
keytool -genkey -alias sitekey -keystore "C:\Program Files\Java\jdk1.5.0_05\jre\lib\security\cacerts"Now the process of creating the jar file and signing it:
1. jar cf myfile.jar *.class
2. jarsigner -keystore "C:\Program Files\Java\
jdk1.5.0_05\jre\lib\security\cacerts" myfile.jar sitekeyNow this is the way i've been using then and the first time i get the "do you want to trust" screen but still i get a security exception.
Exception in thread "AWT-EventQueue-10" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkExec(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at applet.RunApplet_jButton_actionAdapter.actionPerformed(RunApplet.java:73)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)Is there anybody who have an idea what can be wrong?
regards
thallishok i solved i myself. i assigned a different and thereby correct keystore and now it works like it should
regards
thallish -
Hi, i am having trouble with my mac mail account, i cannot send or receive any emails because of the server connection problems. Message says it could not be connected to SMTP server. Thanks in advance for your help.
Hello Sue,
I have an iPad 3, iPad Mini and iPhone 5S and they are all sluggish on capitalisation using shift keys. I hope that Apple will solve the problem because it is driving me crazy.
I find using a Microsoft Surface and Windows 8 phone, which I also have, work as well as all the ios devices before the ios 7 upgrade.
It has something to do with the length of time that you need to hold the shift key down. The shift key needs to be held longer than the letter key for the capitalisation to work. For some reason, this is a major change in the way we have learnt to touch type on computers. I am having to relearn how to type!
Michael -
I'm having trouble with a virus or something which affects Google search results when I use Firefox on my PC ...
When I search a topic gives me pages of links as normal, but when I click on a link, the page is hijacked to a site called 'www.goingonearth.com' ...
I've done a separate search and found that other users are affected, but there doesn't seem to be a clear-cut solution ... (Norton, McAfee and Kaspersky don't seem to be able to detect/fix it).
I'd like to continue using the Firefox/Google combination (nb: the hijack virus also affects IE but not Safari) - do you have a patch/fix that could rectify the vulnerability in your software?
thanks''' "... vulnerability in your software?" ''' <br />
And it affects IE, too? Ya probably picked up some malware and you blame it on Firefox.
Install, update, and run these programs in this order. They are listed in order of efficacy.<br />'''''(Not all programs detect the same Malware, so you may need to run them all to solve your problem.)''''' <br />These programs are all free for personal use, but some have limited functionality in the "free mode" - but those are features you really don't need to find and remove the problem that you have.<br />
''Note: If your Malware infection is bad enough and you are mis-directed to URL's other than what is posted, you may have to use a different PC to download these programs and use a USB stick to transfer them to the afflicted PC.''
Malwarebytes' Anti-Malware - [http://www.malwarebytes.org/mbam.php] <br />
SuperAntispyware - [http://www.superantispyware.com/] <br />
AdAware - [http://www.lavasoftusa.com/software/adaware/] <br />
Spybot Search & Destroy - [http://www.safer-networking.org/en/index.html] <br />
Windows Defender: Home Page - [http://www.microsoft.com/windows/products/winfamily/defender/default.mspx]<br />
Also, if you have a search engine re-direct problem, see this:<br />
http://deletemalware.blogspot.com/2010/02/remove-google-redirect-virus.html
If these don't find it or can't clear it, post in one of these forums for specialized malware removal help: <br />
[http://www.spywarewarrior.com/index.php] <br />
[http://forum.aumha.org/] <br />
[http://www.spywareinfoforum.com/] <br />
[http://bleepingcomputer.com] -
my ipad is having trouble with my music... i had recently gotten a new one when i signed into my icloud the music that i had on the orignal one was not there.... some songs were in fact there but not clickable ( it was there only gray)... i was looking for help on how to get the music on the ipad
my ipad is having trouble with my music... i had recently gotten a new one when i signed into my icloud the music that i had on the orignal one was not there.... some songs were in fact there but not clickable ( it was there only gray)... i was looking for help on how to get the music on the ipad
-
I am having trouble with my mac mini ethernet. It had been working for weeks after an update to SL 10.6.8.
Once it went out and i repaired it by defining a new connection from System Preferences ->Network->(left panel service, +).
But yesterday, after a power up. my ethernet was not working again. I tried this old trick to repair it, but the interface choices
listed for '+' a new service did not include Ethernet any more. And the Utilities->System Profiler->Ethernet Cards shows
no ethernet available.
As a last ditch effort i reloaded my original SL from DVD. (I think it was version 10.6.4 but i could be mistaken on the version).
The ethernet worked! But KeyNote wasn't going to work because apparently the version i purchased depends on 10.6.8.
So I upgraded again to SL 10.6.8 (Plus some other updates like AirPort which i don't use).
Now the Ethernet is not working again. I see the same symptoms as before with the Ethernet seeming not installed.
Is this a problem seen by others?
Would going to Lion fix the problem?
Could AirPort actually be the culprit and not SL?
If i stay with my original SL, would i need to repurchase a version of KeyNote for the older version of SL?Have you reset the SMC?
Shut down the computer.
Unplug the computer's power cord.
Wait fifteen seconds.
Attach the computer's power cord.
Wait five seconds, then press the power button to turn on the computer.
While you're at it, resetting the PRAM won't hurt anything and 'might' help is SMC reset didn't work (PRAM does some port control):
Shut down the computer.
Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
Turn on the computer.
Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
Hold the keys down until the computer restarts and you hear the startup sound for the second time.
Release the keys.
Something else you might try .... you don't say how you're updating to 10.6.8, however, if you're using Software Update, you might try downloading the 10.6.8 combo update, which contains all updates to 10.6. Sometimes, Software Update doesn't work quite right, and installing the combo update fixes that. Download the update from Apple's download site at http://support.apple.com/downloads/ , using Disk Utility repair permissions, apply the combo update, then repair permissions again. -
I am having trouble with my links/websites having images attached to them. The place where the image should be is blank. For example, AARP has an A for its image. My storage website has a blank broken box where the image should be. I forgot I had trouble and had to reset Foxfire, this problem occurred after that reset.
cor-el,
Mixed content normally gives the world globe image, unless you are using a theme that uses a broken padlock instead. Maybe the gray triangle means invalid? I came across that in a few themes (what is invalid was not made clear), but those were not using triangle shapes to indicate that.
I came across that mention in one of the pages you posted:
* https://support.mozilla.org/kb/Site+Identity+Button
I cannot attach a screenshot because I have not seen a triangle of any kind in my address bar. -
I have been having troubles with this for months and am extremly tired of not being able to download my songs. I bought these songs off of Itunes as well, so I really hope i can retrieve them. I do not know where to find a personal apple support person yet, does anyone know where to find one on the website?
See these previous discussions:
Waiting applications: Apple Support Communities
Downloading apps stuck on waiting...: Apple Support Communities -
I am having trouble with iMessage being activated. It has worked up until yesterday and now won't activate and is saying no address in the send and receive section. My number is there but not ticked. Any suggestions on how to fix this? I have shut down my phone, but still no luck!
iMessage and FaceTime went down yesterday for some people. Mine is still down. My iMessage is saying the same thing about being activated. Sounds like you are still down too. Ignore the status page that says everything is fine - it lies.
-
I am having trouble with app updates on my iOS 5 iPhone never getting beyond the "waiting" state. I have tried signing out/in of my account, rebooting and removing/re-installing the apps. This started shortly after going to iOS 5 but I am not certain if that is related. All updates that I try now are stuck in "waiting". I also tried removing the apps and then installing via iTunes desktop sync with no improvement. The only thing that I have not tried so far is a restore to a prior iPhone backup. I have not been able to find anything to indciate what the updates on waiting on. There is plenty of space on the iPhone (16gb available). Any suggestions on what to try next?
Hello there, Missy.
First thing I would recommend is to check your downloads queue to make sure there is not an interrupted download per the following Knowledge Base article:
iTunes: How to resume interrupted iTunes Store downloads
http://support.apple.com/kb/HT1725
If your download was interrupted using your iPhone, iPad, or iPod touch
1. From the Home screen, tap the iTunes app.
2. For iPhone or iPod touch, tap More > Downloads. For iPad, tap Downloads.
3. Enter your account name and password if prompted.
4. Tap the blue download arrow to resume.
If you can't complete the download on your iOS device, you can download it in iTunes on your Mac or PC and then sync it to your iOS device. You can also transfer purchases from your iPhone, iPad, or iPod to a computer.
For Apps, you can also try tapping on the application icon to resume the download, as outline in this featured discussion:
App updates won't download on my...: Apple Support Communities
https://discussions.apple.com/thread/4111336
Try tapping the App, so that it changes to Paused instead of Waiting, then tap it again to resume the install.
Make sure you don't have any paused downloads in other apps either, like the App Store or iTunes Store.
If that doesn't do it, try resetting or restoring the iPhone.
via whatheck
Thanks for reaching out to Apple Support Communities.
Cheers,
Pedro. -
In Mail, I am having trouble with my cursor. When making revisions to what I have already typed, the cursor doesn't "land" where I "click" it to be. It seems to land somewhere below the spot I click on. It seems to have a mind of its own.
Cool handyandy42!
I'm happy I could be helpful, with solving your problem!
Also, I notice that you have marked your question as answered, but have not utilized the Helpful or Solved options. That may be intentional, but, if you are not aware of the benefits, of using that function, here is some information.
When you mark the appropriate posts as Helpful (5 pts) 2 available, or Solved (10 pts) 1 available, you are Thanking the contributors, by awarding them points.
In threads with multiple replies, it also alerts other readers, to which answers may have been helpful, or solved the issue.
This info, and more, can be viewed by clicking on
? Help & Terms of Use, located under your login name, on all "Discussions" pages.
Specifically What are question answers?.
ali b
Maybe you are looking for
-
How can I migrate my group lists with my address book?
I have moved from Windows XP to Ubuntu (YEAH!). I was using TB in XP and I was able to successfully move my address book with all of my contacts' information by copying and pasting the abook.mab file. But I seem to have lost (or at least I am current
-
Ipod classic hard drive coming back saying error after a diagnostics test
i recently done my disk check on my ipod classic hard drive and it flashed up error instead of the numbers people normally get when doing this. does this mean the hard drive is finished. it was letting me sync 200 songs out of 9000 i have but no more
-
Problem with depositioned picture boxes after export or printing
I have created a template with 20 boxes (4x5) defined as placeholders for pictures. The alignment and margins between the boxes are set to be exactly equal (it's one millimetre actually). On the screen of my MBP everything looks good. But when I prin
-
Insert collapsible panel in Spry menu
Hi, Can a collapsible panel be inserted into a Spry menu. When clicked, I would like one of my menu items to slide open exposing another menu. Kind of a sub catagory of the menu item. Sorry for the poor discription. Thanks Dennis
-
How to install/configure Oracle AS
Does anyone have any links to installing and configuring Oracle Application Server for Oracle 10g release 2 on a standalone desktop? I have installed Oracle 10g R2 and I just want to deploy my Oracle Forms (for 10g) on the Web. Thanks in advance.