Can't run this bit of code

i cn't get this bit of code to work, it was working fine at home and now when i want to run it on another computer i can't, can anyone help me????
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestCheckBox extends JPanel
     private JCheckBox cb1,cb2;
     private JComboBox c1;
     private JTextField tf1;
     private ActionHandler h1;
     public void init()
          setLayout(new FLowLayout());
          h1 = new ActionHandler(this);
          String [] s = {"Serif", "SansSerif"};
          c1 = new JComboBox (s);
          c1.addActionListener(h1);
          add(c1);
          Font font = new Font ( c1.getItemAt (0).toString(), Font.Plain, 14);
          tf1 = new JTextField("Test String", 20);
          tf1.setEditable (false);
          tf1.setFont (font);
          add.(tf1);
          cb1 = new JCheckBox ("Bold");
          cb1.addActionListener (h1);
          cb1.setMnemonic('b');
          add(cb1);
          cb2 = new JCheckBox ("Italics");
          cb2.addActionListener(h1);
          cb2.setMnemonic('i');
          add(cb2);
     public void updateFont()
          int valBold, valItalic;
          int fontStyle = tf1.getFont().getStyle();
          int fontSize = tf1.getFont().getSize();
          String fontName = (String) c1.getSelectedItem();
          valBold = cb1.isSelected() ? Font.BOLD : Font.PLAIN;
          valItalic = cb2.isSelected() ? Font.ITALIC : Font.PLAIN;
          fontStyle = valBold + valItalic;
          tf1.setFont(new Font(fontName, fontStyle, fontSize));
          tf1.repaint();
     public static void main (String s[])
          JFrame fr = new JFrame("TestCheckBox");
     class ActionHandler implements ActionListener
          private TestCheckBox tcb;
          public ActionHandler(TestCheckBox T)
          tcb = t;
          public void actionPerformed(ActionEvent e )
          tcb.updateFont();
}

