Home Answers Viewqa Java-Beginners code and specification u asked

 
 


Shaik Fayaz Ahmed
code and specification u asked
3 Answer(s)      4 years and 9 months ago
Posted in : Java Beginners

View Answers

August 30, 2008 at 7:53 PM


Hi friend,

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;


public class BrowserDisplay {
private static final String AT_REST = "Ready";

public void run(String location) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Browser display message");
createContents(shell, location);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

//create main window content
// maintain param for location

public void createContents(Shell shell, String location) {
shell.setLayout(new FormLayout());

// Create the composite to hold the buttons and text field
Composite controls = new Composite(shell, SWT.NONE);
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
controls.setLayoutData(data);

// Create the status bar
Label status = new Label(shell, SWT.NONE);
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
status.setLayoutData(data);

// Create the web browser
final Browser browser = new Browser(shell, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(controls);
data.bottom = new FormAttachment(status);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
browser.setLayoutData(data);

// Create the controls and wire them to the browser
controls.setLayout(new GridLayout(7, false));

// Create the back button
Button button = new Button(controls, SWT.PUSH);
button.setText("Back");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.back();
}
});

// Create the forward button
button = new Button(controls, SWT.PUSH);
button.setText("Forward");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.forward();
}
});

// Create the refresh button
button = new Button(controls, SWT.PUSH);
button.setText("Refresh");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.refresh();
}
});

August 30, 2008 at 7:54 PM


// Create the stop button
button = new Button(controls, SWT.PUSH);
button.setText("Stop");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.stop();
}
});

// Create the address entry field and set focus to it
final Text url = new Text(controls, SWT.BORDER);
url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
url.setFocus();

// Create the go button
button = new Button(controls, SWT.PUSH);
button.setText("Go");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.setUrl(url.getText());
}
});

// Create the animated "throbber"
Label throbber = new Label(controls, SWT.NONE);
throbber.setText(AT_REST);

// Allow users to hit enter to go to the typed URL
shell.setDefaultButton(button);

// Add event handlers
browser.addCloseWindowListener(new AdvancedCloseWindowListener());
browser.addLocationListener(new AdvancedLocationListener(url));
browser.addProgressListener(new AdvancedProgressListener(throbber));
browser.addStatusTextListener(new AdvancedStatusTextListener(status));

// Go to the initial URL
if (location != null) {
browser.setUrl(location);
}
}

//This class implements a CloseWindowListener for BrowserDisplay

class AdvancedCloseWindowListener implements CloseWindowListener {

// Called when the parent window should be closed

public void close(WindowEvent event) {
// Close the parent window
((Browser) event.widget).getShell().close();
}
}

//This class implements a LocationListener for BrowserDisplay

class AdvancedLocationListener implements LocationListener {
// The address text box to update
private Text location;

//Constructs an AdvancedLocationListener

public AdvancedLocationListener(Text text) {
// Store the address box for updates
location = text;
}


public void changing(LocationEvent event) {
// Show the location that's loading
location.setText("Loading " + event.location + "...");
}

public void changed(LocationEvent event) {
// Show the loaded location
location.setText(event.location);
}
}

August 30, 2008 at 7:55 PM


class AdvancedProgressListener implements ProgressListener {
// The label on which to report progress
private Label progress;

public AdvancedProgressListener(Label label) {
// Store the label on which to report updates
progress = label;
}

public void changed(ProgressEvent event) {
if (event.total != 0) {
int percent = (int) (event.current / event.total);
progress.setText(percent + "%");
} else {
progress.setText("???");
}
}


public void completed(ProgressEvent event) {
progress.setText(AT_REST);
}
}

class AdvancedStatusTextListener implements StatusTextListener {
// The label on which to report status
private Label status;

public AdvancedStatusTextListener(Label label) {
// Store the label on which to report status
status = label;
}

public void changed(StatusTextEvent event) {
// Report the status
status.setText(event.text);
}
}

public static void main(String[] args) {
new BrowserDisplay().run(args.length == 0 ? null : args[0]);
}
}

----------------------------------

Thanks.









