Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners code and specification u asked
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shaik Fayaz Ahmed
code and specification u asked
3 Answer(s)      6 years and a month ago
Posted in : Java Beginners



Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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
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
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
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
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
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
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
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
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
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
can u plz help out how to attach file directly & send to a particular mail id
can u plz help out how to attach file directly & send to a particular mail id  i am building a project online LEAVE MANAGEMENT SYSTEM to our coll mini project so if a faculty write all details abt leave & shd send to HOD
required treenodes checkboxes are not clicking if u change the url - Java Server Faces Questions
required treenodes checkboxes are not clicking if u change the url  Hi, Here i have Library.java file. just look at d url : http://localhost...(1001,1007,1002,1005,1008,1002,1009,1010,1008)are getting clicked. But when u again add or remove the album
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
code
code  code for android sample program
code
code    how to write this in java
Code
Code  code for connecting c lang to database
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List... ?? its urgent can u help me
Advertisements
 

 

 

DMCA.com