Give me a hand, pls!

I'm building a app, i can explain briefly about it:
1 - i create a gateway, it'll recieve all message from client then process it
2- when gateway recieve a message, it create a thread to process it:
2-1: create a connection to another server( core-Server)
2-2: recieve response message, process it then send it to client
2-3: the problem is when gateway send a message to core-Server, if core-Server doesnt reply in 10seconds, we must close that connection to core-Server and reply to client the error-code
I have try to use Timer to do it, but nothing useful, please give me a solution!

Socket.setSoTimeout()

Similar Messages

  • How to calculate the number of vowels from a txt file. Pls give me a hand!!

    Guys! How do i calculate the number of vowels from a txt file? I have to create a program to count the number of words, sentence, and vowels. So far I had managed to count the number of words. Now I need help on counting sentence and vowels! Pls give me a hand guys!

    I first have to read from the file not the string.I
    know how to read from a file. Now the problem ishow
    to compare a character from a txt file!You fail to understand, that you have read the data
    from the file into a string. Now loop over all
    characters in the string. Forget about the file.
    KajOr forget the scanners just as others have told you. Just read the file character by character using a FileReader.
    Kaj

  • Novice asking qn, pls give a helping hand

    i am trying to develop a distributed system that needs password checking in order to access.
    Hence i need to check user password in my database that resides in my server.
    so when ReMoTe user click "enter" after typing password.. how do i connect to my server database to verify?? is my solution given below the norm?
    suggested solution: pass the userID and password to the server using HttpServletRequest, from there, the server listen for request and process connecting to local DB if a request is detected..
    am i correct... pls give a helping hand...

    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginServlet extends HttpServlet{
         private Connection con;
         private PreparedStatement pstmt;
         private Statement stmt;
         private ResultSet rs;
         private String pass = "";
         private String login="",password="",done="";
         private HttpSession session;
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException{
              login = ""+request.getParameter("login");
              password = ""+request.getParameter("password");
              done = ""+request.getParameter("done");
              session = request.getSession(true);
              PrintWriter out = response.getWriter();
              out.println(login);
                        out.println(password);
              try{
                   Class.forName("org.gjt.mm.mysql.Driver");
              }catch(Exception e){
                   out.println(e.getMessage());
              try{
                   con = DriverManager.getConnection("jdbc:mysql:///senji");
                   if(!(password.equals("")&&login.equals(""))){
                        pstmt = con.prepareStatement("select password from logon where login = ?");
                        pstmt.setString(1,login);
                        rs = pstmt.executeQuery();
                        pass = "";
                        while(rs.next()){
                             pass = rs.getString(1);
                        if(pass.equals(password)){
                             session.setAttribute("login",login);
                             if(done.equals("null")){
                                  done = "";
                                  pass = "";
                                  response.sendRedirect("/ksenji/quiz2/shoponline.jsp");
                             }else{
                                  response.sendRedirect(done.substring(5));
                        else{
                             response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                   else{
                        response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
              }catch(SQLException ex){
                   out.println(ex.getMessage());
    }

  • I am having problems opening images renerated in lightroom5 into cs6. Cs6 bridge does not see the lightroom libarary. If I open lightroom and right clik the image, edit in cs6, 6 opens but the picture doesnot follow. What is going on? Give me a hand.

    I am having problems opening images renerated in lightroom5 into cs6. Cs6 bridge does not see the lightroom libarary. If I open lightroom and right clik the image, edit in cs6, 6 opens but the picture doesnot follow. What is going on? Give me a hand, thanks.

    What edition of LR 5? What edition of ACR does PSCS 6 contain. If they are not parallel (same edition number x in [5 or 8].x ), is LR making a tiff or psd rendition of the image?

  • Hi I,m Wonkeun Kim. Could u give me a hand to solve the problem which now i forget answers of my security questions. How should i do to reset my answers??

    Hi I,m Wonkeun Kim. Could u give me a hand to solve the problem which now i forget answers of my security questions. How should i do to reset my answers??

    Forgotten Security Questions / Answers...
    See Here > Apple ID: Contacting Apple for help with Apple ID account security
              Ask to speak with the Account Security Team...
    Or Email Here  >  Apple  Support  iTunes Store  Contact
    More Info >  Apple ID: All about Apple ID security questions
    Note:
    You can only set up and/or change a Rescue Email Before you forget the questions/answers.

  • Exception when readObj() - please give me a hand!

    I am writing a Client/Server application where Server simply sends object to the client. The first object goes well but when the client side reads the second object, the exception caught was "Type code out of range, is -84". Can anybody kindly give me a hand? Thanks very much in advance!
    Result on Client:
    C:\thesisTest>java TestCli
    @Line 1: Get ready!!!
    Type code out of range, is -84
    receive error.
    Source for Server :
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import sendNode;
    public class TestSer {
         static sendNode sendNodeObj = new sendNode();
    static String inputLine;
         public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = null;
    try {
    serverSocket = new ServerSocket(4444);
    } catch (IOException e) {
    System.err.println("Could not listen on port: 4444.");
    System.exit(1);
    Socket clientSocket = null;
    try {
    clientSocket = serverSocket.accept();
    } catch (IOException e) {
    System.err.println("Accept failed.");
    System.exit(1);
    OutputStream o = clientSocket.getOutputStream();
    ObjectOutput out=new ObjectOutputStream(o);
    BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        clientSocket.getInputStream()));
    sendNodeObj.sendMsg="@Line 1: Get ready!!!";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    out=new ObjectOutputStream(o);
    sendNodeObj.sendMsg="@Line 2: Please input Start";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    while (!inputLine.equalsIgnoreCase("Start")) {
         sendNodeObj.sendMsg="@Error, Please input Start";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    out.close();
    in.close();
    clientSocket.close();
    serverSocket.close();
    Source for Client:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.applet.Applet;
    import sendNode;
    public class TestCli extends Applet {
    static sendNode recNodeObj=null;
    public static void main(String[] args) throws IOException {
    BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
    Socket kkSocket = null;
    PrintWriter out = null;
    try {
    kkSocket = new Socket("127.0.0.1", 4444);
    out = new PrintWriter(kkSocket.getOutputStream(), true);
    } catch (UnknownHostException e) {
    System.err.println("Don't know about host.");
    System.exit(1);
    } catch (IOException e) {
    System.err.println("Couldn't get I/O for the connection to: taranis.");
    System.exit(1);
    InputStream i= kkSocket.getInputStream();
    ObjectInput in= new ObjectInputStream(i);
    try {
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
    if (recNodeObj.sendMsg.equalsIgnoreCase("@Line 2: Please input Start")) {
    out.println("Start");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    System.out.println("receive error.");
    System.exit(1);
    out.close();
    in.close();
    stdIn.close();
    kkSocket.close();

    You are not being consistent in the way you use ObjectOutputStream and ObjectInputStream.
    For every new ObjectOutputStream you create you need a corresponding new ObjectInputStream, because ObjectOutputStream writes a header that ObjectInputStream reads.
    In general, you probably don't want to use multiple OutputOutputStream objects on a given underlying socket, because it is ineffecient in the way class names etc are encoded.
    Sylvia.

  • In my Iphone 4 the home button is not working, give me the solution pls........

    in my Iphone 4 the home button is not working, give me the solution pls...........

    Restart the iPhone otherwise it might be a hardware problem. Go to an Apple Store.

  • Can anyone give me a hand with Quicktime?

    I used to be able to watch movies and video on fullscreen mode or the Present Movie mode with noproblems at all. Now, everytime I try to set it up nothing happens, it's like the window goes into ghost mode... any ideas will be very welcome.

    Is it possible that anyone doesn´t want to give me a hand?

  • In my iphone6, voice over got switched on and screen got locked. Phone is not responding for slide but only responding for double tap. Phone is not accepting my passcode as I double tap in passcode screen. Single tap just gives a voice over. pls help

    In my iphone6, voice over got switched on and screen got locked. Phone is not responding for slide but only responding for double tap. Phone is not accepting my passcode as I double tap in passcode screen. Single tap just gives a voice over. pls help me to unlock the screen and switch off voice over

    Thanks a lot Sted !! It worked

  • Pls give me a hand and have a look, i dont know whats wrong with it

    it said-
    Order.java:45: connot reslove symbol
    symbol: class View
    location: class Order
    View my View = View();
    import java.io.*;
    import java.util.*;
    public class Order {
         private int SupplierID;
         private String SupplierName;
         private int HouseNumber;
         private String Address1;
         private String Town;
         private String County;
         private String PostCode;
         private int ShrubID;
         private String ShrubName;
         private String Genus;
         private String Species;
         private String Variety;
         private int Quantity;
         private double Price;
         public Order (int SuID, String SuN, int Hno, String Add, String T, String C, String PC,int ShID, String ShN, String G, String S, String V, int Q, double P){
              SupplierID = SuID;
              SupplierName = SuN;
              HouseNumber = Hno;
              Address1 = Add;
              Town = T;
              County = C;
              PostCode = PC;
              ShrubID = ShID;
              ShrubName = ShN;
              Genus = G;
              Species = S;
              Variety = V;
              Quantity = Q;
              Price = P;
              public boolean View() throws IOException{
                   View myView  = new View();
                   myView.getSupplierID(SupplierID);
                   myView.getSupplierName(SupplierName);
                   myView.getHouseNumber(HouseNumber);
                   myView.getAddress1(Address1);
                   myView.getTown(Town);
                   myView.getCounty(County);
                   myView.getPostCode(PostCode);
                   myView.getShrubID(ShrubID);
                   myView.getShrubName(ShrubName);
                   myView.getGenus(Genus);
                   myView.getSpecies(Species);
                   myView.getVariety(Variety);
                   myView.getQuantity(Quantity);
                   myView.getPrice(Price);
              boolean returnCode; returnCode = false;
                   try{
                        File outputFile = new File ("Order.html");
                        FileWriter writeBuffer = new FileWriter(outputFile);
                        BufferedWriter bufferedWriter = new BufferedWriter(writeBuffer);
                        writeBuffer.write("<html> \n \r");
                        writeBuffer.write("<head> \n \r");
                        writeBuffer.write("<title>Order</title>\n\r");
                        writeBuffer.write("</head> \n \r");
                        writeBuffer.write("<body> \n \r");
                        writeBuffer.write("<div align='right'> \n \r");
                        writeBuffer.write("<FONT> face = 'Times New Roman'<P>address1</P></FONT> \n \r");
                        writeBuffer.write("</div align='right'> \n \r");
                        writeBuffer.write("<div align='left'> \n \r");
                        writeBuffer.write("<FONT>  face = 'Times New Roman'<P>"+ Address1 +"</P></FONT> \n \r");
                        writeBuffer.write("</div align='left'> \n \r");
                        writeBuffer.write("<P>Order description</P> \n \r");
                        writeBuffer.write("<p>" + ShrubName + ", " + Genus + ", " + Species + ", " + Variety + "</p>\n \r");
                        writeBuffer.write("<p>Total Price =" + (Quantity*Price) + "</p>");
                        writeBuffer.write("</body> \n \r");
                        writeBuffer.write("</html>");
                        bufferedWriter.close();
                        returnCode = true;
                        catch (IOException e) {
              return returnCode;
    }

    Hi,
    It means that there is no class with the name View. You either need to write it, or import it.
    /Kaj

  • Everything runs als Root, can someone give me a hand for the system rights?

    yeah I screwed up big times because of this neat unknow_user "Feature" in Leopard.
    First i installed a os 10.4 app under leopard which let the disk utility slow down and the finder crashes if i change the user rights, and then i changed globally the group and user of everything in the application folder and my documents folder with pathfinder for looking if i can solve the problem that way.
    -But now everything runs as Root and even the hd itself has a owner root and as group admin.
    i don't get the difference between system, root, admin, wheel, username for the owner and group. I googled but found nothing clear about this.
    And i also wonder what i should do about the group and the meaning of root, system, admin, wheel, username as a group for a single user system. Where should i give a read, read&write and execute permission for example?
    at the moment everything seems to run mostly root and every program runs on root and i think this is the worst think that can happen and causes some trouble for the programs.
    Can someone give me a short hand and for example tell me if i should set the hd owner to my username and the group to system or admin or whatever and this also for the application and documents/film and other stuff on my user folder?
    that would be great
    I think i have to reinstall leopard, but as long as this unknow_user problem still resist and no patch is available, i see the same thing happen again and again for me, so a little help would be great
    here the ls -l -a from the system and user directory
    drwxrwxr-t 26 root admin 1496 Nov 1 23:41 .
    drwxrwxr-t 26 root admin 1496 Nov 1 23:41 ..
    -rw-rw-r--@ 1 root admin 15364 Nov 5 22:42 .DS_Store
    drwxrwxr-x@ 3 root admin 102 Oct 30 18:40 .Spotlight-V100
    drwxrwxr-x@ 2 root admin 68 Aug 2 12:29 .Trashes
    -rw-r--r-- 1 root admin 0 Oct 30 17:09 .com.apple.timemachine.supported
    drwx------ 2 root admin 952 Nov 5 22:09 .fseventsd
    -rw-rw-r--@ 1 root admin 262144 Oct 10 11:42 .hotfiles.btree
    drwxr-xr-x@ 2 root wheel 68 Aug 2 12:30 .vol
    drwxrwxrwx+ 400 adrian admin 13872 Nov 5 22:00 Applications
    drwxr-xr-x 2 root admin 102 Nov 1 23:01 Data
    -rw-r--r--@ 1 root admin 10240 Oct 25 05:19 Desktop DB
    -rw-r--r--@ 1 root admin 37442 Oct 25 01:39 Desktop DF
    drwxrwxr-x@ 13 root admin 544 Oct 30 19:46 Developer
    drwxr-xr-x 5 adrian adrian 204 Sep 12 14:25 InputManagers
    -rw-r--r--@ 1 adrian adrian 1568128 Nov 1 23:45 Installer Log File
    drwxrwxr-t+ 60 root admin 2108 Nov 1 22:06 Library
    drwxr-xr-x@ 2 root wheel 68 Aug 2 10:08 Network
    drwxr-xr-x 3 root wheel 136 Oct 30 18:01 System
    drwxrwxrwx@ 3 root admin 102 Aug 2 17:21 TheVolumeSettingsFolder
    drwxr-xr-x 5 root admin 238 Nov 2 00:03 Users
    drwxrwxrwt@ 4 root admin 170 Nov 5 20:21 Volumes
    -rw-r--r-- 1 adrian admin 0 Oct 29 22:51 az.log
    drwxr-xr-x@ 2 root wheel 1360 Oct 30 17:57 bin
    drwxrwxr-t@ 2 root admin 68 Jan 13 2006 cores
    dr-xr-xr-x 2 root wheel 512 Nov 2 04:11 dev
    lrwxr-xr-x@ 1 root admin 11 Oct 30 17:57 etc -> private/etc
    dr-xr-xr-x 2 root wheel 1 Nov 2 04:11 home
    lrwxr-xr-x 1 root 502 11 Nov 1 22:40 mach -> mach_kernel
    -r--r--r--@ 1 root admin 615748 Oct 29 18:23 mach.sym
    -rw-r--r--@ 1 root wheel 10243756 Oct 10 06:38 mach_kernel
    -rw-r--r--@ 1 root wheel 10696809 Oct 10 06:38 mach_kernel.ctfsys
    dr-xr-xr-x 3 root wheel 2 Nov 2 04:11 net
    drwxr-xr-x@ 3 root admin 102 Sep 14 17:40 opt
    drwxr-xr-x@ 6 root wheel 204 Oct 29 18:23 private
    drwxr-xr-x@ 2 root wheel 2244 Oct 30 18:01 sbin
    drwxr-xr-x 11 root admin 374 Jun 9 2006 sw
    lrwxr-xr-x@ 1 root admin 11 Oct 30 17:57 tmp -> private/tmp
    drwxr-xr-x@ 13 root wheel 510 Oct 30 19:52 usr
    lrwxr-xr-x@ 1 root admin 11 Oct 30 17:57 var -> private/var
    and for the my user folder:
    drwxr-xr-x+ 22 adrian adrian 1156 Nov 3 02:30 .
    drwxr-xr-x 5 root admin 238 Nov 2 00:03 ..
    -rw-r--r-- 1 adrian adrian 3 Sep 13 22:41 .CFUserTextEncoding
    -rw-r--r--@ 1 adrian adrian 15364 Nov 5 21:50 .DS_Store
    -rw-r--r-- 1 adrian adrian 11 Oct 16 17:17 .PortAuthority2.4.rc
    drwx------ 2 adrian adrian 68 Nov 5 20:58 .Trash
    -rw-r--r-- 1 adrian adrian 0 Aug 16 04:37 .Xauthority
    -rw-r--r-- 1 adrian adrian 2552 Nov 5 22:43 .bash_history
    drwxr-xr-x 4 adrian adrian 136 Aug 17 21:11 .config
    drwxr-xr-x 8 adrian adrian 306 Aug 6 02:22 .dvdcss
    drwxr-xr-x 2 adrian adrian 578 Oct 21 19:32 .fontconfig
    -rw-r--r-- 1 adrian adrian 489724 Aug 30 17:49 .fonts.cache-1
    drwxr-xr-x 2 adrian adrian 68 Sep 14 17:40 .macports
    -rw-r--r-- 1 adrian adrian 1643 Aug 30 19:01 .mime.types
    -rw-r--r-- 1 adrian adrian 47 Oct 12 22:45 .parallels_settings
    -rw-r--r-- 1 adrian adrian 194 Sep 28 02:52 .profile
    drwxr-xr-x 3 adrian adrian 102 Sep 23 00:48 .stella
    drwxr-xr-x 2 adrian adrian 68 Aug 16 20:09 .wapi
    -rw-r--r-- 1 adrian adrian 467 Nov 5 04:21 .webaom
    -rw-r--r-- 1 adrian adrian 570 Aug 16 04:37 .xinitrc
    drwxr-xr-x 3 adrian adrian 170 Aug 5 08:10 Applications
    drwxr-xr-x+ 23 adrian adrian 1190 Nov 5 20:21 Desktop
    drwxrwxrwx+ 35 adrian adrian 2210 Nov 5 22:08 Documents
    drwxr-xr-x+ 14 adrian adrian 3332 Nov 5 20:02 Downloads
    drwxr-xr-x+ 48 adrian adrian 1836 Oct 30 19:11 Library
    drwxr-xr-x+ 9 adrian adrian 748 Nov 2 23:49 Movies
    drwxr-xr-x+ 8 adrian adrian 510 Sep 29 05:44 Music
    drwxr-xr-x 2 root adrian 68 Nov 3 02:30 New Folder
    drwxr-xr-x+ 6 adrian adrian 748 Oct 18 23:26 Pictures
    drwxrwxrwx+ 3 adrian adrian 238 Nov 4 20:34 Public
    drwxr-xr-x+ 3 adrian adrian 204 Aug 14 21:29 Sites
    drwxr-xr-x 3 adrian adrian 340 Oct 31 05:55 CompilationUnix
    -rw-r--r-- 1 adrian adrian 129 Oct 6 16:48 license.jai

    lllaass wrote:
    lizdance40, did you read the original post? The poster's problem is that when he connects the iPod to his computer the iPod does not appear in iTunes. He does not say he has a wifi problem with his iPod.
    lizdance40 wrote:
    You need to do an update on your router's firmware, or get a higher speed router..
    Or replace the router and or modem.  High demand can burn out a router in 2 years.  Typical life is about 4-5 at most.
    The new iPod is more advanced and if your router is slow or inconsistant signal your iPod will stop trying to connect to save your battery.
    of course he dose have a wifi problwm. read the last line of the original post

  • Please Give Me Your Hands

    Here is my codes, I try to save the "drawing" Panel graphics into a jpg, and I can compile it, however, when I run it, system tell me" NullPointerException"!!!
    I'm out of ideas, Please help, Thank you So much!!!
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.imageio.*;
    import com.sun.image.codec.jpeg.*;
    import java.io.*;
    import java.awt.geom.*;
    public class test3 extends JFrame
         public test3()
              super("test");
              setSize(800, 600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              drawingArea drawing = new drawingArea();
              Container c = getContentPane();
              c.add(drawing, BorderLayout.CENTER);
              int paneWidth = drawing.getWidth();
              int paneHeight = drawing.getHeight();
              BufferedImage buffer = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB);
              buffer = (BufferedImage)drawing.createImage(paneWidth, paneHeight);
              Graphics graphic = buffer.getGraphics();
              if(graphic.getClipBounds()!=null)
                   graphic.setClip(0, 0, paneWidth, paneHeight);
              drawing.paint(graphic);
              try
                   File file = new File("test.jpg");
                   FileOutputStream out = new FileOutputStream(file);
                   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                   JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buffer);
              encoder.setJPEGEncodeParam(param);
              param.setQuality(1.0f,false);
                   encoder.encode(buffer);
                   out.flush();
                   out.close();
              catch(IOException ioe)
                   System.out.println(ioe.toString() + "something wrong");
              catch(RasterFormatException rfe)
                   System.out.println(rfe.toString() + "rfe");
              setVisible(true);
         class drawingArea extends JPanel
              public void paintComponent(Graphics g)
                   Graphics2D g2D = (Graphics2D)g;
                   Rectangle2D.Float rect = new Rectangle2D.Float(50F, 50F, 20F, 20F);
                   g2D.draw(rect);
         public static void main(String args[])
              test3 t = new test3();
    }

    1 - the graphics context of a Component is null until the Component is realized, ie, until you call pack or setVisible on its top-level Container
    2 - you can make up a BufferedImage and save it without using a Component to show it
    3 - using a 'png' extension seems to give better results and a smaller file size than 'jpg'
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class ImageTest
        ImageTestPanel imagePanel;
        ImageTestUtility utility;
        BufferedImage image;
        public ImageTest()
            createImage();
            imagePanel = new ImageTestPanel();
            utility = new ImageTestUtility();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(getUIPanel(), "North");
            f.getContentPane().add(imagePanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            System.out.println("imagePanel graphics context before visible = " +
                                imagePanel.getGraphics());
            f.setVisible(true);
            System.out.println("imagePanel graphics context after realized = " +
                                imagePanel.getGraphics());
        private void createImage()
            int w = 200;
            int h = 200;
            image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.white);
            g2.fillRect(0, 0, w, h);
            g2.setPaint(Color.blue);
            g2.draw(new Rectangle2D.Double(w/16, h/16, w*7/8, h*7/8));
            int dia = Math.min(w, h)/4;
            g2.setPaint(Color.red);
            g2.draw(new Ellipse2D.Double(w/2 - dia/2, h/2 - dia/2, dia, dia));
            g2.setPaint(Color.green.darker());
            g2.draw(new Line2D.Double(w/16, h*15/16, w*15/16, h/16));
            g2.dispose();
        private JPanel getUIPanel()
            final JButton
                saveComponent = new JButton("save component"),
                saveImage = new JButton("save image");
            ActionListener l = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    JButton button = (JButton)e.getSource();
                    if(button == saveComponent)
                        utility.saveComponent(imagePanel);
                    if(button == saveImage)
                        utility.saveToFile(image);
            saveComponent.addActionListener(l);
            saveImage.addActionListener(l);
            JPanel panel = new JPanel();
            panel.add(saveComponent);
            panel.add(saveImage);
            return panel;
        public static void main(String[] args)
           new ImageTest();
    class ImageTestPanel extends JPanel
        public ImageTestPanel() { }
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.red);
            g2.draw(new Rectangle2D.Float(50, 50, 20, 20));
    class ImageTestUtility
        public BufferedImage loadImage(String fileName)
            BufferedImage image = null;
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
            return image;
        public void saveComponent(Component c)
            int w = c.getWidth();
            int h = c.getHeight();
            BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            c.paint(g2);
            g2.dispose();
            saveToFile(bi);
        public void saveToFile(BufferedImage image)
            try
                ImageIO.write(image, "jpg", new File("imageTest.jpg"));
            catch(IOException ioe)
                System.err.println("write: " + ioe.getMessage());
    }

  • Give  me a hand! one problem in J2EE SDK.

    hello,everyone
    I met a message but I don't know what can i do,pls help!
    "Exception in thread "main" java.lang.noclassdeffounderror:trademo"
    trademo.java is my programe in test.
    what is mean this message?
    what can i do?

    http://access1.sun.com/FAQSets/newtojavatechfaq.html#1
    /Stephane

  • Who knows Chinese. give me  a hand Thanks!

    Hello there
    Thank you
    Last mounth my boyfriend buy a mac book air for me from China
    But the OS is 10.7
    I wanna  a mountaint lion
    But the China support give me a Chinese email
    I just cannot understand
    can you help me to trans the imformation
    Thanks
    亲爱的 Apple 客户:
    感谢您参与 OS X Mountain Lion Up-To-Date 计划。下面附带的文件中的内容码可让您从 Mac App Store 下载并安装 OS X Mountain Lion。您将收到单独的电子邮件,其中含有用以解锁附带文件的密码。内容码可立即通过 Mac App Store 兑换,且不会过期。
    请按照这些步骤进行操作来兑换 OS X Mountain Lion 副本:
    打开 Mac App Store 应用程序。
    从 Mac App Store 的“快速链接”部分中选择“兑换”。
    输入您的内容码。
    如果有疑问,不知道如何从 Mac App Store 兑换或安装软件,请访问 www.apple.com/cn/support/mac/app-store/。
    若要兑换内容码,您需要最新版本的 Mac App Store 应用程序、Apple ID 和互联网访问(可能需要付费)。可以在 appleid.apple.com/cn 上创建 Apple ID。
    请注意,内容码不可转售;若要兑换,用户年龄必须达到您所在国家或地区的 Mac App Store 条款与条件所指定的最小年龄。内容码若遗失或被盗,Apple 概不负责。可在 www.apple.com/legal/itunes/ww/ 上查阅 Mac App Store 的服务条款。
    感谢您选择 Apple!
    © 2012 Apple Inc. 保留一切权利。Apple、苹果、Apple 标志、Mac 和 OS X 是 Apple Inc. 在美国及其他国家和地区注册的商标。App Store 是 Apple Inc. 的服务标记。CH034-6487-A。

    really?
    Here is the output I get:
    Dear Apple Customer:
    Thank you for your participation in OS X Mountain Lion Up-To-Date program. The contents of the file included with the following code allows you to download and install OS X Mountain Lion from the Mac App Store. You will receive a separate e-mail containing the password used to unlock the accompanying documents. Content code can be immediately convertible through the Mac App Store, and will not expire.
    Please follow these steps to redeem a copy of OS X Mountain Lion:
    Open Mac App Store application.
    Select the "Conversion" from the "Quick Links" section on the Mac App Store.
    Enter the code of your content.
    If in doubt, do not know how to exchange or install software from the Mac App Store, visit www.apple.com/cn/support/mac/app-store/.
    To exchange content code, you need the latest version of the Mac App Store application, Apple ID and Internet access (fees may apply). Created appleid.apple.com / cn Apple ID.
    Please note that the content code can not be resold; To redeem, the user's age must meet the minimum age specified in the Mac App Store terms and conditions in your country or region. Content code is lost or stolen, Apple takes no responsibility. Are available in www.apple.com/legal/itunes/ww/ on the Mac App Store Terms of Service.
    Thank you for choosing the Apple!
    © 2012 Apple Inc. All rights reserved. Apple, Apple, Apple logo, Mac OS X, Apple Inc. Registered trademarks in the United States and other countries and regions. App Store is a service mark of Apple Inc. CH034-6487-A.

  • How ask indesign to give back the hand ?

    Since we work with InDesign CS5.5, when we do a book, all the stages a little long (add documents, package, synchronization ...) are keeping busy indesign
    It was the same with CS4 but we could use other applications in the same time.
    Indesign was switching in the background while indesign was working and we could work on excel, word, acrobat, etc.
    Now Indesign keeps control: we can open another program but the actions are impossible, because indesign keep the hand. (we have new computers, 8 Go Ram andt 1To disc)
    I tried to create several desktops but indesign keeps the hand on every desk!
    How can we take control of the computer?
    Thank you for your help

    Thanks.
    I found the application frame, although he did not have the same name in French... And I realised that I have been working with since the beginning.
    I will test the new user account but I can't do it by myself.
    I hope we will finish by find something  
    To be continued ...

Maybe you are looking for