Question about Operating Systems

1 Answer

Java import java.awt.*; public class Lamp extends java.applet.Applet { public void paint(Graphics g) { // lamp platform g.fillRect(0,250,290,290); //lamp base g.drawLine(125,250,125,160); g.drawLine(175,250,175,160); //lamp shade (top and bottom edges) g.drawArc(85,157,130,50,-65,312); g.drawArc(85,87,130,50,62,58); //lamp shade (sides) g.drawLine(85,177,119,89); g.drawLine(215,177,181,89); //dots on shade g.fillArc(78,120,40,40,63,-174); g.fillOval(120,96,40,40); g.fillArc(173,100,40,40,110,180); } }

Posted by on

1 Answer

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Brigadier General:

    An expert that has over 10,000 points.

  • Master
  • 10,406 Answers

... and your question is ___________________________ ???

Posted on Dec 03, 2009

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

I need a complete workingsource code written in


This is a simple source code for Simple calculator in Java using RMI
//mathServer//
import java.rmi.*;
import java.rmi.Naming.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
import java.util.*;
interface mathInterface extends Remote
{
public int add(int a,int b) throws RemoteException;
public int subt(int a,int b) throws RemoteException;
public int mult(int a,int b) throws RemoteException;
public int div(int a,int b) throws RemoteException;
}
public class mathServer extends UnicastRemoteObject implements
mathInterface
{
public mathServer() throws RemoteException
{
System.out.println("Initializing Server");
}
public int add(int a,int b)
{
return(a+b);
}
public int subt(int a,int b)
{
return(a-b);
}
public int mult(int a,int b)
{
return(a*b);
}
public int div(int a,int b)
{
return(a/b);
}
public static void main(String args[])
{
try
{
mathServer ms=new mathServer();
java.rmi.Naming.rebind("MathServ",ms);
System.out.println("Server Ready");
}
catch(RemoteException RE)
{
System.out.println("Remote Server Error:"+ RE.getMessage());
System.exit(0);
}
catch(MalformedURLException ME)
{
System.out.println("Invalid URL!!");
}
}
}

//mathClient//
import java.rmi.*;
import java.rmi.registry.*;
import java.awt.*;
import java.awt.event.*;
public class mathClient extends Frame implements ActionListener
{
Button B1=new Button("Sum");
Button B2=new Button("Subtract");
Button B3=new Button("Multiply");
Button B4=new Button("Divide");
Label l1=new Label("Number 1");
Label l2=new Label("Number 2");
Label l3=new Label("Result");
TextField t1=new TextField(20);
TextField t2=new TextField(20);
TextField t3=new TextField(20);
public mathClient()
{
super("Calculator");
setLayout(null);
l1.setBounds(20,50,55,25);
add(l1);
l2.setBounds(20,100,55,25);
add(l2);
l3.setBounds(20,150,55,25);
add(l3);
t1.setBounds(150,50,100,25);
add(t1);
t2.setBounds(150,100,100,25);
add(t2);
t3.setBounds(150,150,100,25);
add(t3);
B1.setBounds(20,200,80,25);
add(B1);
B2.setBounds(100,200,80,25);
add(B2);
B3.setBounds(180,200,80,25);
add(B3);
B4.setBounds(260,200,80,25);
add(B4);
B1.addActionListener(this);
B2.addActionListener(this);
B3.addActionListener(this);
B4.addActionListener(this);
addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent AE)
{
if(AE.getSource()==B1)
{
sum();
}
else if(AE.getSource()==B2)
{
subt();
}
else if(AE.getSource()==B3)
{
mult();
}
else if(AE.getSource()==B4)
{
div();
}
}
public void sum()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.add(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void subt()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.subt(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void mult()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.mult(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void div()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.div(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public static void main(String args[])
{
mathClient MC=new mathClient();
MC.setVisible(true);
MC.setSize(600,500);
};
}

Jul 03, 2009 | Microsoft Operating Systems

2 Answers

How can I create .jar file using jarmaker s/w.... (shahsani@ymail.com)


hi

Question How do I create a .JAR file?
Answer Java Archive (JAR) files allow developers to package many classes into a single file. JAR files also use compression, so this can make applets and applications smaller.
Creating a .JAR file is easy. Simple go to the directory your classes are stored in and type :-
jar -cf myfile.jar *.class If your application or applet uses packages, then you'll need to do things a little differently. Suppose your classes were in the package mycode.games.CoolGame - you'd change to the directory above mycode and type the following :- (Remember to use / on UNIX systems)
jar -cf myfile.jar .\mycode\games\CoolGame\*.class Now, if you have an existing JAR file, and want to extract it, you'd type the following
jar -xf myfile.jar Working with JAR files isn't that difficult, especially if you've used the unix 'tar' command before. If you're planning on packaging an applet for Internet Explorer, or an application for Microsoft's jview, you might also want to consider .CAB files.
'); document.write (''); document.write ('showle?'); //-->
hop i was helpfull good luck

Mar 14, 2009 | Microsoft Windows Vista Ultimate Edition

1 Answer

PLATFORM INDIPENDENT if java is platform independent why .net is introduced in the marcket. if jvm is platform dependent how java is platform independent


Java is stored on a computer as a plain-text document. This makes it Platform Independent, but not much use without a compiler to make sense of the code for the computer. This compiler is known as Java Virtual Machine or JVM for short.

JVM is not Platform Independent because it is precompiled.
The problem arises because of the variety of different OS and Processor Architectures on the Market. Each Combination requires a different set of binary commands to make both the processor and the OS understand the code. This is where JVM comes in.
Java can be Platform Independent because it is not complied until compiled by the JVM, which doesn't happen until the Applet is actually used.
As for why .Net was introduced? To permit Microsoft to have a proprietary in-house way of standardising data transferral and interfacing across networks and the Internet.
This talk of processor architecture and compiling might not make sense to you (I don't know your programming experience), but it should make sense to other programmers.

Jan 27, 2009 | Operating Systems

1 Answer

How to play audio clip in java


  • Create an AudioClip object
  • Load .au sound file into AudioClip
  • Play sounds once or loop continuously
  • Stop playback


Here's how the code for these steps looks:
import java.applet.*;
AudioClip ac = getAudioClip(getCodeBase(), soundFile);
ac.play(); //play once
ac.stop(); //stop playing
ac.loop(); //play continuously


It would seem logical to use this same code to play audio clips in a Java application. Unfortunately, if you do that you will get errors from the compiler. Why? Because the AudioClip object and the getAudioClip() method are part of the java.applet package -- and are not part of applications. The good news is we can dive down and make things work ourselves.
The trick to solving this problem is to use some undocumented features that are provided by Sun in its JDK. Taking a peek inside the classes.zip file from the Sun JDK (using any of the various zipfile utilities), we find not only the standard Java packages such as java.applet but also sun.audio. (These are in the directory sun/audio.)
The sun.audio package contains everything we need to be able to play audio clips! Here's the code:
import sun.audio.*; //import the sun.audio package
import java.io.*;
//** add this into your application code as appropriate
// Open an input stream to the audio file.
InputStream in = new FileInputStream(Filename);
// Create an AudioStream object from the input stream.
AudioStream as = new AudioStream(in);
// Use the static class member "player" from class AudioPlayer to play
// clip.
AudioPlayer.player.start(as);
// Similarly, to stop the audio.
AudioPlayer.player.stop(as);


To use a URL as the audio stream source, substitute the following for the input stream and audio stream setup:
AudioStream as = new AudioStream (url.openStream());


Playing the audio stream continuously adds a bit more complexity:
// Create audio stream as discussed previously.
// Create AudioData source.
AudioData data = as.getData();
// Create ContinuousAudioDataStream.
ContinuousAudioDataStream cas = new ContinuousAudioDataStream (data);
// Play audio.
AudioPlayer.player.play (cas);
// Similarly, to stop the audio.
AudioPlayer.player.stop (cas);

Jan 22, 2009 | Operating Systems

3 Answers

What is servlets?


Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. A servlet can almost be thought of as an applet that runs on the server side--without a face. Java servlets make many Web applications possible.  » Read More The reference implementation is included in the Java EE 5 SDK and also in the open-source Java Platform, Enterprise Edition (Java EE) application server, available through the GlassFish project, which you can download from java.net. The reference implementation source code is available from the servlet-sources project on java.net.

Dec 29, 2008 | Microsoft Windows Vista Ultimate Edition

1 Answer

How to create owr own calculater


for all os ? you must use java language! this is the code:

//<applet code="calmayank"height=300 width=300></applet>
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class calmayank extends JApplet
implements ActionListener
{
JTextField t1;

JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,
b11,b12,b13,b14,b15,b16,b17,b18,b19,b20;

GridLayout gl;
JPanel p1,p2,p3;

public void init()
{
gl=new GridLayout(5,4);
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p1.setLayout(gl);
t1=new JTextField(17);
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b10=new JButton("0");
b11=new JButton("+");
b12=new JButton("-");
b13=new JButton("*");
b14=new JButton("/");
b15=new JButton("@");
b16=new JButton("$");
b17=new JButton("%");
b18=new JButton(".");
b19=new JButton("?");
b20=new JButton("=");


p2.add(t1);

p1.add(b1);
p1.add(b2);
p1.add(b3);
p1.add(b4);
p1.add(b5);
p1.add(b6);
p1.add(b7);
p1.add(b8);
p1.add(b9);
p1.add(b10);
p1.add(b11);
p1.add(b12);
p1.add(b13);
p1.add(b14);
p1.add(b15);
p1.add(b16);
p1.add(b17);
p1.add(b18);
p1.add(b19);
p1.add(b20);
p3.add(p2);
p3.add(p1);
getContentPane().add(p3);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
t1.setText("1");
}
else if(e.getSource()==b2)
{
t1.setText("2");
}
else if(e.getSource()==b3)
{
t1.setText("3");
}
else if(e.getSource()==b4)
{
t1.setText("4");
}
else if(e.getSource()==b5)
{
t1.setText("5");
}
else if(e.getSource()==b6)
{
t1.setText("6");
}
else if(e.getSource()==b7)
{
t1.setText("7");
}
else if(e.getSource()==b8)
{
t1.setText("8");
}
else if(e.getSource()==b9)
{
t1.setText("9");
}
}
}

Dec 15, 2008 | Operating Systems

2 Answers

StartActivity fails to launch class called


This example is working try it.

Forwarding.java
----------------------

package com.example.android.apis.graphics;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Forwarding extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.forwarding);
Button goButton = (Button)findViewById(R.id.go);
goButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Intent intent = new Intent();
intent.setClass(Forwarding.this, ForwardTarget.class);
startActivity(intent);
finish();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
});
}
}


ForwardTarget
--------------------

package com.example.android.apis.graphics;
import android.app.Activity;
import android.os.Bundle;
public class ForwardTarget extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

setContentView(R.layout.forward_target);
}
}



AndroidManifest.xml
-----------------------------

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.apis.graphics"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Forwarding"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ForwardTarget"/>
</application>
</manifest>


forwarding.xml
---------------------

<?xml version="1.0" encoding="utf-8" ?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0"
android:paddingBottom="4dip" android:text="forwarding" />
<Button android:id="@+id/go" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="go">
<requestFocus />
</Button>
</LinearLayout>

forward_target.xml
---------------------------

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0"
android:text="forward_target" />
</LinearLayout>


Nov 03, 2008 | Google Android

1 Answer

Atm s\w using java applet


Nice try! Find an upper-class student to give you one-on-one tutoring with your homework assignment.

Aug 29, 2008 | Operating Systems

1 Answer

AWT PROBLEM IN JAVA.


its runing the program.it didnt has any problem

Aug 12, 2008 | Operating Systems

Not finding what you are looking for?
Operating Systems Logo

Related Topics:

192 people viewed this question

Ask a Question

Usually answered in minutes!

Top Operating Systems Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18299 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Prashant  Sharma
Prashant Sharma

Level 3 Expert

1127 Answers

Are you an Operating System Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...