Search Results

Search found 59 results on 3 pages for 'tushar chitra'.

Page 3/3 | < Previous Page | 1 2 3 

  • How to display an image(all major formats), selected by JFileChooser in java

    - by Tushar Maroo
    I am developing an image editing app, so want to display an image selected by JFileChooser, so what would be best approach so that it can display all formats jpg, png, gif etc. OpenButton is used for invocation of filechooser. private void OpenActionPerformed(java.awt.event.ActionEvent evt) { int returnVal = fileChosser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChosser.getSelectedFile(); // What to do with the file // I want code for this part try { //code that might create an exception } catch (Exception e1) { e.printStackTrace(); } } }

    Read the article

  • Use of select or multithread for almost 80 or more clients?

    - by Tushar Goel
    I am working on one project in which i need to read from 80 or more clients and then write their o/p into a file continuously and then read these new data for another task. My question is what should i use select or multithreading? Also I tried to use multi threading using read/fgets and write/fputs call but as they are blocking calls and one operation can be performed at one time so it is not feasible. Any idea is much appreciated. update 1: I have tried to implement the same using condition variable. I able to achieve this but it is writing and reading one at a time.When another client tried to write then it cannot able to write unless i quit from the 1st thread. I do not understand this. This should work now. What mistake i am doing? Update 2: Thanks all .. I am able to succeeded to get this model implemented using mutex condition variable. updated Code is as below: **header file******* char *mailbox ; pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER ; pthread_cond_t writer = PTHREAD_COND_INITIALIZER; int main(int argc,char *argv[]) { pthread_t t1 , t2; pthread_attr_t attr; int fd, sock , *newfd; struct sockaddr_in cliaddr; socklen_t clilen; void *read_file(); void *update_file(); //making a server socket if((fd=make_server(atoi(argv[1])))==-1) oops("Unable to make server",1) //detaching threads pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); ///opening thread for reading pthread_create(&t2,&attr,read_file,NULL); while(1) { clilen = sizeof(cliaddr); //accepting request sock=accept(fd,(struct sockaddr *)&cliaddr,&clilen); //error comparison against failire of request and INT if(sock==-1 && errno != EINTR) oops("accept",2) else if ( sock ==-1 && errno == EINTR) oops("Pressed INT",3) newfd = (int *)malloc(sizeof(int)); *newfd = sock; //creating thread per request pthread_create(&t1,&attr,update_file,(void *)newfd); } free(newfd); return 0; } void *read_file(void *m) { pthread_mutex_lock(&lock); while(1) { printf("Waiting for lock.\n"); pthread_cond_wait(&writer,&lock); printf("I am reading here.\n"); printf("%s",mailbox); mailbox = NULL ; pthread_cond_signal(&writer); } } void *update_file(int *m) { int sock = *m; int fs ; int nread; char buffer[BUFSIZ] ; if((fs=open("database.txt",O_RDWR))==-1) oops("Unable to open file",4) while(1) { pthread_mutex_lock(&lock); write(1,"Waiting to get writer lock.\n",29); if(mailbox != NULL) pthread_cond_wait(&writer,&lock); lseek(fs,0,SEEK_END); printf("Reading from socket.\n"); nread=read(sock,buffer,BUFSIZ); printf("Writing in file.\n"); write(fs,buffer,nread); mailbox = buffer ; pthread_cond_signal(&writer); pthread_mutex_unlock(&lock); } close(fs); }

    Read the article

  • how to use facebooks old client library

    - by tushar
    i installed the old library from here:http://pearhub.org/get/facebook-0.1.0.tgz and then extracted the facebook.php file and wrote an index.php file in the same folder with the index .php file just displaying hello "username" but the problem is the index.php when run in browser does not show anythink its blank i have xamp installed on my system please help my index.php code is: require_once 'facebook.php'; $api_key = 'fda501108b3b955bcf0f87a4008bc786'; $secret = '833b35812a3e6b379a5158b2f3f0611f'; $facebook = new Facebook($api_key, $secret); $user_id = $facebook-require_login(); // Greet the currently logged-in user! echo "Hello, !"; ?

    Read the article

  • how to create following Java applicatin? [on hold]

    - by Tushar Bichwe
    Write a JAVA program which performs the following listed operations: A. Create a package named MyEmpPackage which consists of following classes A class named Employee which stores information like the Emp number, first name, middle name, last name, address, designation and salary. The class should also contain appropriate get and set methods. 05 A class named AddEmployeeFrame which displays a frame consisting of appropriate controls to enter the details of a Employee and store these details in the Employee class object. The frame should also have three buttons with the caption as “Add Record” and “Delete Record” and “Exit”. 10 A class named MyCustomListener which should work as a user – defined event listener to handle required events as mentioned in following points. 05 B When the “Add Record” button is clicked, the dialog box should be appeared with asking the user “Do you really want to add record in the file”. If the user selects Yes than the record should be saved in the file. 10 When the “Exit” button is clicked, the frame should be closed. 10 [Note: Use the MyCustomListener class only to handle the appropriate events] C The “Delete Record” button should open a new frame which should take input of delete criteria using a radio button. The radio button should provide facility to delete on basis of first name, middle name or last name. 10 The new frame should also have a text box to input the delete criteria value. 10 The record should be deleted from the file and a message dialog should appear with the message that “Record is successfully Deleted”. 10 [Note: Use the MyCustomListener class only to handle the appropriate events] D Provide proper error messages and perform appropriate exceptions where ever required in all the classes 10

    Read the article

  • deleteRowsAtIndexPaths- crahes application [closed]

    - by Tushar Chutani
    (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { NSLog(@"delet it"); // Delete the row from the data source. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. } } why is this crashing my application

    Read the article

  • Deferred vs Immediate execution in Linq

    - by Jalpesh P. Vadgama
    In this post, We are going to learn about Deferred vs Immediate execution in Linq.  There an interesting variations how Linq operators executes and in this post we are going to learn both Deferred execution and immediate execution. What is Deferred Execution? In the Deferred execution query will be executed and evaluated at the time of query variables usage. Let’s take an example to understand Deferred Execution better. Example: Following is a code for that. using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var customers = new List<Customer>( new[] { new Customer{FirstName = "Jalpesh",LastName = "Vadgama"}, new Customer{FirstName = "Vishal",LastName = "Vadgama"}, new Customer{FirstName = "Tushar",LastName = "Maru"} } ); var newCustomers = customers.Where(c => c.LastName == "Vadgama"); customers.Add(new Customer {FirstName = "Teerth", LastName = "Vadgama"}); foreach (var c in newCustomers) { Console.WriteLine(c.FirstName); } } public class Customer { public string FirstName { get; set; } public string LastName { get; set; } } } } More on my personal blog @www.dotnetjalps.com

    Read the article

< Previous Page | 1 2 3