* @(#)TestCheckComboBox.java     Tiger 2005 May 12
package com.yahoo.ron.examples;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
* A Java program that run as an applet and application.
* This test swing checkbox and combobox.
// I hope this helps a little. If theres a problem just make some modification. -author
public class TestCheckComboBox extends JApplet{
     private Font font;
     private class TestPanel extends JPanel{
          private String text = "Test Font";
          TestPanel(){
               setPreferredSize(new Dimension(300, 300));
          public void paint(Graphics g){
               super.paint(g);
               if(font == null) return;
               g.setFont(font);
               FontMetrics fm = g.getFontMetrics(font);
               int x = (getWidth() - fm.stringWidth(text)) / 2;
               int y = (getHeight() - fm.getHeight()) / 2;
               g.drawString(text, x, y);
          void setText(String text){
               if(text != null && text.length() != 0) this.text = text;
     private class ControlPanel extends JPanel implements ItemListener{
          private JCheckBox italics, bold, plain;
          private JComboBox fontSelection;
          private JPanel panel;
          ControlPanel(JPanel panel){
               if(panel != null)
                    this.panel = panel;
               setLayout(new GridLayout(1, 4, 5, 5));
               GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
               add(fontSelection = new JComboBox(ge.getAvailableFontFamilyNames());
               add(bold = new JCheckBox("Bold"));
               add(italics = new JCheckBox("Italics"));
               add(plain = new JCheckBox("Plain"));
               fontSelection.setMaximumRowCount(4);
               fontSelection.addItemListener(this);
               bold.addItemListener(this);
               italics.addItemListener(this);
               plain.addItemListener(this);
               plain.setSelected(true);
          public void itemStateChanged(ItemEvent ie){
               if(panel == null) return;
               String fontName = String.valueOf(fontSelection.getSelectedItem());
               int style = Font.PLAIN;
               if(plain.isSelected()){
                    // do nothing.
               else if(bold.isSelected() && italics.isSelected())
                    style = Font.BOLD + Font.ITALIC;
               else if(bold.isSelected())
                    style = Font.BOLD;
               else if(italics.isSelected())
                    style = Font.ITALIC;
               font = new Font(fontName, style, 14);
               panel.repaint();
     public void init(){
          setPreferredSize(new Dimension(350, 350));
          setLayout(new BorderLayout());
          JPanel tPanel = new TestPanel();
          JPanel cPanel = new ControlPanel(tPanel);
          add(BorderLayout.CENTER, tPanel);
          add(BorderLayout.SOUTH, cPanel);
     static public void main(String[] args){
          JFrame frame = new JFrame("Testing Swing Check Box And Combo Box");
          frame.setPreferredSize(new Dimension(350, 350));
          frame.setLayout(new BorderLayout());
          JPanel tPanel = new TestPanel();
          JPanel cPanel = new ControlPanel(tPanel);
          frame.add(BorderLayout.CENTER, tPanel);
          frame.add(BorderLayout.SOUTH, cPanel);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
}

Similar Messages

  • I have an old file that was made by macromedia flash,but I can't run this file in my Windows 7 64-bit ,while I can run it in Windows XP 32-bit

    I have an old file that was made by macromedia flash,but I can't run this file in my Windows 7 64-bit ,while I can run it in Windows XP 32-bit

    Hi momi macrom,
    Have moved your post to the Flash forum. Experts here are better placed to help you.
    Thanks,
    Preran

  • How  can i run this code correctly?

    hello, everybody:
        when  i run the code, i found that it dons't work,so ,i  hope somebody can help me!
        the Ball class is this :
        package {
        import flash.display.Sprite;
        [SWF(width = "550", height = "400")]
        public class Ball extends Sprite {
            private var radius:Number;
            private var color:uint;
            private var vx:Number;
            private var vy:Number;
            public function Ball(radius:Number=40, color:uint=0xff9900,
            vx:Number =0, vy:Number =0) {
                this.radius= radius;
                this.color = color;
                this.vx = vx;
                this.vy = vy;
                init();
            private function init():void {
                graphics.beginFill(color);
                graphics.drawCircle(0,0,radius);
                graphics.endFill();
    and the Chain class code is :
    package {
        import flash.display.Sprite;
        import flash.events.Event;
        [SWF(width = "550", height = "400")]
        public class Chain extends Sprite {
            private var ball0:Ball;
            private var ball1:Ball;
            private var ball2:Ball;
            private var spring:Number = 0.1;
            private var friction:Number = 0.8;
            private var gravity:Number = 5;
            //private var vx:Number =0;
            //private var vy:Number = 0;
            public function Chain() {
                init();
            public function init():void {
                ball0  = new Ball(20);
                addChild(ball0);
                ball1 = new Ball(20);
                addChild(ball1);
                ball2 = new Ball(20);
                addChild(ball2);
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            private function onEnterFrame(event:Event):void {
                moveBall(ball0, mouseX, mouseY);
                moveBall(ball1, ball0.x, ball0.y);
                moveBall(ball2, ball1.x, ball1.y);
                graphics.clear();
                graphics.lineStyle(1);
                graphics.moveTo(mouseX, mouseY);
                graphics.lineTo(ball0.x, ball0.y);
                graphics.lineTo(ball1.x, ball1.y);
                graphics.lineTo(ball2.x, ball2.y);
            private function moveBall(ball:Ball,
                                      targetX:Number,
                                      targetY:Number):void {
                ball.vx += (targetX - ball.x) * spring;
                ball.vy += (targetY - ball.y) * spring;
                ball.vy += gravity;
                ball.vx *= friction;
                ball.vy *= friction;
                ball.x += vx;
                ball.y += vy;
    thanks every body's help!

    ok, thanks for your reply ! I run this code in the Flex builder 3!and the Ball class and the Chain class are all in the same AS project!
      and i changed the ball.pv property as public in the Ball class, and  the Chain class has no wrong syntactic analysis,but the AS code don't run.so this is the problem.
    2010-04-21
    Fang
    发件人: Ned Murphy <[email protected]>
    发送时间: 2010-04-20 23:01
    主 题: how  can i run this code correctly?
    收件人: fang alvin <[email protected]>
    I don't see that the Ball class has a pv property, or that you even try to access a pv property in the Chain class.  All of the properties in your Ball class are declared as private, so you probably cannot access them directly.  They would need to be public.  Also, I still don't see where you import Ball in the chain class such that it can use it.

  • Can I run 32 bit version of Oracle 10g grid  on Linux x86-64?

    Since Oracle did not release 64 bit version of Oracle 10g grid for Linux X86-64. Can I run 32 bit version of Oracle 10g grid on Linux x86-64? If so did anyone tried this? and also any known issues?

    All I had to do was use the 32bit version of "/usr/bin/gcc" and "/usr/bin/g++" to run the installation
    That is:
    bin]# cp -p /usr/bin/gcc /usr/bin/gcc_old
    bin]# mv /usr/bin/gcc /usr/bin/gcc323
    mv: overwrite `/usr/bin/gcc323'? y
    bin]# ln -s /usr/bin/gcc296 /usr/bin/gcc
    bin]# cp -p /usr/bin/g++ /usr/bin/g++_old
    bin]# mv /usr/bin/g++ /usr/bin/g++323
    mv: overwrite `/usr/bin/g++323'? y
    bin]# ln -s /usr/bin/g++296 /usr/bin/g++
    AFTER INSTALLATION REMEMBER TO
    move back the 64bit files to their former state.
    bin]#rm /usr/bin/g++
    bin]#rm /usr/bin/gcc
    bin]#mv /usr/bin/gcc_old /usr/bin/gcc
    bin]#mv /usr/bin/g++_old /usr/bin/g++                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can I run 32-bit kernel on OS X Yosemite?

    Can I run 32-bit kernel on OS X Yosemite?

    Not sure if you are still having an issue, but I've encountered similar problems with more recent OS'. I am NOT AN EXPERT HERE so I want to make that clear. I may not be 100% correct in my understanding.
    To my understanding, OS X Lion was the last OS that you can run 32-bit kernels on, but most people seem to prefer Snow Leopard for this task due to better legacy support and how 10.6.8 Snow Leopard is an extremely reliable OS. For Mountain Lion and later, you more or less run the compatibility mode that is the same context as you can do from Windows 8.1. I've had limited success here. I have a copy of OS X Snow Leopard so I can run at 32-bit installed on my hard drive and run OLD apps that do not like Yosemite. As I am running it through VMWare Fusion 7, I can't tell you if you can run Snow Leopard in 32 bit mode via a secondary install or not (I think it depends on your hardware and if your hardware shipped with Mountain Lion or later, then this is NOT possible even if booting through a 32 bit-capable OS...I COULD BE WRONG!)
    One other option is if you have an old copy of Windows XP or something, you can do a 32 bit install through a virtual machine and update the firmware through the VM (obviously you would need drivers to allow it to recognize USB or Firewire or etc. devices to update the FW of a hardware component, which Parallels and Fusion are both capable of and do very well...but they are paid (free trial for both). Oracle has a VM which is free, but I do not know much about its functionality.) There are even certain software apps made to run older programs on OS X reliably...I do not know if they would be of benefit in your case or not.
    Obviously that is a little bit of a pain but truth be told, I find that both Apple and Microsoft OS' have limitations when attempting to run older programs on newer OS. Old programs don't tend to run well on Yosemite or Windows 8.1, despite the fact that the operating systems themselves are reasonably reliable. I don't blame them as it seems this is just something that is very difficult to do reliably in a world where new technology is favored over legacy support. So that is why I have a 32-bit capable version of both OS X and Windows in addition to the current respective 8.1 and 10.10.2.
    If this is a one-time deal and you do not think you will need to do the same thing down the road, you could skip all of the above and just borrow a computer from a friend with a 32-bit OS, or even go to a Fedex Kinkos or something and see if they will let you run the application from there. A lot of Mac users do have Parallels or Fusion on their Mac so someone local might be able to help you out. As Snow Leopard was the last OS to incorporate certain hardware support, it is still used extensively (some estimate it is used on around 1/4 of all Macs).

  • This program has been blocked for your protection/ An Administrator has blocked you from running this program/ Return code: 1625

    This program has been blocked for your protection/ An Administrator has blocked you from running this program/ Return code: 1625
    If you get a message saying, “Publisher: Not trusted,” the printing functionality you are attempting to use may become blocked while downloading, installing or attempting to run.
    You may also see messages such as:
    MSIExec installation error (Return code:1625)
    The recommended software listed below could not be installed
    “Do you want to allow the following the program from an unknown publisher to make changes to this program”
    “This program has been blocked for your protection”
    “Blocked”
    “Not trusted”
    The Windows User Account Control message may look like this.
    You may get this message when installing, uninstalling, or updating HP software for Windows from the product CD, from software previously downloaded from www.hp.com, or from running HP Smart Install by connecting a printer via USB cable.
    The solution will vary depending on the products that you are using. Here is a helpful document for HP printers that will walk you through what you can do.
    John
    I work on behalf of HP.

    Hey @kat54 ,
    Welcome to the HP Forums!
    I understand you're receiving an error stating "This program has been blocked for your protection."
    You can read about this error here: "Blocked", "User Account Control", "Not trusted", or "Return code: 1625" message in Windows.
    You will find a link for Printers here which directs you to the HP Update Software Utility to resolve the problem. When you install this utility ensure you select version 5.005.002.002 or later.
    Make sure the utility you've downloaded is for your exact product and operating system.
    If this does not resolve the issue please call our technical support at 800-474-6836. If you live outside the US/Canada Region, please click the following link to get the support number for your region: Phone Assist Worldwide.
    Thanks!
    Please click the "Kudos, Thumbs Up" at the bottom of this post if you want to say "Thanks" for helping!
    Please click "Accept as Solution" if you feel my post solved your issue, it will help others find the solution.
    The Great Deku Tree
    I work on behalf of HP.

  • Can I run 32 bit firefox on my Windows 7, 64 bit and how ? Flash player loads slow.

    Can I run 32 bit Firefox on my Windows 7, 64 bit and how do I do that? Flash player loads videos slowly. You tube videos are mostly loading slowly or hanging up. It seems to have happened after the last Firefox update.

    Dibbens wrote:
    According to website I have Flash Player installed but I cannot run a program (BBC iPlayer DeskTop) that requires 64 Bit Flash player Any ideas?
    Does that program require the Flash Player ActiveX Control, or the plugin?  If you only have the ActiveX Control (for Internet Explorer) installed, then you may also need the plugin (for other browsers).  Get it from http://get.adobe.com/flashplayer/otherversions/

  • I developed app in mac 10.6.8 with xcode 3.2.6.how can i run this app in ipad device

    i developed app in mac 10.6.8 with xcode 3.2.6.how can i run this app in ipad device

    actually i planned to get  provisioning profiles from apple by paying 99$ in following website
    https://developer.apple.com/programs/start/ios/ and followed by
    https://developer.apple.com/programs/start/standard/.
    but in last link,following thing were mentioned at bottom -
    Technical Requirements
    You must have an Intel-based Mac running OS X 10.8 Mountain Lion or later to develop and distribute iOS apps and Mac apps.
    but i\m using mac running OS X 10.6.8 snow leopard.
    Doubt:can't i run my app in ipad device?\
    Thank's in advance..

  • Can we run 32 bit application over 64 bit windows server 2012 ?

    Can we run 32 bit application over 64 bit windows server 2012 ?

    Hi,
    Thanks for your question.
    Since the two cases that you posted are the same, I will merge them so that you can get a better assistance. Thanks for your understanding
    and support.
    In addition, according to your question, it depends on the applications. Some applications designed for the 32-bit version of Windows
    will work on the 64-bit version of Windows, but some are not. Before you install the application, you’d better check if it is compatible with 64-bit version of Windows Server 2012.
    Best regards,
    Susie

  • How can i run this query in BI Answers

    Hi,
    pls tell me how can i run this sql statement in BI Answers....???
    select abc_date,abc_asset_desc,sum(nvl(abc_market_val_lcy,0)+nvl(abc_accr_lcy,0)) "total balance" from abc
    group by abc_date,abc_asset_desc;any help would be appriciated.... :-)
    Regards

    Strange question this one.
    normally with Answers you pick the columns you want to report on and the BI server will construct the SQL for you.
    In this example you would need a star with the abc dimension logical table and a logical fact for abc (these can be in the same table), which has a calculated field for 'Total Balance'.
    You then pick the columns you require and Answer and the BI will automatically add the group by.
    Adrian
    Majendi

  • I created an application on a machine with Labview 6.01, can I run this application on another machine that has labview 5?

    In the development center we use Labview 6.01, in the testcenter we use labview 5.
    Additionally, in the development center we use a unix version of Labview and in the testcenter a Windows version.

    You can Save with Option to save VIs as version 5.
    Unless your VIs deal with system files in UNIX or Windows (ie. Registry...)
    then you have to develop your VI specificly on that OS, since UNIX and
    Windows have different ways to deal with system files. Mostly, LabVIEW is OS
    independent. I used to have VIs developed from LabVIEW v.3 on UNIX, I can
    still open these files from LV v.4 on Windows. Now I can still work with
    these VIs on LV 6 on Windows.
    Good luck,
    Nam.
    roybra wrote in message
    news:[email protected]..
    > I created an application on a machine with Labview 6.01, can I run
    > this application on another machine that has labview 5?
    >
    > In the development center we use Labview 6.01, in the testcenter we
    > use l
    abview 5.
    >
    > Additionally, in the development center we use a unix version of
    > Labview and in the testcenter a Windows version.

  • Getting a message that I can't run this app on my PC and to contact the pulisher to get a version that I can run

    getting a message that I can't run this app on my PC and to contact the pulisher to get a version that I can ru

    Which Adobe product?
    Which operating system?

  • How to run 64-bit native code with Java Web Start

    This question has probably been asked many times, but I couldn't find anything in my searches.
    How can I get Java Web Start on a Solaris client (Solaris 10 in this case, with JRE 1.5) to run a java application that includes a 64-bit native code library? The application downloads fine, including the jar file that has the native shared object, but when the native library is loaded by the java application, I get a "wrong ELF class: ELFCLASS64" error.
    I assume that is because Web Start is invoking the 32-bit java VM, which can't load a 64-bit library. I tried configuring Java Web Start to use the 64-bit VM (by setting the path to java to ".../jre/bin/sparcv9/java" in the javaws console) but then I get an error that says "Can't load library: .../jre/lib/sparcv9/libdeploy.so".
    Does Java Web Start support 64-bit native code, and if so, what do I need to do differently?
    Thanks.

    No it can't. On the Sun download page of the JRE it says that 64 Bit systems need to use the 32 Bit JRE to execute Plugins - this might be the same for Web Start apps.

  • How many computers can I run this software on?

    The laptop I am currently using is dying. Can I install this on a new computer?         

    Thanks for your help, but the drop down window you posted is nothing like mine. I am running windows 7, 64 bit. I am calling Adobe support tomorrow. My desktop dies completely and I lost Adobe Pro 9 and CS4 before I could deactivate them. I've read that Adobe will deactivate them for me when this happens. I'll ask about the Elements 10 too when I talk to them.
    My laptop is experiencing the same problems as my desktop was, so I know it is only a matter of time before it's gone too. I have Acrobat pro 10 on it, which I can deactivate. If Adobe deactivates Pro 9 and CS4, they'll go on another desktop, which is my workstation, when I get one . BTW, I tried to take a screen shot of my menu, but Adobe will not allow me to, so I can't show you what I was seeing.
    Again, thanks for everything.

  • I can't run this file

    I tried running this file, but keep on getting this one error message.
    import java.util.*;
    import java.io.*;
    * My first print message for CS 170
    * @author (John Vu)
    * @version (September 11, 2009)
    public class PrintMessage
    // Program-wide input and output streams
    private PrintStream cout = System.out;
    private Scanner cin = new Scanner(System.in);
    * These are the actions my program will perform.
    public void run()
    System.out.println(
    "What is the difference between a ' and a \"?" +
    "Or between a \" and a\"?");
    System.out.println(
    "One is what we see when we're typing our program." +
    "The other is what appears on the \"console\".");
    * The standard Java entry point. DON'T MODIFY.
    * @param args the command-line arguments.
    @SuppressWarnings("null")
    public static void main(String...args)
    PrintMessage app;
    app.run(); (this is line 37)
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
         The local variable app may not have been initialized
         at PrintMessage.main(PrintMessage.java:37)
    can anyone help me?

    You can't use an object until you initialize it. So it's not:
        PrintMessage app;
        app.run(); // (this is line 37)but:
        PrintMessage app = new PrintMessage();
        app.run(); // (this is line 37)Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [cod&#101;] below your pasted code like so:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]Welcome to the sun java forums.
    Edited by: Encephalopathic on Sep 12, 2009 1:02 PM

Maybe you are looking for

  • HT3153 Can the early 2006 MAC mini support a DVI to hdmi adapter for TV monitor support?

    Can the early 2006 MAC Mini support a DVI to HDMI adapter for a TV Monitor?

  • Itunes blank, library wont import

    dear community, i use a PC with Vista. when i upgraded to itunes 8.1 i was unable to record CDs or watch DVDs so at the suggestion of other users, i removed 8.1 and went back to 7.1. however my library could not be opened because it was created with

  • Creation of Multiple Supplier Registration Questionnaires

    We have one generic supplier reqistration for all product categories. We now want additional questionniares for specific product categories with some having multiple questionnaires for one product category. One Product category could have 3-4 quesito

  • Having A REALLY hard time installing itunes on my Window 7 laptop

    Alrite so this is like day 2 for trying to download itunes on my window 7 laptop! I click run and yes to everything and then when the whole itunes+quicktime pops up to download its gets all the way to the point where it says "Publishing product infor

  • Unread messages in the INBOX

    I migrated data from NMS4.15 to IMS5.2 ( coppied filesystems) and ran reconstruct -m. All mailboxes are accessible but for some reason all the messages in the Inbox folders are marked as unread. Does anyone know what is causing that and how it can be