Closing the Frame

If I write an applet, which create a frame, and the menu in the frame. the frame contain a "new" command which to create another frame, and also has a "quit" command in the menu. If I have the "quit" command response like that when it click I want all of the opening frames will be closing then what should I do? I tried to use the System.exit(0); but it will generate the security error message, then what should I do, please give me the advise

have you tried to make the dispose of the frames? The hide method just hides the frame. The dispose method closes the frame.

Similar Messages

  • Closing a frame

    I have created a frame (frame1) with a 'Continue' button for the user to select. When the user selects this button, I want another frame to be called up (public void Continue2Display() ) as well as closing the frame (frame1).
    I added frame1.dispose to the actionlistener but it doesn't work.
    Here is part of my code. Can anyone help me fix it?
    frame1.add(Continue1);
                        Continue1.addActionListener(new ActionListener(){
                             public final void actionPerformed(ActionEvent e){
                                  if(e.getSource()==Continue1){
                                            frame1.dispose();
                                            Continue1Display();
    The error is
    java:151: local variable frame1 is accessed from within inner class; needs to be declared final
                                            frame1.dispose();
    I'm not sure where I am going wrong!!
    Thank-you

    I tried frame1.setVisible(false); but it didn't work.
    I can't understand why this won't work...I keep getting the same error stating frame1 needs to be declared final.
    public static void main(String args[])
              JFrame frame1 = new OScreen();
              public OScreen()
                        // Creating a frame and setting the size along with the background colour
                        Frame frame1 = new Frame("Welcome to my opening screen");
                        frame1.setSize(1025,740);
                        frame1.setBackground(Color.blue);
                        // Displaying and adding an image to a button
                        ImageIcon icon = new ImageIcon("cs_title.gif");          
                        JButton button = new JButton(icon);
                        // Creating labels for text
                        JLabel labelspace1 = new JLabel(" ");
    JLabel labela = new JLabel(" Software Engineering Project ",SwingConstants.LEFT);
                        JLabel labelb = new JLabel(" 2001 / 2002 ",SwingConstants.LEFT);
                        JLabel labelspace2 = new JLabel(" ");
                        JLabel labelc = new JLabel(" Project Title : ",SwingConstants.LEFT);
                        JLabel labeld = new JLabel(" An LU Decomposition Demonstrator ",SwingConstants.LEFT);
    // Creating three panels and setting the color for the background
                   Panel p = new Panel();
                        p.setBackground(Color.blue);
                        Panel q = new Panel();
                        q.setBackground(Color.blue);
                        Panel r = new Panel();
                        r.setBackground(Color.blue);          
         Font writing = new Font("SansSerif",Font.BOLD, 18);
                        Continue1.setForeground(Color.red);
                        Continue1.setFont(writing);
                        // Adding a button to a panel
                        p.add(button);
                        // Adding labels to a panel as well as setting the size and colour
                        q.add(labelspace1);
                        labela.setFont(new Font("Sansserif",Font.BOLD,50));
                        labela.setForeground(Color.green);
                        q.add(labela);
                        labelb.setFont(new Font("Sansserif",Font.BOLD,50));
                        labelb.setForeground(Color.yellow);
                        q.add(labelb);
                        q.add(labelspace2);
                        labelc.setFont(new Font("Sansserif",Font.BOLD,50));
                        labelc.setForeground(Color.green);
                        q.add(labelc);
                        labeld.setFont(new Font("Sansserif",Font.BOLD,50));
                        labeld.setForeground(Color.yellow);
                        q.add(labeld);
                        q.add(labelspace3);
                        labele.setFont(new Font("Sansserif",Font.BOLD,50));
                        labele.setForeground(Color.green);
                        q.add(labele);
                        labelf.setFont(new Font("Sansserif",Font.BOLD,50));
                        labelf.setForeground(Color.yellow);
                        q.add(labelf);
                        frame1.add(Continue1);
                        Continue1.addActionListener(new ActionListener(){
                             public void actionPerformed(ActionEvent e){
                                  if(e.getSource()==Continue1){
                                            frame1.dispose();
                                            Continue1Display();
                        // Adding the three panels to the frame
                        frame1.add("North",p);
                        frame1.add("Center",q);
                        frame1.add("South",r);
                        // Displaying the frame
                        frame1.setVisible(true);
    I would be really grateful if anyone can help me fix this program.
    Alison

  • After opening an email of photos from my mom, the email app won't open. I've rebooted the iPad, I've closed the app and reopeneded it. When I open it I get the basic frame (reply button, delete, etc) but none of my accts show up.

    When I first opened the email, it took forever to open. Then the pics didn't show up as pics, but as a ton of some kind of code. Since then, the app will open with just the frame, no info in the frame, no email accts or anything. Then it closes automatically after a few seconds.
    I've closed the app and reopened it, rebooted the iPad, and gone online and deleted the email itself. But the app still won't open. Help, please!!

    Thank you. I tried the soft reboot again, and the home button has been working fine this whole time. I have tried deleting the email acct from the settings and the mail app still opens only empty frames. I have a screen shot of it, but don't know how to post it here to be able to show what exactly is happening.
    The mail app will open. I can see the area that usually shows the messages themselves. I can also see the area that usually displays all the accts. Both these areas are completely blank. The search bar is showing on the left hand side, and up on the top right, the download button, reply, delete and compose buttons are showing. At the very bottom left the refresh button is showing. The app sits like that for about 20 seconds and then automatically closes. None of the buttons are responsive. I cannot see any of the email accounts I have in the app (3, usually but 2 at the moment since deleting the acct that seemed to have caused this problem).
    I have force-stopped the app, shut down and restarted the iPad, and rebooted the iPad. None of these have helped.

  • How to create a Child Window without closing the parent Window

    Hi All,
    I have a requirement to create a child window without closing the parent window. I have to click an item in the parent window, then one child window should get open. The parent window should not be closed before closing the child window.
    Kindly help me in this.
    Thanks and Regards,
    Myvizhi

    Hi All,
    I found the solution for this. I have created a new page. Then i created an item as link item style in the parent page and i have set the following properties in the Link item:
    Destination URI : OA.jsp?page=/seagate/oracle/apps/seasoa/que/webui/SeaSoaHeaderDetailPG&headerId={@ErrHeaderId}&retainAM=Y&addBreadCrumb=Y&backPage=S
    Target Frame     : _blank
    This is opening the new child window without closing the parent window.
    Thanks and Regards,
    Myvizhi

  • Stop the Frame from being able to be dragged

    Hi all
    I was hoping that someone could tell me how to stop the frame from being dragged
    while a dialog is showing.
    I am using this code to call the dialog.
    When is is visible I can still click and drag the frame behind it.
    I want to set it so you can not drag it until the dialog has be closed.
        public void runStartup() {
            Login dlg = new Login(this, "Login", true);
            Dimension dlgSize = dlg.getPreferredSize();
            Dimension frmSize = getSize();
            Point loc = getLocation();
            dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                            (loc.y + 22));
            dlg.setModal(true);
            dlg.pack();
            dlg.show();
        }

    here is the Login Class
    package build0_0_1.dialogs;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import java.awt.*;
    import com.borland.jbcl.layout.XYLayout;
    import com.borland.jbcl.layout.*;
    import javax.swing.JLabel;
    import javax.swing.JComboBox;
    import javax.swing.JPasswordField;
    import javax.swing.JButton;
    import javax.swing.ImageIcon;
    import build0_0_1.images.image_pics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusAdapter;
    import build0_0_1.mysql.MYSQLDAO;
    import build0_0_1.Command;
    import javax.swing.*;
    import java.sql.SQLException;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Login extends JDialog {
        ImageIcon back;
        MYSQLDAO mysqlDAO;
        Command command;
        JPanel panel1 = new JPanel();
        XYLayout xYLayout1 = new XYLayout();
        JLabel loginLabel = new JLabel();
        JLabel nameLabel = new JLabel();
        JLabel passwordLabel = new JLabel();
        JComboBox jComboBox1 = new JComboBox();
        JPasswordField passwordField = new JPasswordField();
        JButton loginButton = new JButton();
        JButton cancelButton = new JButton();
        JLabel backLabel = new JLabel();
        JLabel logoLabel = new JLabel();
        JComboBox locationComboBox = new JComboBox();
        JLabel locationLabel = new JLabel();
        public Login(Frame frame, String string, boolean _boolean) {
            super(frame, string, _boolean);
            try {
                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                jbInit();
                pack();
            } catch (Exception exception) {
                exception.printStackTrace();
        public Login() {
            this(new Frame(), "Login", false);
        private void jbInit() throws Exception {
            this.setResizable(false);
            this.setUndecorated(true);
            this.setSize(new Dimension(450, 220));
            back = new ImageIcon(image_pics.LOGIN_BACK);
            logoLabel.setIcon(new ImageIcon(image_pics.SMALL_LOGO));
            panel1.setLayout(xYLayout1);
            panel1.setMinimumSize(new Dimension(450, 220));
            panel1.setPreferredSize(new Dimension(450, 220));
            loginLabel.setText("Login");
            nameLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            nameLabel.setText("User Name");
            passwordLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            passwordLabel.setText("Password");
            backLabel.setIcon(back);
            passwordField.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            passwordField.setText("Enter Password");
            passwordField.addFocusListener(new
                                           Login_passwordField_focusAdapter(this));
            loginButton.setBackground(new Color(231, 231, 231));
            loginButton.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            loginButton.setText("Login");
            loginButton.addActionListener(new Login_loginButton_actionAdapter(this));
            cancelButton.setBackground(new Color(231, 231, 231));
            cancelButton.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            cancelButton.setActionCommand("cancelButton");
            cancelButton.setSelected(true);
            cancelButton.setText("Cancel");
            cancelButton.addActionListener(new Login_cancelButton_actionAdapter(this));
            jComboBox1.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            jComboBox1.setEditable(true);
            logoLabel.setBorder(null);
            logoLabel.setHorizontalAlignment(SwingConstants.CENTER);
            logoLabel.setHorizontalTextPosition(SwingConstants.CENTER);
            logoLabel.setText("");
            locationLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            locationLabel.setText("Location");
            locationComboBox.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN,
                    11));
            panel1.add(cancelButton, new XYConstraints(337, 170, -1, -1));
            panel1.add(loginButton, new XYConstraints(245, 170, -1, -1));
            panel1.add(loginLabel, new XYConstraints(208, 21, -1, -1));
            panel1.add(logoLabel, new XYConstraints(21, 20, 57, 54));
            panel1.add(passwordLabel, new XYConstraints(99, 141, -1, -1));
            panel1.add(locationLabel, new XYConstraints(104, 72, -1, -1));
            panel1.add(nameLabel, new XYConstraints(90, 106, -1, -1));
            panel1.add(passwordField, new XYConstraints(185, 138, 219, -1));
            panel1.add(jComboBox1, new XYConstraints(183, 103, 219, -1));
            panel1.add(locationComboBox, new XYConstraints(183, 67, 219, -1));
            panel1.add(backLabel, new XYConstraints(0, 0, 451, 223));
            getContentPane().add(panel1);
            panel1.grabFocus();
         * Exit action performed.
         * @param actionEvent ActionEvent
        public void cancelButton_actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
         * Login to MySQL Server. Using User ame and Password
         * This pass into MYSQLDAO user Name and Password
         * @param actionEvent ActionEvent
        //This pass into MYSQLDAO user Name and Password
        public void loginButton_actionPerformed(ActionEvent actionEvent) {
            String pass = new String(passwordField.getPassword());
            if (!pass.equals("Enter Password")) {
                System.out.println("This the username   " +
                                   (String) jComboBox1.getSelectedItem() + "\n" +
                                   "Password is     " + pass);
                try {
                    mysqlDAO = new MYSQLDAO();
                    mysqlDAO.setUserName((String) jComboBox1.getSelectedItem().
                                         toString().
                                         trim());
                    mysqlDAO.setPassword(new String(passwordField.getPassword()));
                } catch (SQLException ex) {
                    // handle the error
                    System.out.println("SQLException: " + ex.getMessage());
                    System.out.println("SQLState: " + ex.getSQLState());
                    System.out.println("VendorError: " + ex.getErrorCode());
                } catch (Exception ex) {
                    // handle the error
                    System.out.println("Erro no registro do Driver Mysql!!!!");
                hide();
         * Password field select all.
         * Feild is select. The user can just start typing
         * and overright the password feild
         * @param focusGained FocusEvent
        public void passwordField_focusGained(FocusEvent focusEvent) {
            passwordField.selectAll();
    class Login_loginButton_actionAdapter implements ActionListener {
        private Login adaptee;
        Login_loginButton_actionAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void actionPerformed(ActionEvent actionEvent) {
            adaptee.loginButton_actionPerformed(actionEvent);
    class Login_passwordField_focusAdapter extends FocusAdapter {
        private Login adaptee;
        Login_passwordField_focusAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void focusGained(FocusEvent focusEvent) {
            adaptee.passwordField_focusGained(focusEvent);
    class Login_cancelButton_actionAdapter implements ActionListener {
        private Login adaptee;
        Login_cancelButton_actionAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void actionPerformed(ActionEvent actionEvent) {
            adaptee.cancelButton_actionPerformed(actionEvent);
    }

  • How to control a windowClosing Event so that it doesn't hide the frame. URG

    if(logIn_logOut.isEnabled()) // true if user is logged in
    JOptionPane.showMessageDialog(null,"You must Logout before closing the Administrator application","Error",JOptionPane.ERROR_MESSAGE);
    this.setVisible(true);
    this.toFront();
    else
    System.exit(0)
    i want to use the afore mentioned code so that if the user is Still Logged in and tries to close the application an error is displayed and the application is not affected.
    but the problem is that the application hides by default and does not terminate.

    make it so your frame does nothing when the when the 'X' is pressed...you can do it like this...
    yourFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

  • How to handle event when the user closing the browser (Urgent Please)

    Hi,
    How to handle the event when user closes the browser....
    i want to display some alter message when user trying to close the browser...
    Please can any one help me how i have to do this...........
    Thanks.

    Finally got this working. You cannot use the stop() or destroy methods. By the time they are called all database connections are gone and you will get a null pointer exception.
    You will have to use the onBeforeUnload method in the html file that calls the applet and use JavaScript to call the save method in java which saves the document:
    <SCRIPT LANGUAGE="JScript" TYPE="text/javascript">
    function Save()
    //i call the applets doSave() method from here in which i save all
    //changes to the database
    top.Tree.document.TestApplet.doSave();
    //this will invoke the default IE message for closing the window
    //when user clicks on the x in the browser
    message = "Your document has been saved."
    return message;
    window.onbeforeunload=Save;
    </SCRIPT>
    //the applets doSave()
    public void doSave()
    //this frame provides user with the message that document is being
    //saved
    final JFrame frame = new JFrame("Saving");
    JPanel contentPane = new JPanel();
    JLabel label = new JLabel(" Please wait, saving document...");
    frame.getContentPane().add(label,BorderLayout.CENTER);
    frame.setSize(250, 100);
    frame.setLocation(300, 400);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter()
    //the frame is just for user's information, so prevent user from
    //closing it or iconifying it.
    public void windowClosing(WindowEvent e)
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    public void windowIconified(WindowEvent e)
    frame.setState(frame.NORMAL);
    //call my saveDocument() method that saves everything to the database.
    editorModule.saveDocument();
    //System.out.println("finished calling saving document");
    //once the saving is done the frame with the message disappears
    frame.setVisible(false);
    //System.out.println("setting frame to false");
    //I also had an exit button in my applet, that would perform the same task, however now with the above onBeforeUnload method, the exit message would appear twice, so had to modify my exit button action performed, so that if the exitbutton was clicked the onbeforeunload method would get passed a null value and not do anything.
    private void exitButton_actionPerformed()
    if (DEBUG) System.out.println("Calling exit");
    doSave();
    window.eval("this.onbeforeunload=null;");
    window.eval("top.close();");
    //continue from here if user cancels the closing of the window
    window.eval("this.onbeforeunload=doSave;");
    window.eval("top.focus()");
    window.eval("document.TestApplet.requestFocus()");
    homePanel.requestFocus();
    }

  • Closing The JFrame without using setVisible(false)

    I am using a frame for creating table "public class createTable extends JFrame" this class is being used by two panels to display the data . in a last panel where I have put two buttons "ADD" for adding records to a access table and "RETURN" to return back , while closing the "createTable" frame.
    On Clicking the "RETURN" button the code :
    setVisible(false)
    just closes the buttons in the panel whereas the original frame doesnot hides. whereas, if i use an instance of createTable:
    private createTable ctbl;
    and the have it as
    ctbl.setVisible(false);
    exception is thrown . as well as the method :
    void remove(Container con) also throws exception and does not functions smoothly.
    Can anyone please help me>>>>

    The problem is probably that you're calling setVisible on the button, not on the frame.
    If you maintain a reference to the frame then just do something like this:
    frame.setVisible(false);If you don't then you'll need to work out which frame the button belongs to:
    SwingUtilities.getWindowAncestor(this).setVisible(false);Hope this helps.

  • Connection reset when closing the client program.

    when closing the client program I get the error message Connection Reset
    at ServerThread.run(SeverThread.java:244)
    which is the following file
    i've marked the 244: on this file on the left of the file.
    after this I have the client program which is called Client.java
    the error happens when I close the client program and the error is on the serverthread side of the application. Please anyone help out with this one.. Thanks.
    //SererThread.java
    import java.net.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Calendar;
    import javax.swing.*;
    public class ServerThread extends Thread {
    private Socket socket = null;
    String outputStrings = "";
    public ServerThread(Socket socket) {
         super("ServerThread");
         this.socket = socket;
         Calendar c = Calendar.getInstance();
         int hr = c.get(Calendar.HOUR_OF_DAY);
         int hour=hr-1;
         int min = c.get(Calendar.MINUTE);
         int sec = c.get(Calendar.SECOND);
         String timeOfConnect [] = new String[100];
         int conCtr = 0;
    int curState = 0;
         String entries [][] = new String[5][100];
    public String getInput(String theInput) {
    String sentToClient = null;
         Calendar c = Calendar.getInstance();
         int hr = c.get(Calendar.HOUR_OF_DAY);
         int hour=hr-1;
         int min = c.get(Calendar.MINUTE);
         int sec = c.get(Calendar.SECOND);
         int day = c.get(Calendar.DAY_OF_WEEK);
         int month = c.get(Calendar.MONTH);
         int year = c.get(Calendar.YEAR);
         int pm = c.get(Calendar.PM);
         String strHr = Integer.toString(hour);
         String strMin = Integer.toString(min);
         String theInputSeg = "";     
         if(theInput!= null)     
         for(int a=0;a<theInput.length();a++)
              char inputCharArray [] = theInput.toCharArray();
              if(inputCharArray[a]==';')
                   theInputSeg = theInput.substring(0,a);
    if (curState == 0) {
    if(c.PM==1&& hour == 8)
         sentToClient = "yes";
    curState = 1;
    } else if (curState == 1) {
         for(int a=0;a<3;a++)
                   //System.out.println("theInput:" + theInput);
                   //System.out.println("a:" + entries[0][a]);
                   //System.out.println("a:" + entries[1][a]);               
                   //if()
                   if(theInputSeg.equalsIgnoreCase("CUSCarissa_Calton25242526")||theInputSeg.equalsIgnoreCase("CUSSan_Htat27242526")
                        ||theInputSeg.equalsIgnoreCase("CUSSadam_Husien20909990"))
                   //if(theInput.equalsIgnoreCase(entries[0][a])||theInput.equalsIgnoreCase(entries[1][a]))
                        System.out.println("buy...");
                        curState = 0;
                        sentToClient = "Bye.";
                   else
                        System.out.println("buy...!");
                        curState = 0;
                        sentToClient = "Hello.";
    return sentToClient;
    public void run() {
         int next = 0;     
         BufferedWriter bw = null;
         byte [] b = null;
         BufferedWriter bw1 = null;
         try{
    //JOptionPane.showMessageDialog(null,"Sizz");
    String fileNameStr = "C:\\San Server Data\\cInputCustData.txt";
    File f = new File(fileNameStr);
    long size = f.length();
    b = new byte[(int)size];
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    int count = 0, index = 0;
    int byteRed = 0;
    int sizeInt = (int)size;
    while (bis.available() > size-1)//16848 )
    bis.read(b,index,(int)size);
    //int bytesRead = bis.read(b,index,(int)size2);
    //size2 -= count;
    //index += count;
    //System.out.println( "hello:" + b[index]);
    //index++;
    //bis should be closed in a finally block.
    bis.close() ;
    catch(IOException io)
    System.out.println("Oh oh io error");
         //System.out.println("cInputCustData: \n" + new String(b));
         String bStr = new String(b);
         char charbStr []= bStr.toCharArray();
         String header []= new String[5];
         int ctr = 0;
         int e = 0;
    boolean first = true;
         for(int q=0;q<5;q++)
              for(int u=0;u<100;u++)
                   entries[q]= new String("");                    
         //System.out.println("b: " + bStr);
         for(int s=0; s<charbStr.length;s++)
              if(s<charbStr.length-1)
              if(charbStr[s]==':'&&charbStr[s+1]==':')
                   //System.out.println(" s0: " + s);                    
                   for(int ss=s+2;ss<s+12;ss++)
                        //System.out.println("ss: "+ ss + " s: " + s);                         
                        if(charbStr[ss]==':')
                             //System.out.println("in");     
                             header[ctr] = bStr.substring(s,ss);               
                             //System.out.println("1ss: " + ss + " s: " + s);          
                             for(int c=ss+1;c<charbStr.length;c++)               
                                  if(charbStr[c]==':')
                                       //System.out.println("ctr: " + ctr + " " +"entries[0]" + entries[0][0]+ "\n"+ entries[0][1] + "\n" + entries[1][0] + "\n" + entries[1][1]);
                                       if(ss<charbStr.length)entries[ctr][e++] = bStr.substring(ss+1,c);
                                       //System.out.println("c:" + c);
                                       ss= c;
                        ctr++;
                        e=0;
              //System.out.println("header: " + header);                         
                                  //System.out.println("entires[0]0: " + entries[0][0]);
                                  //System.out.println("entires[0]1: " + entries[0][1]);
                                  //System.out.println("entires[1]0: " + entries[1][0]);
                                  //System.out.println("entires[1]1: " + entries[1][1]);
                                  //System.out.println("entires[2]0: " + entries[2][0]);
                                  //System.out.println("entires[2]1: " + entries[2][1]);
              String timeConnect[][] = new String[5][100];
              char myChars[] = null;
              for(int d=0;d<5;d++)
                   for(int f = 0;f<100-1;f++)
                        for(int cs=0;cs<entries[d][f].length();cs++)
                             if(!(entries[d][f].equals("")))
                                  myChars = entries[d][f].toCharArray();
                             for(int a=0;a<entries[d][f].length();a++)
                                  if(myChars[a]==';')
                                       for(int k=a;k<entries[d][f].length();k++)
                                            timeConnect[d][f]= entries[d][f].substring(a,k);
                                       //     System.out.println("time: " + timeConnect[d][f]);
         //for(int o=0;o<5;o++)
              //System.out.println("Header["+o+"]" + header[o]);
         try {
         PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
         BufferedReader input = new BufferedReader(
                        new InputStreamReader(
                        socket.getInputStream()));
         String inLine, outLine;
         outLine = getInput(null);
         output.println(outLine);
         while ((inLine = input.readLine()) != null) {
    244: outLine = getInput(inLine);
              output.println(outLine);
              System.out.println(inLine);
              outputStrings += inLine;
              //if(inLine.equals("Hello."))break;
              timeOfConnect[conCtr++]= " " Integer.toString(hour)":"+Integer.toString(min)+":"+Integer.toString(sec);
              if(c.PM==1){System.out.println("HL");timeOfConnect[conCtr-1]+="PM";}
              System.out.println(timeOfConnect[conCtr-1]);
              outputStrings += "\n"+ timeOfConnect[conCtr-1];
              //System.out.println("output");     
              try {
                   //FileWriter fw1 = new FileWriter("C:\\San Server Data\\Connectlog.txt");
                   bw1 = new BufferedWriter(new FileWriter("C:\\San Server Data\\Connectlog.txt",true));
                   //PrintWriter pw2 = new PrintWriter(bw1);
                        System.out.println(outputStrings);
                        //pw2.println(outputStrings);
                        if(next == 0)          
                             bw1.write(outputStrings);
                        if(next == 1)
                             bw1.write(outputStrings+ " D");
                        bw1.newLine();
                        bw1.flush();
                   //pw2.close();
                        catch (IOException io) {
                   System.out.println("Oh oh, Got and IOException error!"+io);
                        finally{
                             if(bw1 != null) try{
                                  bw1.close();
                             catch(IOException io)     
         output.close();
         input.close();
         socket.close();
    if(next == 0)next = 1;
         else if(next == 1)next = 0;
         //WONCUS1 won = new WONCUS1();
         //String m[] = new String[1];      
         //won.main(m);
         //won.start();     
         } catch (IOException err) {
         err.printStackTrace();
    //Client.java
    public class Client {          
    public static Socket Socket = null;
    public static BufferedReader i = null;
         public static PrintWriter o = null;
         public static String packetString = "CUSCarissa_Calton25242526"; //product id
         public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static String fromServer;
    public static String fromUser;
    public static void main(String[] args) throws IOException {
         int ars=0;
         if (args.length > 0)
              ars = Integer.parseInt(args[0]);
    try {
         Socket = new Socket("localhost", 4444);
    o = new PrintWriter(Socket.getOutputStream(), true);
    i= new BufferedReader(new InputStreamReader(Socket.getInputStream()));
    } catch (UnknownHostException err) {
    System.err.println("Can not find Server!");
    System.exit(1);
    } catch (IOException e) {
    System.err.println("Couldn't get initialisation files to be represented in true statement!");
    System.exit(1);
    while ((fromServer = i.readLine()) != null) {
         //int hour = Integer.parseInt(fromServer);
         //System.out.println("Server: " + fromServer);
         System.out.println("Server: " + fromServer);     
         if (fromServer.equals("Bye."))
    break;
         if (fromServer.equals("Hello."))
    break;
    fromUser = packetString;
         if (fromUser != null) {
    System.out.println("Client: " + fromUser);
    //o.println(fromUser);
              String getComp = InetAddress.getLocalHost().getHostName();
              String ip = InetAddress.getLocalHost().getHostAddress();
              o.println(fromUser+";"+getComp + " " + ip);
              //o.println(getComp + " " + ip);

    "onclose event of application", at least do something such as call wait() on ReadersWhy? Who is going to notify() it?
    and close the Sockets and then Readers/WritersI won't even ask why about that because it is 100% dead wrong. Close the outermost Writer or OutputStream. That flushes the output, closes the socket, and closes any input streams or readers. Taking your advice the flush() cannot occur. But the evidence is that he is closing the socket: in fact the operating system does that anyway. Possibly he needs to take the advice about closing the Writer/OutputStream, to cause the flush(), which might stop the server from writing. But that depends on the application. If it's legal in the application protocol for the client to exit while the server is still writing he will just have to put up with the 'connection resets', or at least interpret them properly rather than just logging them as an error.
    If your using a window(GUI) you can use the main frame with a Window closing event.And that's completely irrelevant because the error happens on the server.

  • How to renable a closed Internal frame?

    Hi Friends,
    I got few intenal frames which can be closed at any point. I dont loose the Jinternalframe Object though. Can I again show the internal frame even if some closes the the internal frame window. Please let me know how ? I will be glad.
    Regards,
    Ravi.

    rather than actually closing the JInternalFrames, use setVisible(false) on a frame to hide it from the user. If you want to bring the window back simply call setVisible(true) on the frame you want to reinstate. You can override the default window closing behaviour to do this fairly easily.

  • MBP (13-inch, early 2011) goes into hibernation instead of safe sleep upon closing the lid (only when using battery power)

    MBP details
    13-inch MacBook Pro, early 2011 (model identifier: MacBookPro8,1)
    Running Yosemite, OS X 10.10.1 (however, problem started while using Mavericks)
    2.5 GHz Intel Core i5
    4 GB memory
    Symptoms
    * the MBP goes into hibernation instead of sleep upon closing the lid on battery power (i.e.,  when AC adapter is NOT connected)
      -- problem does not occur when AC adapter is connected
    * putting the computer to sleep by other means does not induce the problem; these other means include:
      -- [i] option+command+Power,
      -- [ii] Apple Icon --> Sleep,
      -- [iii] in Terminal: pmset sleepnow
    * the battery is NOT getting drained at all; if I close the lid on 87%, the battery is still at about 87% when I get the MBP back up and running
    To be as clear as possible:
    (1) MBP is on and in use  (power source: battery); battery is at X%
    (2) the lid is then closed
    (3) the battery indicator light glows bright for about 10 seconds, then shuts off, and with it so does the MBP (all fans and sounds cease)
    (4) opening the lid and pressing any key on the keyboard does nothing (the computer is not sleeping)
    (5) to turn the MBP back on, I must hit the power button once; this brings up  and the gray screen and loading bar indicative of returning from hibernation
    (6) log in; battery is still at X%
    Attempted Solutions / Fixes
    There are Apple Discussions addressing similar MBP issues, many of which at least have work-arounds, if not full-blown solutions. However, I have tried many of the proposed work-arounds and solutions; nothing has solved my problem. Such attempted solutions include:
      * made sure EFI/SMC firmware was up to date
      * updated all software
      * logged in as a different user
      * booted in Safe Mode
      * reset the PRAM
      * repaired disk permissions using Disk Utility
      * repaired additional disk permissions in recovery mode (a la this chron.com advice)
      * ran the Apple Hardware Test multiple times (short test while plugged in, short test on battery, extended test while plugged in, extended test on battery)
      * booted from an external known-good OS on USB drive
      * reseated the RAM
      * used MemTest to test the RAM's health (it was good)
      * tested my battery's health with the app Battery Health (it is healthy!)
      * booted my computer with one stick of the MBP's original RAM at a time (figured "why not?")
      * booted my computer using other sticks of RAM
      * checked my power management settings using PMSET in the terminal (e.g., pmset -g); tried various hibernation modes (e.g., sudo pmset -a hibernationmode X, where X=0,1,3, etc)
      * searched/grepped through my power management logs and Console messages to look for googleable items (e.g., pmset -g log | grep WORD, where WORD=failure, sleep, etc);  still have not found help online
      * brought the MBP to a Mac Genius
    -- he ran some further tests, but found nothing;
    -- he re-installed my OS as a hopeful-hail-mary-just-maybe-last-ditch effort; the problem persisted!
    -- we both agreed that we had ruled out a software cause
    -- he offered me to leave my MBP to get fixed for a flat fee of $300.00 (which after a couple weeks of trying to figure this out is starting to sound more and more reasonable)
    Given that it is likely not a software issue, what hardware might it be? By booting from an OS on an external drive, I think I've ruled out a bad hard drive or hard drive cable. Also, given that inducing sleep in any way other than closing the MBP's lid does not cause the problem, it seems there might be a wire (or something) in the hinge section of the MBP that gets moved when the lid is closed possibly causing some kind of short circuit...or something.
    If someone with more experience interpreting Console messages, for example, can help, I'd be happy to provide some logs, or any additional information.
    Thank you for your time and consideration.

    Ok, this is a crazy-simple, quasi-embarrassing fix, but I'll post it anyway just in case anyone is having a similar problem (for example, this guy: Changes to pmset being ignored).
    Some time around late last August / early September (2014) this issue began happening for me (specifically, issue = closing lid while on battery power induces hibernation / shut down instead of sleep --- independent of hibernation mode). Maybe it was when I upgraded to Yosemite (not sure what the exact date of that was). As detailed in my original post, I frantically tried everything I could think of... At that time, however, I had quite a few presentations and posters to create and present at meetings and conferences, so I held off fixing it for a couple of months and returned to it this past week, where I tried a few more things listed above, but again to no avail...
    This morning, I simply tried fudging around with all my power management settings again (via pmset in Terminal). The simplicity of the fix surprised me. But now that I understand it, I know it is likely the same fix for other threads I've read, such as the one above:
                                        (TLDR in bold)
    (1) Take note of your power management settings (Terminal:  pmset -g custom)
    (2) Is the "standby" flag set to 0? If so, set it to 1. Wa-la! Done.
    This fix is crazy and embarrassing b/c I was so close to it for so long. I tried changing my hibernation modes multiple times (sudo pmset -a hibernatemode X, where X=0,1,3,25,etc). I read about manipulating other PMSET settings that helped other people with newer MBPs, like "autopoweroff" and "autopoweroffdelay" --- settings that I do not have on the MBP early 2011 (check your settings: pmset -g cap). And most amazingly of all, I even messed with the "standbydelay" setting, trying to make it so long that my computer should never go into hibernation... Yet, from what I can tell by looking over my notes, I never simply set "standby" from 0 to 1.
    There are interesting questions that arise due to this fix. For example, why did this problem persist on clean installs of OS Yosemite? Is "standby" being set to 0 the Yosemite default? I'm not sure. If it is, then Kappy was right: this was normal behavior... It just wasn't always the normal behavior...at least not for my MBP. Normal behavior (hibernatemode 3) used to be (and now is again) that the MBP goes into safe sleep, and then only after an allotted amount of time will it go into full-blown hibernation.
    NOTE: the "standby" and "standbydelay" PMSET settings are not available in some earlier MBP models (e.g., my brother has a 2010 and does not have these settings); so if you're having a similar problem with an earlier model, this fix might not be of any help to you.

  • Help! I don't understand the frame mechanics.

    Hi, I've been trying to figure out how frames work in Flash.  I'm new to ActionScript, so I don't know the inner workings of the language.  I tried checking the API but no Frame class is listed.  The closest thing was FrameLabel and that wasn't helpful.  I need to know a few things:
    1) How can I tell what frame I am in?  If there is a class method for this, what is the exact name?
    2) How does a frame advance?  I have some code with no timer, only event listeners/handlers, and I've got a hacked animation working without playing clips on the time line.  The displayed pictures change whenever I press a directional button to move the character.  This is not really what I want to do however, because I'm switching the visibility of many different symbols and updating their position according to the original player symbol.  Very inefficient.  And does that mean that the frame only advances when a button is pressed? Am I even advancing the frame at all?  I don't know any frame advance method.
    3) How do frames work on the time line?  I have all of my symbols on a single frame.  I made their visibility false in my constructor because I don't want some things to show when I first load up the .swf file.  When I created a second frame, everything went crazy and things began to show up.  This suggests that the visibility = false was only done in the first frame?  What caused the frame to change?  I don't really get it.
    Ideally I want to achieve a dynamically modifiable animation because the game actions are not going to be linear.  The player character will be responding to controls (which will change the animation) and the AI will be responding to the player (which will also change the animation).  I don't think I can do this without understanding frames, so please help me.  I'm very confused!  Even pointing me in the right direction as to where I can read about frame details would be cool.  I've tried Adobe tutorials, support, and documentation but it was not sufficient.  Is there any place where there is a very in depth explanation about frames, or would someone be so kind as to tutor me about them?
    Thanks in advance.

    You can find out the current frame by using the currentFrame property. There are a number of ways to change frames, where the most common would be prevFrame(), nextFrame(), play(), gotoAndPlay(), and gotoAndStop().  There are plenty of ways to make use of frames in a Flash file, from having linear animations along the timeline, to have each frame being a distinct zone of operation that contains elements having their own timelines.
    One thing you may need to get a handle on are the different types of frames.  There are plain frames and there are keyframes.  Plain frames genrally involve a continuation of preceding frames, while keyframes mark an area of change.  In your example of things going crazy when you added a second frame, I am guessing you implanted a new keyframe because had you inserted a plain frame the status of your content from frane 1 would not have been impacted.
    I don't know of any resources for you to follow up with for learning more about frames--I came to learn them thru trial and error.  Someone else may come along with some suggestions for reference materials.

  • Anybody knows how to bounce them off the edge of the frame ...

    I want them to change position randomly and smothly and also bounce off the edge of the frame. i will be so happy if you can help me.
    Here is the code:
    FlatWorld:
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * This FlatWorld contains random number(between 1 and 10) of disks
    * that can be drawn on a canvas.
    public class FlatWorld
        // initialize the width and height of the Canvas in FlatWorld...
        final int WIDTH = 400;
        final int HEIGHT = 400;
        // create random numbers of disks (1-10) using array.
        Random myRandom = new Random();
        int numbersOfDisks = myRandom.nextInt(10) + 1;
        Disk myDisk[] = new Disk[numbersOfDisks];
        // The Canvas on which things can be drawn or painted...
        private Canvas myCanvas;
        * creates a Canvas and disks
       FlatWorld()
            //Creates our disks using array.
            for( int i = 0; i < numbersOfDisks; i++ )
                myDisk[i] = new Disk(WIDTH,HEIGHT);
            //creates a canvas and store it in the instance variable...
            myCanvas = new Canvas(WIDTH,HEIGHT,this);
       /* Draws our disks using array.
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawYourself(Graphics graphicsContext)
            for (int i = 0; i < numbersOfDisks; i++)
                myDisk.drawDisk(graphicsContext);
    public void change()
    final int movementScale = 8;
    for (int i = 0; i < numbersOfDisks; i++)
    int deltax = (int)( Math.random() - 0.5 * movementScale );
    int deltay = (int)( Math.random() - 0.5 * movementScale );
    myDisk[i].move(deltax, deltay);
    Disk:
    import java.awt.*;
    import java.util.*;
    * The Disk class is used to creates a disk with a random position
    * and a random color and a random diameter (between 1/20 width and 1/4 width)
    public class Disk
        /* instance variables */                    
        private int x;
        private int y;
        private int Diameter;
        private Color randomColor;
        private int red, green, blue;
         * Constructor for objects of class Disk
        //creat a disk at a 2D random position between width and height
        public Disk(int width, int height)
            /* Generates a random color red, green, blue mix. */
            red =(int)(Math.random()*256);
            green =(int)(Math.random()*256);
            blue =(int)(Math.random()*256);
            randomColor = new Color (red,green,blue);
            /* Generates a random diameter between 1/20 and 1/4 the width of the world. */
            double myRandom = Math.random();
            Diameter = (width/20) + (int)(( width/4 - width/20 )*myRandom);
            /* Generates a random xy-offset.
             * If the initial values of the xy coordinates cause the disk to draw out of the boundry,
             * then the x and/or y will change their values in order to make the whole disk visible in
             * the boundry. */
            int randomX = (int)(Math.random() * width);
            int randomY = (int)(Math.random() * height);
            int endPointX = randomX + Diameter;
            int xPixelsOutBound = endPointX - width;
            if ( endPointX > width)
                randomX = randomX - xPixelsOutBound;
            int endPointY = randomY + Diameter;
            int yPixelsOutBound = endPointY - width;
            if ( endPointY > width)
                randomY = randomY - yPixelsOutBound;
            setXY(randomX , randomY);
            /* replace values of newX and newY (randomX and randomY) into the x and y variables
             * @param newX The x-position of the disk
             * @param newY The y-position of the disk */
            public void setXY( int newX, int newY )
                x = newX;
                y = newY;
            /* Draw a disk by its coordinates, color and diameter...
             * @param graphicsContext The Graphics context required to do the drawing.
             * Supplies methods like "setColor" and "fillOval". */
            public void drawDisk(Graphics graphicsContext)
                graphicsContext.setColor(randomColor);
                graphicsContext.fillOval( x , y, Diameter , Diameter );
            public void move (int deltaX, int deltaY)
                x = x + deltaX;
                y = y + deltaY;
    }[i]Canvas:import java.awt.*;
    import javax.swing.*;
    public class Canvas extends JPanel
    // A reference to the Frame in which this panel will be displayed.
    private JFrame myFrame;
    // The FlatWorld on which disks can be create...
    FlatWorld myFlatWorld;
    * Initialize the Canvas and attach a Frame to it.
    * @param width The width of the Canvas in pixels
    * @param height The height of the Canvas in pixels
    public Canvas(int width, int height, FlatWorld sourceOfObjects)
    myFlatWorld = sourceOfObjects;
    // Set the size of the panel. Note that "setPreferredSize" requires
    // a "Dimension" object as a parameter...which we create and initialize...
    this.setPreferredSize(new Dimension(width,height));
    // Build the Frame in which this panel will be placed, and then place this
    // panel into the "ContentPane"....
    myFrame = new JFrame();
    myFrame.setContentPane(this);
    // Apply the JFrame "pack" algorithm to properly size the JFrame around
    // the panel it now contains, and then display (ie "show") the frame...
    myFrame.pack();
    myFrame.show();
    * Paint is automatically called by the Java "swing" components when it is time
    * to display or "paint" the surface of the Canvas. We add whatever code we need
    * to do the drawing we want to do...
    * @param graphics The Graphics context required to do the drawing. Supplies methods
    * like "setColor" and "fillOval".
    public void paint(Graphics graphics)
    // Clears the previous drawing canvas by filling it with the background color(white).
    graphics.clearRect( 0, 0, myFlatWorld.WIDTH, myFlatWorld.HEIGHT );
    // paint myFlatWorld
    myFlatWorld.drawYourself(graphics);
    //try but if --> {pauses the program for 100 miliseconds} dont work -->
    try {Thread.sleep(70);}
         catch (Exception e) {}
         myFlatWorld.change();
         repaint();

    Here is my contribution:
    FlatWorld:
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * This FlatWorld contains random number(between 1 and 10) of disks
    * that can be drawn on a canvas.
    public class FlatWorld {
       // initialize the width and height of the Canvas in FlatWorld...
       final int WIDTH = 400;
       final int HEIGHT = 400;
       // create random numbers of disks (1-10) using array.
       Random myRandom = new Random();
       int numbersOfDisks = myRandom.nextInt(10) + 1;
       FlatWorldDisk myDisk[] = new FlatWorldDisk[numbersOfDisks];
       // The Canvas on which things can be drawn or painted...
       private FlatWorldCanvas myCanvas;
        * creates a Canvas and disks
       public FlatWorld() {       
            //Creates our disks using array.
            for( int i = 0; i < numbersOfDisks; i++ ) {
                myDisk[i] = new FlatWorldDisk(WIDTH,HEIGHT);
            //creates a canvas and store it in the instance variable...
            myCanvas = new FlatWorldCanvas(WIDTH,HEIGHT,this);
       /* Draws our disks using array.
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawYourself(Graphics graphicsContext) {
            for (int i = 0; i < numbersOfDisks; i++) {
                myDisk.drawDisk(graphicsContext);
    public void change() {
    final int movementScale = 8;
    for (int i = 0; i < numbersOfDisks; i++) {
    int deltax = (int)( Math.random() - 0.5 * movementScale );
    int deltay = (int)( Math.random() - 0.5 * movementScale );
    myDisk[i].move(deltax, deltay, WIDTH, HEIGHT);
    public static void main(String[] args) {
    new FlatWorld();
    FlatWorldDisk:
    import java.awt.*;
    import java.util.*;
    * The FlatWorldDisk class is used to creates a disk with a random position
    * and a random color and a random diameter (between 1/20 width and 1/4 width)
    public class FlatWorldDisk {
       /* Constants */
       private static final int DIRECTION_NW = 1;
       private static final int DIRECTION_N  = 2;
       private static final int DIRECTION_NE = 3;
       private static final int DIRECTION_W  = 4;
       private static final int DIRECTION_E  = 5;
       private static final int DIRECTION_SW = 6;
       private static final int DIRECTION_S  = 7;
       private static final int DIRECTION_SE = 8;
       /* instance variables */               
       private int x;
       private int y;
       private int diameter;
       private Color randomColor;
       private int red, green, blue;
       private int direction;
        * Constructor for objects of class FlatWorldDisk
       //creat a disk at a 2D random position between width and height
       public FlatWorldDisk(int width, int height) {
          /* Generates a random color red, green, blue mix. */
          red =(int)(Math.random()*256);
          green =(int)(Math.random()*256);
          blue =(int)(Math.random()*256);
          randomColor = new Color (red,green,blue);
          /* Generates a random diameter between 1/20 and 1/4 the width of the world. */
          double myRandom = Math.random();
          diameter = (width/20) + (int)(( width/4 - width/20 )*myRandom);
          /* Generates a random xy-offset.
           * If the initial values of the xy coordinates cause the disk to draw out of the boundry,
           * then the x and/or y will change their values in order to make the whole disk visible in
           * the boundry. */
          int randomX = (int)(Math.random() * width);
          int randomY = (int)(Math.random() * height);
          int endPointX = randomX + diameter;
          int xPixelsOutBound = endPointX - width;
          if (endPointX > width) randomX = randomX - xPixelsOutBound;
          int endPointY = randomY + diameter;
          int yPixelsOutBound = endPointY - width;
          if (endPointY > width) randomY = randomY - yPixelsOutBound;
          setXY(randomX , randomY);
          /* Generates a random direction */
          direction = (int)(Math.random() * 8) + 1;
       /* replace values of newX and newY (randomX and randomY) into the x and y variables
        * @param newX The x-position of the disk
        * @param newY The y-position of the disk */
       public void setXY(int newX, int newY) {
          x = newX;
          y = newY;
       /* Draw a disk by its coordinates, color and diameter...
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawDisk(Graphics graphicsContext) {
          graphicsContext.setColor(randomColor);
          graphicsContext.fillOval( x , y, diameter , diameter );
       public void move(int deltaX, int deltaY,
                        int width, int height) {
          int dx = Math.abs(deltaX);
          int dy = Math.abs(deltaY);
          int olddir = direction;
          int newdir = olddir;
          switch(olddir) {
             case DIRECTION_NW: { int newX = x - dx, newY = y - dy;
                                  if ((newX < 0) && ((y - dy) < 0))         newdir = DIRECTION_SE;
                                  else if (((newX) >= 0) && ((y - dy) < 0)) newdir = DIRECTION_SW;
                                  else if (((newX) < 0) && ((y - dy) >= 0)) newdir = DIRECTION_NE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_N:  { int newY = y - dy;
                                  if ((newY) < 0) newdir = DIRECTION_S;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     y =newY;
                                  break;
             case DIRECTION_NE: { int newX = x + dx, newY = y - dy;
                                  if (((newX + diameter) > width) && (newY < 0))       newdir = DIRECTION_SW;
                                  else if (((newX + diameter) > width) && (newY >= 0)) newdir = DIRECTION_NW;
                                  else if (newY < 0)                                   newdir = DIRECTION_SE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_W:  { int newX = x - dx;
                                  if (newX < 0) newdir = DIRECTION_E;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX;
                                  break;
             case DIRECTION_E:  { int newX = x + dx;
                                  if (newX + diameter > width) newdir = DIRECTION_W;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX;
                                  break;
             case DIRECTION_SW: { int newX = x - dx, newY = y + dy;
                                  if ((newX < 0) && ((newY + diameter) > height))     newdir = DIRECTION_NE;
                                  else if (newX <0)                                   newdir = DIRECTION_SE;
                                  else if ((newY + diameter) > height)                newdir = DIRECTION_NW;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_S:  { int newY = y + dy;
                                  if ((newY + diameter) > height) newdir = DIRECTION_N;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     y =newY;
                                  break;
             case DIRECTION_SE: { int newX = x + dx, newY = y + dy;
                                  if (((newX + diameter) > width) && ((newY + diameter) > height)) newdir = DIRECTION_NW;
                                  else if ((newX + diameter) > width)                              newdir = DIRECTION_SW;
                                  else if ((newY + diameter) > height)                             newdir = DIRECTION_NE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
    FlatWorldCanvas remains unchanged.
    Hope this will help,
    Regards.

  • Difference between closing the connection before and after committing user transaction?

              I was wondering what's the difference between closing the connection before committing
              the transaction versus closing the connection after committing the transaction?...
              for e.g....
              Scenario 1.........
              UserTransaction useretran;
              usertran.begin();
              Connection con = datasource.getCOnnection();
              // do bunch of stuff...
              conn.close();
              usertran.commit()
              Scenario 2...
              UserTransaction useretran;
              usertran.begin();
              Connection con = datasource.getCOnnection();
              // do bunch of stuff...
              usertran.commit()
              conn.close();
              thanks....
              Srini
              

    Hi. As long as you're sure there's a transaction going on, and the connection
    is a transaction-aware object (from a TxDataSource), either will be fine.
    In the first scenario the actual semantics of the close() call are less than
    normal, because we really don't close the connection or return it to the
    pool until the actual transaction commits, and in the second case, we have
    already taken the connection out of your service as of the commit().
    The second scenario is the usual coding style. If there's ever a chance your
    code will get non-transaction-aware connections, it is crucial to close
    connections, and I always recommend putting the close() in a finally block
    so it's guaranteed to happen.
    Joe
    srinivas wrote:
    I was wondering what's the difference between closing the connection before committing
    the transaction versus closing the connection after committing the transaction?...
    for e.g....
    Scenario 1......... UserTransaction useretran; usertran.begin(); Connection con =
    datasource.getCOnnection(); // do bunch of stuff... conn.close(); usertran.commit()
    Scenario 2... UserTransaction useretran; usertran.begin(); Connection con = datasource.getCOnnection();
    // do bunch of stuff... usertran.commit() conn.close();
    thanks....
    Srini

  • Text wrap for a paragraph: How to define the width of a Text box /  active text area? I simply need a longish text to wrap within the frame!

    Hello, I've been searching for a good while in the forums now, but have found no solution or real mention of the problem – I hope some of you can help.
    I want to very simply layout a text between scenes, a slightly longer text that wraps within the frame margins. Here's an example of how I want it to look:
    Now, I couldn't for the life of me get the Custom Text to behave like that, as there are no parameters to set for the width of the text area. The Text Size, yes, along with the Tracking, Baseline and all that, but the width of the text box, no. The above was created by customizing one of the other Text Generator presets that happened to be left aligned.
    However, this preset has a fade in/fade out transition, which I do not want. There's no way to remove this transition as it seems integrated into the Text Generator (meaning they are not really presets, but separate kinds of Text objects? Very silly.)
    So I am asking you: Is there any way to get the Custom Text generator to behave like that? Just a text paragraph as above. Below you'll see all I can manage with the diffferent Custom Text parameters. Any kind of repositioning and resizing of the text just changes the position and size of the frame – but the actual text items are just cropped off where they extend out of that frame. Apparently the bounding box for the text is just some default length, and I can't find any way to adjust the width. See below my different attempts.
    The same text pasted into a Custom Text generator clearly extends outside the frame:
    Here Transform just moves – or resizes – the video frame that the Text Box exists inside:
    The Crop gives similar results, and of course Distort doesn't get me closer to what I need, either. There should be simply a Text Box Width parameter to set somewhere, but if it exists they have hidden it very well. How do you do it?
    Thanks for any help, this is a silly problem, but one of now many trivial problems that amount to me growing quite dissatisfied with FCPX. Hopefully I've just overlooked something.
    All the best,
    Thomas

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

Maybe you are looking for

  • Please dont erase music

    i posted a bulliten earlier about itunes not openeing and about updating and all...well it updated but to update it it's going to have to erase all of my data and it says my music will be erased to.....i payed for all of this...how can it erase it??

  • Basic Questions about Oracle E-Business Suite

    I am just now starting to learn about Oracle E-Business Suite. I am an Oracle DBA, and I want to become an "Oracle Apps DBA". The following questions pertain to the DATABASE side of E-Business: *(1)* Is "Oracle E-Business Suite", and "Oracle Applicat

  • Concatinating strings in a loop

    The string TYPE only contains the last value from the loop instead of all of them Attachments: Search Catalog.vi ‏88 KB

  • Result in SELECT-OPTIONS not valid

    Hi, I wrote the next statment about SELECT-OPTIONS..but for example if the selection criterio S_HKONT is initial..this is don´t have a value...all the result are true when I compare.. I wrote: SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-0

  • DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"

    I got dump in production system,can you please advice how to sort it out. Database error text........: "[207] Invalid column name 'PAGENO'.#[8180] Statement(s) could not be prepared." Internal call code.........: "[RSQL/INSR/REGUP ]" Please check the