Question about Computers & Internet

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

Ad

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

Ad

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of.(from cars to computers, handyman, and even drones)
click here to download the app (for users in the US for now) and get all the help you need.
Goodluck!

Posted on Jan 02, 2017

Ad

Add Your Answer

Uploading: 0%

my-video-file.mp4

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

×

Loading...
Loading...

Related Questions:

1 Answer

How to get no. Of pixels from given image through java


try this code

import java.awt.image.PixelGrabber;
import java.awt.Toolkit;
import java.awt.Image;
class getpixel2
{
public static void main(String args[]) throws Exception
{

Image image = Toolkit.getDefaultToolkit().getImage("D:\\one.jpg");

if(image==null)
System.out.println("NO FIle");
PixelGrabber grabber = new PixelGrabber(image, 0, 0, -1, -1, false);

if (grabber.grabPixels())
{
int width = grabber.getWidth();
int height = grabber.getHeight();

if (isGreyscaleImage(grabber))
{
byte[] data = (byte[]) grabber.getPixels();

}
else
{
int[] data = (int[]) grabber.getPixels();
for(int i=0;i<data.length;i++)
{
int r = (data[i] >> 16) & 0xff;
int g = (data[i] >> 8) & 0xff;
int b = (data[i] >> 0) & 0xff;
System.out.println("(R,G,B)=("r","g","b")");
}
}

}
}
public static final boolean isGreyscaleImage(PixelGrabber pg)
{
return pg.getPixels() instanceof byte[];
}
} import java.awt.image.PixelGrabber;
import java.awt.Toolkit;
import java.awt.Image;
class getpixel2
{
public static void main(String args[]) throws Exception
{

Image image = Toolkit.getDefaultToolkit().getImage("D:\\one.jpg");

if(image==null)
System.out.println("NO FIle");
PixelGrabber grabber = new PixelGrabber(image, 0, 0, -1, -1, false);

if (grabber.grabPixels())
{
int width = grabber.getWidth();
int height = grabber.getHeight();

if (isGreyscaleImage(grabber))
{
byte[] data = (byte[]) grabber.getPixels();

}
else
{
int[] data = (int[]) grabber.getPixels();
for(int i=0;i<data.length;i++)
{
int r = (data[i] >> 16) & 0xff;
int g = (data[i] >> 8) & 0xff;
int b = (data[i] >> 0) & 0xff;
System.out.println("(R,G,B)=("r","g","b")");
}
}

}
}
public static final boolean isGreyscaleImage(PixelGrabber pg)
{
return pg.getPixels() instanceof byte[];
}
}

May 15, 2010 | Computers & Internet

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 Computers & Internet

1 Answer

Jnlp code for the java program


From command prompt: You can also launch an application from a command prompt by typing javaws jnlp_url where jnlp_url is a url to the jnlp file of the application. Go to Start > Run > type "cmd". A command prompt window will appear. Type "javaws url_of_jnlp"

May 28, 2009 | Microsoft Office Word 2007 Upgrade Version...

1 Answer

I am developing one java related application.In this there are three places place1,place2 ,place3 ,,if i'm click the place 1 ,in text box the text should come ilike ''place1 text.After that, when i click...


public class MainWindow extends javax.swing.JFrame {

public MainWindow() {
initComponents();
textField1.setText("");
}
.....component initialization function
......

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
textField1.setText("Place1");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
textField1.setText("Place2");
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
textField1.setText("Place3");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainWindow().setVisible(true);
}
});
}

Mar 24, 2009 | Computers & Internet

1 Answer

Table creation via textfields using swings


import java.lang.Object;
import javax.swing.table.DefaultTableModel;


public class tabletest extends javax.swing.JFrame {
String[][] row = null;
String[] title=new String[3];
private int i;


/** Creates new form tabletest */
public tabletest() {
initComponents();
setTitle("table test");
setVisible(true);
System.out.print("NO Database Needed");
title[0]="Name";
title[1]="Desig";
title[2]="id";
}


/*
" In middle of this two source one generated code will be there that will be done by dragging ur fields to ur frame. THIS IS FOR netbeans IDE "
*/

private void b1ActionPerformed(java.awt.event.ActionEvent evt) {
row=new String[4][3];
// TODO add your handling code here:

String s1=t1.getText();
System.out.println(" event 1");
String s2=t2.getText();
System.out.println(" event 2");
int k=Integer.parseInt(t3.getText());
String s3=""+k;
System.out.println(" event 3");
try{
// for(int i=0;i<=2;i++)
row[i][0]=s1;
row[i][1]=s2;
row[i][2]=s3;
i++;

}catch(Exception e){
e.printStackTrace();

}
table.setModel(new DefaultTableModel(row,title));
}

private void b2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

t1.setText("");
t2.setText("");
t3.setText("");

}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tabletest().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton b1;
private javax.swing.JButton b2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel l1;
private javax.swing.JLabel l2;
private javax.swing.JLabel l3;
private javax.swing.JPanel p2;
private javax.swing.JScrollPane scp1;
private javax.swing.JTextField t1;
private javax.swing.JTextField t2;
private javax.swing.JTextField t3;
private javax.swing.JTable table;
// End of variables declaration

}

Mar 13, 2009 | Computers & Internet

1 Answer

About java swing..


Hi, if you have a specific query about java Swing, I can try to help you. Please find a small java code with using swing as example.

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToolBar;
public class ToolbarDemo extends JFrame {
public static final String FontNames[] = { "Serif", "SansSerif", "Courier" };
protected Font fonts[];
protected JMenuItem[] fontMenus;
protected JToolBar toolBar;
public ToolbarDemo() {
super("Toolbars & actions");
setSize(450, 350);
JMenuBar menuBar = createMenuBar();
setJMenuBar(menuBar);
setVisible(true);
}
protected JMenuBar createMenuBar() {
final JMenuBar menuBar = new JMenuBar();
JMenu mFile = new JMenu("File");
ImageIcon iconNew = new ImageIcon("file_new.gif");
Action actionNew = new AbstractAction("New", iconNew) {
public void actionPerformed(ActionEvent e) {
System.out.println("new action");
}
};
JMenuItem item = mFile.add(actionNew);
mFile.add(item);
menuBar.add(mFile);
toolBar = new JToolBar();
JButton saveButton = new JButton("Save");
toolBar.add(saveButton);

getContentPane().add(toolBar, BorderLayout.NORTH);
return menuBar;
}
public static void main(String argv[]) {
new ToolbarDemo();
}
}
Thanks and Regards,
Supa.

Mar 10, 2009 | Microsoft Internet Explorer 7

1 Answer

Unable to View Java Applet


"load: class JFI.class not found."
Based on the console output, it means that it cannot find the java applet class. In other words, the applet is missing on the server side. There is nothing that you can do about it, unless you know the person who created the applet. Good luck :)

Dec 23, 2008 | ArcMedia JavaScript Source Code 3000 Pro...

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

Student library record







Import java.awt;
Import java.applet;
class Book extends Applet
{ String book name="Handbook";
int Book no=50;
int d.o.s=” ”;}
Type ur required body content here.
}
public static void main(String args[])

{
}

/*<applet code=”book” height=500 width=500 ></applet>
this appears to go beyond the scope of troubleshooting



















Sep 27, 2008 | ArcMedia JavaScript Source Code 3000 Pro...

1 Answer

AWT PROBLEM IN JAVA.


its runing the program.it didnt has any problem

Aug 12, 2008 | Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

196 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Doctor PC
Doctor PC

Level 3 Expert

7733 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...