Synchronized( this ) vs synchronized( SomeClass.class )

I have seen synchronized bits of code declared in the following ways:
1)
synchronized( this )
  //some stuff
}2)
synchronized( SomeClass.class )
  //some stuff
}Could anyone explain the diference or tell me where to read about it.
Thanks In Adavance!

Mattbunch is correct, but I will also check later.
If you want to lock on a class level you lock on a
static method.The term "locking on a class level" doesn't really mean anything.
In the original post, the only difference betweensynchronized this() {} and synchronized(SomeClass.class) {} is which object they use as a lock. That's the only difference. There's no difference in what gets protected or how.
Static methods are at the class scope, global, and
they are locked for the class, not just the
instance, understand?Again, that statement--the concept of being "locked for the class vs. for the instance"--doesn't really have any meaning. If you declare a static method synchronized, it obtains one particular object's lock (that of the Class object corresponding to that method's class), and if you declare an instance method syncrhonized, it obtains a different object's lock--that of the intstance whose method you're calling. That's the only difference--which lock you obtain. There's no inherent difference in the scope of the "protection".
Also remember that locking on the static methods does
not prevent another thread from entering a non static
public method.You don't "lock on" a method. But assuming you mean "declaring a static method synchronized," it doesn't stop another thread from entering any other unsynchronized method, static or not, public or not, and it doesn't stop a thread from entering any synchronized instance method. It only stops threads from entering blocks or methods syncrhronized on the Class object for that class.

Similar Messages

  • What Malicious Software Removal Tool can I use for my Mac Book? I need do to do this for a College class.

    What Malicious Software Removal Tool can I use for my Mac Book? I need do to do this for a College class.

    You may find this User Tip on Viruses, Trojan Detection and Removal, as well as general Internet Security and Privacy, useful: The User Tip seeks to offer guidance on the main security threats and how to avoid them.
    https://discussions.apple.com/docs/DOC-2435

  • "this." inside as2 classes

    Can any one say, if i should use "this." inside my classes to
    refer class
    variables and methods? What is its advantage and
    disadvantage? Does this
    help compiler/flash player in any way.
    please provide some useful links which explain more.
    Cheers,
    Sajeev

    when it's appropriate you can use "this". so, if you've just
    created a movieclip and you're defining a mouse handler for it,
    it's appropriate to use this within the handler's scope.
    but to refer to a class member, i use a private variable in
    the constructor function to use throughout the class so i don't
    have scope issues outside the constructor function.

  • Can any one change this Applet into a class that extends Jpanel.....

    Hi,
    I need this applet as a class that extends JPanel, I will be very very thankful to you if any one kindly change this Applet code into a class that extends JApplet.
    I will be very thankful to you if some one can reserve few minutes & do this favor early.
    Thanks a lot for any help.
         My Pong Code
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    public class Class1 extends Applet implements Runnable
    {     private final int APPLET_WIDTH = 900;
         private final int APPLET_HEIGHT = 600;
         private int px = 15;
         private final int py = 560;
         private final int ph = 10;
         private final int pw = 75;
         private int old_px = px;
         private int bx = 450;
         private int by = 15;
         private final int bh = 20;
         private final int bw = 20;
         private int move_x = 2;
         private int move_y = 2;
         private boolean done = false;
         Thread t;
         private final int delay = 25;
         public void init()
         {     setBackground(Color.black);
              setSize(APPLET_WIDTH, APPLET_HEIGHT);
              requestFocus();
              addKeyListener(new DirectionKeyListener());
             (t = new Thread(this)).start();
         public void run()      {
        try      {     while((t == Thread.currentThread()) && (done == false))           {     
                   if ((bx < 15) || (bx > APPLET_WIDTH-30))                     move_x = -move_x;                                if ((by < 15) ||                    ((by > APPLET_HEIGHT-60)&&                     ((px<=bx)&&(bx<=px+pw))))
                        move_y = -move_y;
                   if (by > APPLET_HEIGHT)
                        done = true;
                                   bx = bx + move_x;
                   by = by + move_y;                                                repaint();
                   t.sleep(delay);
         catch(Exception e)      {}
         }//end run
         /*public void move_paddle(int amount)
              old_px = px;
              //if (amount > 0)
                //if (px <= APPLET_WIDTH-15)
                   px = px + amount;
              //else if (amount < 0)
               // if (px >= 15)
                   px = px + amount;
         public void paint(Graphics page)
              //     page.setColor(Color.black);
              //     page.drawRect(old_px, py, pw, ph);
                   page.setColor(Color.blue);
                   page.drawRect(px, py, pw, ph);
                   page.setColor(Color.white);
                   page.drawOval(bx, by, bw, bh);
                   if ((done == true) && (by > APPLET_HEIGHT))
                        page.drawString("LOSER!!!", APPLET_WIDTH/2, APPLET_HEIGHT/2);
                   else if (done == true)
                        page.drawString("Game Over, Man!", APPLET_WIDTH/2-10, APPLET_HEIGHT/2);
         private class DirectionKeyListener implements KeyListener               
              public void keyPressed (KeyEvent event)
                   switch (event.getKeyCode())
                   case KeyEvent.VK_LEFT:
                        old_px = px;
                        if (px >=15)
                             px -=10;
                        break;
                   case KeyEvent.VK_RIGHT:
                        old_px = px;
                        if (px+pw <= APPLET_WIDTH-15)
                             px += 10;
                        break;
                   case KeyEvent.VK_Q:
                        done = true;
                   default:
                   }  //end switch
                   repaint();
              }//end keyPressed
              public void keyTyped (KeyEvent event)
              public void keyReleased (KeyEvent event)
         }  //end class 
    }

    thank you sir for your advice.
    Its not like that I without any attempt, just past code here & asked for its conversion. I spent about 5 hours on it, can say spoil whole day but to no avail. You then just guide me, give some hint so that I do it. I will most probably wanted to do it by myself but asked for help when was just disappointed.
    I try to put all init() in default constructor of identical copy of this applet that extends JPanel. Problem.....ball tend to fell but pad not moving. Also out out was not getting ant color input. That was like my best effort.....other tried that I found by search like just do nothing only extend panel OR frame in spite of applet, start applet from within main of another class.... these are few I remember what I tried.
    I will be very very thankful to you if you can help/guide me how can I do it. Behavior of the Applet is like a normal PONG game with on pad controlled by arrow keys, & one ball colliding with walls of boundary & falling down.
    Thanks a lot again for your attention & time.

  • Since installing Firefox 4, I keep getting this message "TypeError: Components.classes[cid] is undefined" when a window should open. Also print and print preview don't work properly anymore.

    Since installing the newest version of Firefox, This message "TypeError: Components.classes[cid] is undefined" appears in a box when a new window should open. Also, what you see in print print preview is not what prints.

    This type of error is usually caused by an add-on you are using that is not compatible. It could be anything from an antivirus link scanner like AVG Safe Search add-on, or McAfee Site Advisor add-on, or something similar. To confirm what add-on is causing this use the procedure in this link:
    https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Try Disabling the last add-on that was installed prior to upgrading to version 5.0
    Check and tell if its working.

  • Synchronized API classes

    Hello.
    Does anybody know a reference to which parts of the Java 2 API are synchronized and which aren't ?
    I already know that
    1) Collection classes are not synchronized (but can be mapped to synchronized versions via Collections )
    2) Swing classes are not synchronized (but SwingUtilities provides syncdhonized methods)
    Anyone who can complete this list ?
    Thanks and regards,
    Stephan Gloor
    Switzerland

    I doubt there's a single document which says which
    classes, and which methods of classes, are
    synchronised, I agree. Synchronization is an implemenation issue, not part of the API. Though I expect you could write this yourself fairly easily using Doclets..? I've never used them myself, but from what I've read in the past, I think this is the sort of thing they could be useful for.
    but the API documentation for a given
    class will certainly say if the methods are
    synchronised. Not true. API documentation should not say whether methods are synchronized. Sun's JavaDoc tool used to generate text that did this, but is was classified as a bug and has been removed (not sure when it was, but I think it might have been removed with JDK 1.3).
    In fact, Sun's JavaDoc documentation states "It does not describe implementation details, such as whether the method is native or synchronized." I haven't been able to find the bug in the bug database, but I know there is one.
    I guess its a case of wading through the
    API documentation.API documentation should indicate the level of thread safety that a class conforms to, and may do so (as per Collections.synchronizedXxx) by telling you what objects to synchronize on where external synchronization is necessary. You should not usually need any further info.

  • Question about synchronized singleton classes

    Hi,
    I have a singleton class, with only 1 method (which is static), I want access to that method to be synchronized, but someone suggested that I make my getInstance() method synchronized as well.
    Is this neccessary, or is it overkill?
    thanks!

    Example:
    static Instance getInstance() {
    if (instance == null) {
    instance = new Instance();
    return instance;
    }Two threads call it simultaneously:
    1. if (instance == null) { // evaluates true
    2. if (instance == null) { // evaluates true
    1. instance = new Instance(); // first instance
    2. instance = new Instance(); // second instance,
    deleting the reference to the first instance
    1. return instance; // which is not the originally
    created one but the second instance
    2. return instance;There's actually a worse consequence.
    1) T1 sees null
    2) T1 sets instance to point to where the object will live
    4) T2 sees non-null
    3) T2 returns, with a pointer to what's supposed to be an object, but isn't yet inited.
    4) T1 eventually inits the instance
    This can happen even if you use the "double check locking" pattern of synchronization.
    At least under the old memory model. I think the new JMM in effect in 5.0 (and possibly later 1.4) versions fixes it. I don't know if the fact that it can happen in absence of sync/DCL is an error or not, so I'm not sure if that's addressed in the new JMM, or if it's only the synced case that was a bug. (That is, it might be okay that it happens without syncing.)

  • Nested synchronized method class

    Hi. I have a situation where there are two synchronized methods: Method A and Method B. In the course of execution, Method A calls Method B. Method B calls wait(). This causes a classical deadlock as wait() releases the monitor for Method B, but no for Method A. What are my options to work around this problem?
    Thanks in Advance,
    Paul0al

    A and B cannot synchronize on the same object because if A acquires the monitor, then B cannot obtain the same monitor without A releasing the monitor. My problem is that A and B are synchronized on different objects. A calls B and B calls wait(). A deadlock occurs because A's monitor is not released.
    Thanks,
    Paul0al

  • Synchronizing a class

    Hello Forum... I have some servlets that instantiate a class to send SMS messages with a cell phone attached to the serial port. What do you suggest to synchronize use of the class so phone messages are queued? Should I make the SMS class static so it cannot be instantiated and synchronize on that?
    thanks
    /j-p.

    i also create a servlet for send sms but my problem is it can't make connection to my gsm device. could you tell me what problem with my source code. I get output show "error connection". When i run without servlet it worked and message has successful send. thanks
    import java.io.*;
    import java.lang.*;
    import org.jsmsengine.*;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.comm.*;
    public class WebSMSServlet extends HttpServlet
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws IOException, ServletException
              int status;
              String Mesej=request.getParameter("Mesejform");
              String NoPhone=request.getParameter("NoPhoneform");
              String Subjek=request.getParameter("Subjekform");
              String Daripada=request.getParameter("Daripadaform");
              String SMS;
              String NoPhone2;
              SMS=("Drpd:"+Daripada+"."+Subjek+"."+Mesej);
              NoPhone2=("+6"+NoPhone);
    if ((NoPhone == null) || (Daripada == null) ||
    (Subjek == null) || (Mesej == null)) {
    RequestDispatcher rd =
    getServletContext().getRequestDispatcher("http://localhost/form.html");
    rd.forward(request, response);
    return;
    PrintWriter writer = response.getWriter();
    response.setContentType("text/html");
    writer.println("<html>");
    writer.println("<head>");
    writer.println("<title>FTSM-SMS</title>");
    writer.println("</head>");
    writer.println("<body bgcolor=\"white\">");
         writer.println(SMS);
         writer.println("<p>");
         writer.println("Kepada:");
         writer.println(NoPhone2);
         writer.println("<p>");
         CService srv = new CService("com4", 9600); //connecting to mobile phone
         try
         srv.initialize();
         srv.setCacheDir(".\\");
    status = srv.connect();
                   if (status == CService.ERR_OK)
              srv.setOperationMode(CService.MODE_PDU);
                   srv.setSmscNumber("");
         SMS=("Drpd:"+Daripada+"."+Subjek+"."+Mesej);
         NoPhone2=("+6"+NoPhone);
    COutgoingMessage msg = new COutgoingMessage(NoPhone2, SMS);
    msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
    if (srv.sendMessage(msg) == CService.ERR_OK)
    writer.println("Message have been send ");
    writer.println(NoPhone);
    else
    writer.println("your mesaage failed to delivery to: ");
    writer.println(NoPhone);
              srv.disconnect();
                   else
    writer.println("Error connection :");
    writer.println(status);
              catch (Exception e)
                   e.printStackTrace();
    writer.println("<br><br>");
    writer.println("</body>");
    writer.println("</html>");

  • How to restructure this code into separate classes?

    I have C# code that initializes a force feedback joystick and plays an effect file(vibrates the joystick). I have turn the console application into library
    code to make a dll so that I can use it in LabVIEW. 
    Right now all the code is written under one class, so went I put the dll in LabVIEW I can only select that one class. labVIEW guy told me that I need to
    restructure my C# code into separate classes. Each class that I want to access from LabVIEW needs to marked as public. Then I can instantiate that class in LabVIEW using a constructor, and call methods and set properties of that class using invoke nodes and
    property nodes.
    How can I do this correctly? I tried changing some of them into classes but doesn't work. Can you guys take a look at the code to see if it is even possible
    to break the code into separate classes? Also, if it is possible can you guide me, suggest some reading/video, etc.
    Thank you
    using System;
    using System.Drawing;
    using System.Collections;
    using System.Windows.Forms;
    using Microsoft.DirectX.DirectInput;
    namespace JoystickProject
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    private System.Windows.Forms.Label label1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    private Device device = null;
    private bool running = true;
    private ArrayList effectList = new ArrayList();
    private string joyState = "";
    public bool InitializeInput()
    // Create our joystick device
    foreach(DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl,
    EnumDevicesFlags.AttachedOnly | EnumDevicesFlags.ForceFeeback))
    // Pick the first attached joystick we see
    device = new Device(di.InstanceGuid);
    break;
    if (device == null) // We couldn't find a joystick
    return false;
    device.SetDataFormat(DeviceDataFormat.Joystick);
    device.SetCooperativeLevel(this, CooperativeLevelFlags.Exclusive | CooperativeLevelFlags.Background);
    device.Properties.AxisModeAbsolute = true;
    device.Properties.AutoCenter = false;
    device.Acquire();
    // Enumerate any axes
    foreach(DeviceObjectInstance doi in device.Objects)
    if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
    // We found an axis, set the range to a max of 10,000
    device.Properties.SetRange(ParameterHow.ById,
    doi.ObjectId, new InputRange(-5000, 5000));
    // Load our feedback file
    EffectList effects = null;
    effects = device.GetEffects(@"C:\MyEffectFile.ffe",
    FileEffectsFlags.ModifyIfNeeded);
    foreach(FileEffect fe in effects)
    EffectObject myEffect = new EffectObject(fe.EffectGuid, fe.EffectStruct,
    device);
    myEffect.Download();
    effectList.Add(myEffect);
    while(running)
    UpdateInputState();
    Application.DoEvents();
    return true;
    public void PlayEffects()
    // See if our effects are playing.
    foreach(EffectObject myEffect in effectList)
    //if (button0pressed == true)
    //MessageBox.Show("Button Pressed.");
    // myEffect.Start(1, EffectStartFlags.NoDownload);
    if (!myEffect.EffectStatus.Playing)
    // If not, play them
    myEffect.Start(1, EffectStartFlags.NoDownload);
    //button0pressed = true;
    protected override void OnClosed(EventArgs e)
    running = false;
    private void UpdateInputState()
    PlayEffects();
    // Check the joystick state
    JoystickState state = device.CurrentJoystickState;
    device.Poll();
    joyState = "Using JoystickState: \r\n";
    joyState += device.Properties.ProductName;
    joyState += "\n";
    joyState += device.ForceFeedbackState;
    joyState += "\n";
    joyState += state.ToString();
    byte[] buttons = state.GetButtons();
    for(int i = 0; i < buttons.Length; i++)
    joyState += string.Format("Button {0} {1}\r\n", i, buttons[i] != 0 ? "Pressed" : "Not Pressed");
    label1.Text = joyState;
    //if(buttons[0] != 0)
    //button0pressed = true;
    public Form1()
    // Required for Windows Form Designer support
    InitializeComponent();
    // TODO: Add any constructor code after InitializeComponent call
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    if( disposing )
    if (components != null)
    components.Dispose();
    base.Dispose( disposing );
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    public void InitializeComponent()
    this.label1 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // label1
    this.label1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
    this.label1.Location = new System.Drawing.Point(8, 8);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(272, 488);
    this.label1.TabIndex = 0;
    // Form1
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.BackColor = System.Drawing.SystemColors.ControlText;
    this.ClientSize = new System.Drawing.Size(288, 502);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.label1});
    this.Name = "Form1";
    this.Text = "Joystick Stuff";
    this.ResumeLayout(false);
    #endregion
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    using (Form1 frm = new Form1())
    frm.Show();
    if (!frm.InitializeInput())
    MessageBox.Show("Couldn't find a joystick.");

    Imho he means the following.
    Your class has performs two tasks:
    Controlling the joystick.
    Managing the joystick with a form.
    So I would recommend, that you separate the WinForm from the joystick code. E.g.
    namespace JoystickCtlLib
    public class JoystickControl
    private Device device = null;
    private bool running = true;
    private ArrayList effectList = new ArrayList();
    private string joyState = "";
    public string State { get { return this.joyState; } }
    public bool InitializeInput() { return true; }
    public void PlayEffects() { }
    private void UpdateInputState() { }
    So that your joystick class does not reference or uses any winform or button.
    btw, there is a thing which is more important than that: Your polling the device in the main thread of your application. This will block your main application. Imho this should be a job for a thread like background worker.

  • How do I recover the actual type of the this object in a class hierarchy?

    Hi,
    This is code snippet from Angelica Langer's FAQ:
    abstract class Node <N extends Node<N>>  {
         private final List<N> children = new ArrayList<N>();
       private final N parent;
       protected Node(N parent) {
            this.parent = parent;
            if(parent!=null)
               parent.children.add(this);  // error: incompatible types
       public N getParent() {
         return parent;
       public List<N> getChildren() {
         return children;
    }There are 3 different approaches available in the FAQ to solve this problem.
    My question is:
    If I write:
    parent.children.add((N)this);  // cast added here
    ...as described at the end of this topic in the FAQ, am I safe here (despite
    the compilers warning) ? In my opinion, although I understand that
    compiler needs to issue a warning, it is actually 100% safe .... or is it not ?
    Or let's ask more precise question: can it throw a ClassCastException at
    runtime ever ? If so, can you give any example ?
    Thanks,
    Adrian

    You might not get a CCE within the Node class (because of erasure), but maybe on accessing the children, e.g., in a loop, where the cast will be created by the compiler, based on the type information you give to it.
    class A extends Node<A> {
      public A(A parent) { super(parent); }
    class B extends Node<A> {
      public B(A parent) { super(parent); } // This will add a B as child to an A!
    A a = ...;
    B b = new B(a);
    for (A anA : b.getChildren()) { ... }Creating an instance of B will add it as child to a List<A>, which will most probably result in a CCE when looping on the list like shown above, which is type-safe from the compiler point of view.

  • I allredy install iTunes I become this message: hKEY_LOCAL_MACHINE32\Software\Classes\.m4b\Open\WithList\iTunes.exec. must have privileges

    I can´t install iTunes , I become the message hKEY_LOCAL_MACHINE32\Software\Classes\.m4b\Open\WithList\iTunes.exec.you must have privilleges, Can somebody explain me  how I must become such a privillege?

    This has to do with permissions in the registry. Take a look at the post by Primus Bodacious in this link
    http://discussions.apple.com/thread.jspa?threadID=688433&tstart=30
    Also these on permissions
    http://support.microsoft.com/?kbid=308421
    http://support.microsoft.com/kb/308419/

  • This card game for class

    i had this original program that i got to work then my teacher asked me to add in those gui stuff and now i dont know what to do
    ok here are my methods:
    // Demonstrating the JTextField class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
    private JTextField input,input2;
    private JLabel label1,label2;
    private JButton endButton;
    // set up GUI
    public Test()
    super( "yo" );
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // construct textfield with default sizing
    label1 = new JLabel("How many players?");
         input = new JTextField( 10 );
         input.setToolTipText ( "How many players?" );
    container.add( label1 );
    container.add( input );
    // construct textfield with default text
    label2 = new JLabel("How many cards?");
    input2 = new JTextField( 10 );
    input2.setToolTipText( "How many cards?" );
    container.add( label2 );
    container.add( input2 );
         endButton = new JButton( "Deal" );
         ButtonHandler ButtonAction = new ButtonHandler();
         endButton.addActionListener(ButtonAction);
    container.add( endButton );
    setSize( 275, 170 );
    setVisible( true );
    public static void main( String args[] )
    Test application = new Test();
    application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    private class ButtonHandler implements ActionListener
         public void actionPerformed( ActionEvent event )
              int players=0;
              int tofinish=1;
              String player;
              player = input.getText();
              String cards;
              cards = input2.getText();
              Cards card;
              card = new Cards();
              for (;tofinish<=players;tofinish++)
              card.clearitout();
              card.deal();
    } // end class TextFieldTest
    and then here is my test program
    import javax.swing.*;
    public class TestCards{
         public static void main (String[] args) {
         Cards card;
         card = new Cards();
         card.clearitout();
         card.deal();

    here is the code for the original game that worked without the gui
    import javax.swing.*;
    import java.util.Random;
    public class Cards extends Object{
    String cards[] = new String[52];
    String cardnames[] = {"ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king"};
    String suitnames[] = {"spades","hearts","clubs","diamonds"};
    Random rand = new Random();
    //constructor
    public Cards()
    public void clearitout () {
    for(int index=1;index<=cards.length-1;index++)
    cards[index]=("unused");
    public void deal () {
    int cardsdelt=0;
    int index;
    while(cardsdelt<=5)
    index=(rand.nextInt(52));
    if (cards[index]=="unused")
    cards[index]="used";
    System.out.println(cardnames[identifycard(index)] + " of " + suitnames[identifysuit(index)]);
    cardsdelt++;
    System.out.println("");
    private int identifysuit(int index) {
    int suit=0;
    suit = index/13;
    return suit;
    private int identifycard (int index) {
    int card=0;
    card = index%13;
    return card;

  • When I am on internet explorer and a pop up come up on firefox,this is a college class and it won't work on firefox

    I am starting college classes online and one of my classes has to be on internet explorer only.When the pop up for my class come up it on firefox instead on internet explorer.It has to open on internet explorer only
    == this happen ever time the pop up come up

    A solution could be the Firefox [https://addons.mozilla.org/en-US/firefox/addon/92382/ IE Tab 2] extension - this opens certain pages in an Internet Explorer window within Firefox or open links in IE directly from Firefox. If you know (part of) the domain for those online college classes, you can set IE Tab 2 to automatically open those using the IE engine instead of Firefox - this is what I do for my own netbanking solution out of necessity.

  • Why cant i send this to the cost class on button click?

    when the calculate button is clicked i want the program to check and see if a certain checkbox is selected and if set a variable in another class.
    in the code below. why does it not recognize that i am trying to send the variable from the checkbox to the set method in the cost class?
    public class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent ae){
                   if(ae.getSource()==jbnCalculate)
                        String f = jtfFirst.getText();
                        String l = jtfLast.getText();
                        String id = jtfID.getText();
                        if(cbCream.isSelected()){
                             app1.setCream(ch);
    package final_Kelm;
    public class GMCCost extends GMCEmployee {
         double white;
         double wheat ;
         double creamCheese;
         double butter;
         double peachJelly;
         double blueberryJam;
         //double regularCoffee = 1.25;
         //double mocha = 2.75;
         //double latte = 3.05;
         double coffee;
         double total, subTotal;
         double TAX_RATE = 0.0825;
         public GMCCost()
              total = 0.0;
              subTotal = 0.0;
         public void setCoffee(double c)
              if(c==1)
                   coffee = 1.25;
              else if(c==2)
                   coffee = 2.75;
              else if(c==3)
                   coffee = 3.05;
              else
                   coffee = 0.0;
         public double getCoffee()
              return coffee;
         public void setCream(double ch)
              ch = 0.5;
              ch = creamCheese;
         public double getCream()
              return creamCheese;
         }i am having the same trouble with the coffee. i cannot add it to the output by "Coffee Price: " + app1.getCoffee() + . . . . .

    why is this considered wrong or bad . . .
    public class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent ae){
                   if(ae.getSource()==jbnCalculate)
                        double butter, peach, blueberry, white, wheat;
                        double creamCheese, subTotal, total;
                        String f = jtfFirst.getText();
                        String l = jtfLast.getText();
                        String id = jtfID.getText();
                        double TAX_RATE = 0.0825;
                        if(cbCream.isSelected()){
                             creamCheese = 0.5;
                        else{
                             creamCheese = 0.0;
                        if(cbButter.isSelected()){
                             butter = 0.25;
                        else {
                             butter = 0.0;
                        if(cbPeach.isSelected()) {
                             peach = 0.75;
                        else {
                             peach = 0.0;
                        if(cbBlueberry.isSelected()) {
                             blueberry = 0.75;
                        else {
                             blueberry = 0.0;
                        if(jrbWhite.isSelected()) {
                             white = 1.25;
                        else{
                             white = 0.0;
                        if(jrbWheat.isSelected()) {
                             wheat = 1.50;
                        else {
                             wheat = 0.0;
                        double coffee = jcbCoffee.getSelectedIndex();
                        if(coffee==0) {
                             coffee = 0.0;
                        else if(coffee==1) {
                             coffee = 1.25;
                        else if(coffee==2) {
                             coffee = 2.75;
                        else {
                             coffee = 3.05;
                        subTotal = white + wheat + creamCheese + butter + peach + blueberry + coffee;
                        total = subTotal + (subTotal * TAX_RATE);
                        jtaOutput.setText("");
                        output = output+ "Employee Information: " +"\nStaff ID: " + id + "\nStaff First Name: " + f + "\nStaff Last Name: " + l +
                        "\nInvoice: " + "\nSubtotal: " + subTotal + "\nTotal: " + total;
                   jtaOutput.append(output);
                   }as compared to the code i first posted . . . . . this code works . . . the gui works . . . and im assuming this class of code can run all by itself and does have or need anything to do with the other 3 classes are in this program (see previous thread).
    this program works but all the code is in the button handler class . . . i do not need to send anything anywhere, i do not need to use set get methods . . . so why would this code be frowned upon?

Maybe you are looking for

  • Safari crashing ALL the time

    Hello, I get the feeling that a lot of people are having this issue at the moment but I'm clueless about fixing it. Basically everytime I open Safari right now it crashes after a few seconds. Anybody know what to do? Or what the problem is. Have past

  • Can send pictures to every contact except for one contact ?

    I checked the persons phone and there mms is on and my mms is working so what's the problem???

  • New Classic iPod will not restore and can't eject from iTunes.

    Hi everybody. I just bought a new 160 GB Classic a week ago and promptly attached it to my Windows based laptop and installed the newest firmware. I can add shows and songs to it with no problems, but if I do, I can NOT then eject the iPod from iTune

  • Could you help out a comp-sci student from Germany?

    Dear database experts, my name is Anna and I'm a comp-sci student from Germany, currently in the process of writing my Bachelor's Thesis on the use of mobile devices for monitoring and administrating RDBMS. I'm conducting a survey among database expe

  • Person Assignment tab in network activity

    The person assignment tab in internal network acitvity has a daily view. Shows dates for only 1 day at a time Can anyone please tell me how to change this view from daily to weekly?