Related Pages:
code and specification u asked - Java Beginners
code and specification u asked  you asked me to send the requirements in detail and the code too.so iam sendind you the specification...(); display.dispose(); } } so i have sent u the code
You asked full source code for search - Development process
You asked full source code for search  Hi, For this code can u give me code for display records when i select any field Search Page var arr = new Array(); arr["Select"] = new Array("-select
quiz asked by my lecturer for array reverse....
quiz asked by my lecturer for array reverse....  consider a 2 dimensional array size m by n.Derive a function that can be used to reverse...; Hello Friend, Try the following code: import java.util.*; public class
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM  can u help me to code in jsp for online voting system
Can u Look to the error plz - Java Beginners
Can u Look to the error plz  this is my code can u modify it plz and give me the result of it when u check it on eclipse or jcreator plz and i will be more thankfull if u do that :) , oh yeh one thing can you draw a flag
can u plz try this program - Java Beginners
can u plz try this program  Write a small record management... operation. Thanks in advance   Hi friend, form code... -------------------------  data insert action code
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
can u help me to get a calendar with color codes on days ???
can u help me to get a calendar with color codes on days ???  hi roseindia, Can you help me to get the code, I need a calendar with color codes.i,e Sunday,Saturday dates display in blue color and my calendar should takes
Java Language Specification
Java Language Specification     ... Language Specification, III Edition is a technical reference for the Java ... the source. This specification avails the accurate, complete, and detailed coverage
Thank U - Java Beginners
Thank U  Thank U very Much Sir,Its Very Very Useful for Me. From SUSHANT
hi its the coding of create layout of chess in applet i hope u like it
its the coding of create layout of chess in applet  /* <Applet code="MyApplet8" width="480" height="480"> </Applet> */ import java.applet.*; import java.awt.*; public class MyApplet8 extends Applet
hibernate code - Hibernate
hibernate code  well deepak,Regarding the inputs u asked for my fisr question, i have downloaded the complete project from the roseindia site for the hibernate.thus i do have the firstExample.java ,contact.hbm public static
quiz asked by my lecturer for array reverse....
quiz asked by my lecturer for array reverse....  consider a 2 dimensional array size m by n.Derive a function that can be used to reverse the elements of the array such that the last element of the array becomes the first
JSP Code - Java Beginners
specification. Thanking u in advance... Regards Vinay Kumar Rai  Hi Friend, Try the following code: function city(){ var cid...; " > For the above code, we have created following
Dear Sir I need to join u
Dear Sir I need to join u  Dear Sir i am santosh Rai from Saudi Arabia please make me understood how to join u and i have one question i want to working with you what is ur process for working with u please send me
how can u reduce the size of textfield?
how can u reduce the size of textfield?  how can u reduce the size of textfield? thanks in advance   import javax.swing.*; public class ReduceTextField extends JFrame { public static void main(String
Map code
as we see in google maps and locate our area of interest. Can u tel me how this can be done????????????/ can u help me to do so. plz provide a code which
Y asked Calendar.js File For Subcombo box - Development process
Y asked Calendar.js File For Subcombo box  calendar.js // Array of max days in month in a year and in a leap year monthMaxDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; monthMaxDaysLeap= [31, 29, 31, 30, 31
Write a program that replaces a, e, i, o, u in Java2
Write a program that replaces a, e, i, o, u in Java2  Write a program that replaces a, e, i, o, u, with the letter z. (i.e. John Smith -> Jzhn Smzth. Also the program reverses the users name (i.e. John Smith -> htimS nhoJ
java code
, MalformedURLException { String type = null; URL u = new URL(fileUrl
java code
, MalformedURLException { String type = null; URL u = new URL(fileUrl
java code - Java Beginners
java code  can u plz provide source code for the mini project of "online course portal for a campus
ServiceImpl Code - Development process
ServiceImpl Code  Can u give me sample code for ServiceImpl and DaoImpl, in j2ee . Thanks Prakash
java code - Java Beginners
java code  can u please post java code for zoom in and zoom out an bufferedImage class image
Hibernate Code - Hibernate Interview Questions
Hibernate Code  This is the question asked in CAPEGEMINI Write a sample code how to persist inner class,interface,final class and how to invoke stored procedure in hibernate? From Surjeet
Pagination example with html code
Pagination example with html code  Hi, could u please provide pagination code with clear cut explanation. Thanks in advance
can u plz explain the http request methods - JSP-Servlet
can u plz explain the http request methods  can u plz explain http request methods? as well in jdbc...how to delete the duplicate records in database?  Hi friend, public interface HttpServletRequest extends
JPA Introduction
will learn the benefits of JPA specification. We will also list down the ORM frameworks that can be used with the JPA specification. The Java Persistence API or JPA for short is Java Specification for persisting the Java Objects
plz help me any one as fast as u can
plz help me any one as fast as u can  A thief Muthhooswamy planned to escape from **** jail. Muthhooswamy is basically a monkey man and he is able to jump across the wall. He practiced to cross a wall and he is able to jump 'X
java code - Java Beginners
java code   Sir Ineed one code for Matrix "Take a 2D array and display all elements in matrix form using only one loop " request this question i asked last one week back but Your people send me one answer
Encryption code - JSP-Servlet
Encryption code  Iam developing a web security application for that reason i need a code of encryption in servlet. Can u please send it to me.Its very urgent Because my project delivery date is very near
java code - Development process
java code  hi, this is sampath, how to acchive the batch processing in java or batch process base java thread. can u send the code and brief explanation. thanks and regards sampath reddy
java code - Java Beginners
java code  i have one requirement , i have long value is 150.000- so i neeed to display(convert) as -150.000 using java language,please if u know the anwer send the code
JSP code for registration form
JSP code for registration form  Haiiii can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using jsp
procedure with code - JavaMail
procedure with code  hi thank u for sending a suitable link. but in that no info about sent item folder creation. i want to place a SENT MAIL... do consider thank u
source code - EJB
Simply u download the complete source code from download link.... then browse the src folder then u found the CalculatorBean.java file http...-of-StatelessBean.shtml", it is written that "The source code for CalculatorBean is in ?net
Jsp Code - Development process
Jsp Code   Hi, Can u give me d jsp code to retrive all d rows from database.I used select * from tablename query. But i want to display inside tag  Hi Friend, Try the following code: Emp IDEmp
jsp logout code
jsp logout code  hello sir, im doing jsp project, i have implemented the session code of jsp. session.invalidate(). but its not working. can u tell me what may be the problem. OR if possible pls send me the proper code
java 3d code - Java3D
java 3d code  can u please send source code, how to clear canvas3d in java 3d. In my project if i click on clear button in awt frame then canvas must be clear, please send code
Html Code - Development process
Html Code  Hi,Can u give me code for Html . headers are Date, Name and Dept . Inside Date column i want to split 2 columns. like In and Out. I have tried colspan tag , but i couldnt get d output. Thank u in advance 
Core java Interview Questions
Here are the Core Java Interview Questions that can be asked to you by interviewers. These frequently asked Core Java Interview Questions will be beneficial... programs Compiler converts java code into byte code. Java application launcher
J2ME code hint - MobileApplications
J2ME code hint  I am required to make a mobile application for encryption and decryption of sms messages using RSA. The last day for submission... no... It should b in J2ME with Netbeans (if needed). Thnk u Sneha
jsp code - JSP-Servlet
jsp code  how to count no of clicks made on a link and save it on database( using jsp)  Hi Friend, Try the following code: 1...; } Click Here 2)value.jsp: Thanks  thank u
code required in servlet
code required in servlet  hello... you provided me the answer with javascript.. i want to check which button is clicked in the servlet.. i have only 1 servlet an in that separate codes for different button clicks.. can u plzzz
code - JSP-Servlet
code  how can i connect SQl database in javascript. and how to execute the query also   i think u can not connect to SQL database in javascript. thanks sandeep
hibernet code - Hibernate
hibernet code  is there any good tutorial site . so that hibernet cal learn easily with eclipse ? if u know that then send the link to my mail ID : keshab78@gmail.com
code problem - Java Beginners
code problem  Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john... be like: Line1= hy Line3= regard, Line2= how r u? Line4= john! My meant
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i... series forecasting the future......... source code in java swings. ? plz help
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i... series forecasting the future......... source code in java swings. ? plz help
Introduction To Enterprise Java Bean(EJB). Developing web component.
J2EE specification defines the structure of a J2EE application. According to the specification J2EE application consists of two... server respectively. J2EE specification also provide a way to package

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.