Adding a variable to a class causes a WinRT originate error.

I have a Clock class which causes my game to crash after I add the following line
public:
int FrameTimeTicks; // this line will cause the crash
the error message reads:
First-chance exception at 0x74B24598 (KernelBase.dll) in HH.exe: 0x40080201: WinRT originate error (parameters: 0x80000013, 0x0000001D, 0x02C3D5E0).
First-chance exception at 0x74B24598 in HH.exe: Microsoft C++ exception: Platform::ObjectDisposedException ^ at memory location 0x02C3DA80. HRESULT:0x80000013 The object has been closed.
WinRT information: The object has been closed.
The program '[8200] HH.exe' has exited with code 0 (0x0).
This is completely meaningless to me. It's a strange problem.
Edit: When i step through the program, a breakpoint on the first line of MainPage() isn't reached before the exception is thrown. I can put a breakpoint in Clock constructor which looks like this:
Clock::Clock()
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&pCountAppStart);
//FrameTimeTicks = {};
And it will be hit, when i step through from there, execution reaches the end of Clock(), goes to MainPage() open brace, but before it hits the first line I get "Source not available - Source information is missing from the debug information for this
module ..."
So has MainPage been disposed ?
Here is the Clock.h file:
#pragma once
#include <Windows.h>
#include <map>
#include "Debug.h"
using namespace std;
using namespace Platform;
using namespace Platform::Collections;
class Clock
public:
Clock();
int64 MarkIn();
int64 MarkOut();
//int FrameTimeTicks; // can't add these
//int FrameTimeMS = 0;
private:
LARGE_INTEGER frequency = {};
LARGE_INTEGER pCountAppStart = {};
LARGE_INTEGER pCountStt = {};
LARGE_INTEGER pCountEnd = {};
//int frameTimeTicks; // can't add these either
//int frameTimeMS;

So I think I have found the problem here, and I came to a fix by using Analyze > Run code analysis on solution. Something I've never used before. When i ran it, it gave me 3 issues, one of the issues was that I was using a byte* to pixel data after a
failed call to
IBufferByteAccess->Buffer(&pixels);
I don't know why the call is failing as I call it immediately after creating the WriteableBitmap, and then later in ClearBitmap. Also, the call result never returns a failure. But, nevertheless, by checking for the HRESULT and returning NULL if it fails,
then checking for NULL in the calling functions. The issue seems to have been resolved and I can add variables to my clock class.
I guess something weird was happening with memory.

Similar Messages

  • Adding itemCreationPolicy="immediate" on mx:Panel causes null object reference error in Flex 4.x

    The itemCreationPolicy works fine with spark components and other mx component until we hit by mx panel.
    Looks like an error is thrown from StyleProtoChain.
    The interesting thing is the null object reference error both occurs in Flex 4.0 and Flex 4.1, but caused by different objects.
    Is there a workaround to use itemCreationPolicy on mx panel?
    Thank you.

    Yes, there are all kinds of problems when you remove something from the screen that had focus (for instance, at that point you can't capture keyboard events either).
    My code is sprinkled with so many things to make sure something is in focus, I tend to forget that I've done it.
    In your code that changes the currentState, add
    this.setFocus()
    HTH;
    Amy

  • How to access variables from other class

        public boolean inIn(Person p)
            if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
                 return true;
            else
                 return false;
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
    here am trying to compare the existing object with another object.
    could you please tell me how to access the variables of other class because i meet this error?
    name cannot be resolved!
    thank you!

    public class Person
        protected String name; 
        protected char gender;      //protected attributes are visible in the subclass
        protected int dateOfBirth;
        protected String address;
        protected String natInsceNo;
        protected String phoneNo;
        protected static int counter;//class variable
    //Constractor Starts, (returns a new object, may set an object's initial state)
    public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
        dateOfBirth = howOld;
        gender = sex;
        name = nme;
        address = addr;
        natInsceNo = ins;
        phoneNo = phone;
        counter++;
    public class Store
        //Declaration of variables
        private Person[] list;
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             list = new Person[max];//size array with parameters
             maxSize = max;
             count = 0;
        }//end of store
    //constructor ends
    //accessor starts  
        public boolean inIn(Person p)
           return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

  • Adding session variable causes Dreamweaver to not recognize recordset

    I have a recordset that I have written in advanced mode, the test checks out fine and dreamweaver reconizes it in "server behaviors" and the code is colorized in "code view". Testing the page in a browser works fine.
    Adding a variable for session username, still checks out with MySQL and saves to the page but is no longer recognized in the "server behaviors" and in "code view" it is no longer colorized. All server behaviors that use a recodset as in repeat regions break and cannot find the recordset. Testing in a browser quickly displays a blank page in firefox and a 500 error in IE.
    This is with a bogus variable, which loads fine.
    mysql_select_db($database_ess, $ess);
    $query_client_bdays = "SELECT clients.clientname, clients.birthmonth, clients.birthday FROM clients WHERE clients.username=username AND CONCAT(YEAR(CURDATE()),'-',birthmonth,'-',birthday) BETWEEN DATE_ADD(CURDATE(), interval 30 day) AND DATE_ADD(CURDATE(), interval 60 day)";
    $client_bdays = mysql_query($query_client_bdays, $ess) or die(mysql_error());
    $row_client_bdays = mysql_fetch_assoc($client_bdays);
    $totalRows_client_bdays = mysql_num_rows($client_bdays);
    Here is with the session
    $varU_client_bdays = "-1";
    if (isset(<?php echo $_SESSION['username']; ?>
      $varU_client_bdays =<?php echo $_SESSION['username']; ?>;
    mysql_select_db($database_ess, $ess);
    $query_client_bdays = sprintf("SELECT clientname,  birthmonth, birthday FROM clients WHERE clients.username=%s AND CONCAT(YEAR(CURDATE()),'-',birthmonth,'-',birthday) BETWEEN DATE_ADD(CURDATE(), interval 30 day) AND DATE_ADD(CURDATE(), interval 60 day)", GetSQLValueString($varU_client_bdays, "text"));
    $client_bdays = mysql_query($query_client_bdays, $ess) or die(mysql_error());
    $row_client_bdays = mysql_fetch_assoc($client_bdays);
    $totalRows_client_bdays = mysql_num_rows($client_bdays);
    I have also included a screen shot of the mess in code view.
    Thanks for any help in advance!

    Found the answer, changing from  <?php echo $_SESSION['username']; ?>  to   $_SESSION['username'];  resolved the issue.

  • Error when defining a variable from a class

    Hi,
    I'm getting this error message when trying to define a
    variable from a class:
    '1086: Syntax error: expecting semicolon before left paren.'
    I can't see where the error is.
    The scripts Question.as and Codeframe.as is located int the
    folder Mycomponents under the project.
    Regards
    /Acke
    **** Main app *****
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.CloseEvent;
    import myComponents.*;
    var Question():myComponents.Question=new Question(); // !!
    This line causes the error !!
    other code goes here....
    ]]>
    </mx:Script>
    **** The class definition ******
    package myComponents
    //import other classes needed
    import Mycomponents.Codeframe
    public class Question {
    // Define properties and methods.
    // Define public vars.
    public var Qtype:string;
    public var Condition:string;
    public var Qnumber:string;
    public var Qheading:string;
    public var Pretext:string;
    public var Qtext:string;
    public var Posttext:string;
    public var Codeframe():string;
    public var Reserved:string;
    public var EditableFrom:string;
    public var EditableTo:string;
    public var Decimal:string;
    public var SetQfactor:string;
    public var Logic_if():string;
    public var Logic_then():string;
    // Public constructor.
    //public function Question(){
    // do stuff to set initial values for properties
    public function Question(Type:string,
    Condition:string,
    Qnumber:string,
    Qheading:string,
    Pretext:string,
    Qtext:string,
    Posttext:string,
    Codeframe():string,
    Reserved:string,
    EditableFrom:string,
    EditableTo:string,
    Decimal:string,
    SetQfactor:string,
    Logic_if():string,
    Logic_then():string,
    ):Void
    this.Type=Type;
    this.Condition=Condition;
    this.Qnumber=Qnumber;
    this.Qheading=Qheading;
    this.Pretext=Pretext;
    this.Qtext=Qtext;
    this.Posttext=Posttext;
    this.Codeframe()=Codeframe();
    this.Reserved=Reserved;
    this.EditableFrom=EditableFrom;
    this.EditableTo=EditableTo;
    this.Decimal=Decimal;
    this.SetQfactor=SetQfactor;
    this.Logic_if()=Logic_if();
    this.Logic_then()=Logic_then();
    }

    1.
    It should be
    var theQuestion:Question = new
    Question(sType,sCondition:string,sQnumber,sQheading,sPretext,sQtext,sPosttext,
    sCodeframe,sReserved,sEditableFrom,sEditableTo,sDecimal,sSetQfactor,sLogic_if,sLogic_then )
    As you don't have default values in the constructor - you
    should specify the parameters.
    2. why do use type "string" ? It should be "String" if you
    refer to a standard type
    3. What are you trying to say by this:
    public var Codeframe():string;
    public var Logic_if():string;
    public var Logic_then():string;
    There should not be any parenthesis in the variable
    declaration.
    4.
    this is wrong
    var Question():Question=new Question();
    this even wronger
    var Question():Array=new Question(); // I'm trying to create
    an array here anyway...could this be the problem??
    no parenthesis!
    var Qs():Question=new Question();
    hmmmm....
    .var Qs()=new Question();
    I think you should start reading from the following link to
    get more understanding of the variables, types & declarations:
    http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001863.html
    Cheers,
    Dmitri.

  • Add variables into WS class

    I have java bean classes generated by ws-import from a wsdl
    Can I modify the classes, adding a variable to mark something when I load them from database, but it won't be sent to SOAP?

    jtahlborn wrote:
    you can do that, but it makes project maintenance very difficult as you will lose any modifications if you ever need to generate those classes again. in my current projects, we never actually check-in the generated classes, only the schemas. generating the classes happens as part of the build cycle.Thank for great advice
    I will write a wrapper instead

  • Declaring a variable of a class

    Hi,
    I'm creating a stack to save math operations that have occurred so that I can use an undo button to remove those operations.  I followed this implementation:
    http://deviltechie.wordpress.com/2010/10/03/create-a-stack-queue-data-structure-in-flex-ac tionscript/#comment-71
    I created two actionscript class files Node.as and Stack.as like what was done in the link but I do not know how to create a variable of that class in the Script area of my .mxml file.  My code looks like this:
        <fx:Script>
            <![CDATA[
                import dataStore.Node;
                import Stack;
                var storage:dataStore.Stack;
            ]]>
        </fx:Script>
    I was trying to create a variable called storage of type Stack but I get an error saying "1046: Type was not found or was not a compile-time constant: Stack."
    Any information on how to correctly create a variable of a stack class in the Script of my main MXML file would be very helpful.
    Thanks

    Thanks spoboyle and pauland,
    By adding a new package called dataStore I was able to create a variable of Stack so you two will get the answer and helpful answer to my question. 
    Currently I am getting a error when I try to use the push and pop functions from the Stack.as file.  The error is this:
    Error #1009: Cannot access a property or method of a null object reference.
    I am not sure if I am calling the functions incorrectly in the code or if the Stack.as code I borrowed from the link above is incorrect. What I have is two buttons, "1" and "undo".  If the "1" is pressed the total value gets subtracted by 1 and number 1 gets pushed into the stack.  If "undo" is pressed then the 1 gets popped from the stack and added to the total.  Here is an implementation of my code trying to use the push and pop functions:
    <fx:Script>
            <![CDATA[
                import dataStore.Node;
                import dataStore.Stack;
                public var storage:Stack;
                protected function one_clickHandler(event:MouseEvent):void
                    var tot:Number =int(total.text);
                    var amount:Number=int(1);
                    tot=tot-1;
                    total.text = String(tot);
                    storage.push(amount);
                protected function undo_clickHandler(event:MouseEvent):void
                    var num:Number =int(storage.pop());
                    var tot:Number =int(total.text);
                    tot=tot+(num);
                    total.text = String(tot);
            ]]>
        </fx:Script>
    I receive this error everytime I press the "1" button or the "undo" button when I am running the application.  Any info would be greatly appreciated.

  • How to call a variable in another class????

    if i have two classes in a package. From one class, how do i get the value of one of the variable in the other class.
    For example;
    Class A have a variable call totalNum which have a value initialise.
    Class B wan to get the value variable totalNum in class A.
    So do i go abt calling it?
    Cheers

    For example;
    Class A have a variable call totalNum which have a
    value initialise.
    Class B wan to get the value variable totalNum in
    class A.Your explanation is far from clear. Is the variable in class A a field? If yes, is it a static field? Is it declared public, private, etc.?
    If you don't understand the above questions, you should do the following:
    1) Learn the basics of the Java language from the Java Tutorial and/or from an entry-level book: http://java.sun.com/docs/books/tutorial/
    2) Post future question in the New To Java Technology forum.

  • Is there a way to reference a private variable from one class in another?

    My first class starts off by declaring variables like so:
    class tStudent {
      // declare student name, id, grades 1 & 2, and gpa
      private String fname, lname, g1, g2;
      private int id;
      private double gpa;
      // define a constructor for a new student
      tStudent () {fname=lname=g1=g2=null; id=-1; gpa=0.0;}
      // define methods for manipulating the data members.
      // readStudent: reads information for just one student
    public void read (Scanner input) {
          fname = input.next();
          lname = input.next();
          id = input.nextInt();
          g1 = input.next();
          g2 = input.next();
    }And the second class:// tStudentList: for a list of students
    class tStudentList {
      private int nStudents;
      private tStudent[] list;
      // constructor for creating student list
      tStudentList() {
          list = new tStudent[36];
          for (int i=0; i < 36; i++) list=new tStudent();
    // read the individual students into the student list
    public void read(Scanner scan) {
    nStudents=0;
    while (scan.hasNext()) {list[nStudents++].read(scan);}
    // display the list of all students - fname, lname, id, g1, g2 and gpa
    // with an appropriate header so the output matches my sample //output
    public void print() {
    Is there a way to reference the variables in the first class to use in the second? Specifically in the last section of code where I am going to print the list.

    Not without resorting to reflection hackery. If the fields are private (and are supposed to be), then that means "don't allow access to these to outsiders of this class" by design.
    So if you really meant them to be accessible, then don't use private, or provide public accessors for them.

  • Using a variable from one class to another

    Hi !
    I've a class called ModFam (file ModFam.java) where I define a variable as
    protected Connection dbconn;
    Inside ModFam constructor I said:
    try
    String url = "jdbc:odbc:baselocal";
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    dbconn = DriverManager.getConnection(url);
    System.err.println("Connection successful");
    } ..... rest of code
    This class define a TabbedPane as follows:
    tabbedPane.addTab("Welcome",null,new Familias(),"Familias");
    As you can see it call a new instance of the Familias class (file Familias.java).
    This constructor will try to connect with the DB to populate a combo box with some data retireved from the DB.
    If I do
    Statement stmt;
    stmt = dbconn.createStatement();
    inside Familias constructor I receive the message
    Familias.java:50: cannot resolve symbol
    symbol : variable dbconn
    location: class fam.Familias
    stmt = dbconn.createStatement();
    at compile time.
    While I can�t use a variable defined as "protected" in one class of my package on another class of the same package ?
    How could I do ?
    Thanks in advance
    <jl>

    Familias doesn't have a reference to ModFam or the Connection.
    So change the constructor in Familias to be
    public class Familias {
      private ModFam modFam;
      public Familias(ModFam m) {
        modFam = m;
    // ... somewhere else in the code
    Statement stmt = modFam.dbconn.createStatement();
    }or
    public class Familias {
      private Connection dbconn;
      public Familias(Connection c) {
        dbconn = c;
    // ... somewhere else in the code
    Statement stmt = dbconn.createStatement();
    }And when you instantiate Familias it should then be
    new Familias(this) // ModFam reference
    or
    new Familias(dbconn)

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Sending a variable from one class to another?

    Dear Java Users - please can you help me out here... I know that what I am asking should be straight forward BUT I just don't understand any of the responses people have put on the web....
    Here is what I am trying to do:
    This piece of code - creates a window with a simple textbox on it to enter a word...
    The button then calls another class file to open a new window...
    All I want to do is to take the word from the text box and print it in the new window....
    The first .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class FrontPageGUI extends JFrame implements ActionListener
         //declare all instance variables for THIS per class
              JLabel lblInfoOne;
              JLabel lblButtonPopUp;
              JTextField txtName;
              JButton close;
              JButton popUp;
         public FrontPageGUI()
              //set characteristics of the JFrame object
              super("Title Bar");
              setSize(600,600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              //we need to define a Container to place objects onto the frame - this is inside the JFrame Object Above
              Container ca = getContentPane( );
              ca.setSize(600,600);
              ca.setBackground(Color.white);
              ca.setLayout(null);                
              //define all other objects and set thier characteristics
              lblInfoOne     = new JLabel("Enter a word in the box above to send:");
              lblButtonPopUp = new JLabel("Click Here:");
              txtName          = new JTextField("");
              //create Button components
              close = new JButton("Close");
              popUp = new JButton("Click Me");
              //now add all objects to the container
              //Labels
              addXY(ca,lblInfoOne, 30, 160, 550,45);
              addXY(ca,lblButtonPopUp, 30, 210, 550,45);
              //TextField
              addXY(ca,txtName, 120, 100, 200,30);
              //Buttons
              addButtonXY(ca, popUp, 30, 260, 200, 45);
              addButtonXY(ca, close, 30, 310, 80, 30);
              // add the Container to the Frame     
              setContentPane(ca);          
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         public void actionPerformed(ActionEvent event)
              if (event.getSource()== popUp)
                   //This is WHERE THE PROBLEM IS...
                   //Here I want to send to contents of the textfield - txtName
                   String temp = txtName.getText();
                   new PopUpGUI(temp);
              if (event.getSource()==close)
                   closeUp();
         void closeUp()
              System.exit(0);
              //dispose();
    //we need a driver program - this is the only time MAIN is used.
    public class FrontPage
         //create an instance of the GUI and showit
         public static void main(String args [])
              new FrontPageGUI();
                   The second .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class PopUpGUI extends JFrame implements ActionListener
         //declare all instance variables ie per class
              JLabel headerLabel;
              JLabel sentLabel;          
              JButton close;
         public PopUpGUI(String Sent)
              //set characteristics of the JFrame object
              super("Pop Up Window");
              setSize(320,450);
              setVisible(true);
              //need to define a Container to place objects onto the frame
              Container ca = getContentPane( );
              ca.setSize(320,450);
              ca.setLayout(null);                
              //define all other objects and set characteristics
              headerLabel = new JLabel("New Window!"); //heading label
              sentLabel = new JLabel(Sent);
              close = new JButton("Close");
              //now add all objects to the container
              addXY(ca,headerLabel,10,10,380,80);
              addXY(ca,sentLabel,10,100,380,80);
              addButtonXY(ca, close, 50, 200, 100, 30); //Bottom Left
              // add the Container to the Frame     
              setContentPane(ca);
         //We need these 2 methods - EVERY TIME
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         //What to do when the click happens
         public void actionPerformed(ActionEvent event)
              if (event.getSource()==close)
                   dispose();
                   //closeUp(); - Doesn't run CLOSEUP this time (i.e. exit program) - instead just DISPOSEs of the window
    //Driver class is in FrontPage.javaThis seems to work... but is it the best way to do it????
    Tony.

    Well,
    Using the constructor is the way to go. Otherwise create a method that takes the string as parameter.

  • Adding a JPanel from one class to another Class (which extends JFrame)

    Hi everyone,
    So hopefully I go about this right, and I can figure out what I'm doing wrong here. As an exercise, I'm trying to write a Tic-Tac-Toe (TTT) game. However, in the end it will be adaptable for different variations of TTT, so it's broken up some. I have a TTTGame.java, and TTTSquareFrame.java, and some others that aren't relavent.
    So, TTTGame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              addPanel = startSimple();
              if(!addPanel.isValid())
                   System.out.println("Something's wrong");
              contents.add(addPanel);
              setSize(300, 300);
              setVisible(true);
         public JPanel startSimple()
              mainSquare = new TTTSquareFrame(sides);
              mainSquarePanel = mainSquare.createPanel(sides);
              return mainSquarePanel;
    }and TTTSquareFrame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.Misc;
    public class TTTSquareFrame
         private JPanel squarePanel;
         private JButton [] squares;
         private int square, index;
         public TTTSquareFrame()
              System.out.println("Use a constructor that passes an integer specifying the size of the square please.");
              System.exit(0);
         public TTTSquareFrame(int size)
         public JPanel createPanel(int size)
              square = (int)Math.pow(size, 2);
              squarePanel = new JPanel();
              squarePanel.setLayout(new GridLayout(3,3));
              squares = new JButton[square];
              System.out.println(MIN_SIZE.toString());
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setRolloverEnabled(false);
                   squares[i].addActionListener(bh);
                   //squares[i].setMinimumSize(MIN_SIZE);
                   squares[i].setVisible(true);
                   squarePanel.add(squares[i]);
              squarePanel.setSize(100, 100);
              squarePanel.setVisible(true);
              return squarePanel;
    }I've successfully added panels to JFrame within the same class, and this is the first time I'm modularizing the code this way. The issue is that the frame comes up blank, and I get the message "Something's wrong" and it says the addPanel is invalid. Originally, the panel creation was in the constructor for TTTSquareFrame, and I just added the mainSquare (from TTTGame class) to the content pane, when that didn't work, I tried going about it this way. Not exactly sure why I wouldn't be able to add the panel from another class, any help is greatly appreciated.
    I did try and cut out code that wasn't needed, if it's still too much let me know and I can try and whittle it down more. Thanks.

    Yea, sorry 'bout that, I just cut out the parts of the files that weren't relevant but forgot to compile it just to make sure I hadn't left any remnants of what I had removed. For whatever it's worth, I have no idea what changed, but something did and it is working now. Thanks for your help, maybe next time I'll post an actual question that doesn't somehow magically solve itself.
    EDIT: Actually, sorry, I've got the panel working now, but it's tiny. I've set the minimum size, and I've set the size of the panel, so...why won't it respond to that? It almost looks like it's being compressed into the top of the panel, but I'm not sure why.
    I've compressed the code into:
    TTTGame.java:
    import java.awt.*;
    import javax.swing.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              mainSquare = new TTTSquareFrame(sides.intValue());
              contents.add(mainSquare);
              setSize(400, 400);
              setVisible(true);
    }TTTSquareFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class TTTSquareFrame extends JPanel
         private JButton [] squares;
         private int square, index;
         private final Dimension testSize = new Dimension(50, 50);
         public TTTSquareFrame(int size)
              super();
              square = (int)Math.pow(size, 2);
              super.setLayout(new GridLayout(size, size));
              squares = new JButton[square];
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setMinimumSize(testSize);
                   squares[i].setVisible(true);
                   super.add(squares[i]);
              setSize(200, 200);
              setVisible(true);
    I've made sure the buttons are smaller than the size of the panel, and the panel is smaller than the frame, so...
    Message was edited by:
    macman104

  • Moving Variable from one class to another.

    I need to get a Variable from one class to another how would I do this?

    Well this is a very tipical scehario for every enterprise application. You always create logger classes that generate log files for your application, as that is the only way to track errors in your system when its in the production enviorment.
    Just create a simple class that acts as the Logger, and have a method in it that accepts a variable of the type that you are are trying to pass; most commonly a String; but can be overloaded to accept constom classes. e.g.
    class Logger
      public void log(String message)
        writeToFile("< " + new Date() + " > " + message);
      public void log(CustomClass queueEvent)
        log("queue message was: " + queueEvent.getMessage() + " at: " + queueEven.getEventTime());
    }Hope this makes things clearer
    Regards
    Omer

  • Make a variable in a class av ail. to main tl

    I thought putting public in front of a variable made it
    available to the main timeline, but it doesnt. How do you make it
    available to the main tl? Should I just put it on the main
    tl?

    You are accessing the variable through the class name
    "Class", that is a flash built-in class.
    If you copy and paste the code as I wrote it it doesn't give
    any problem... Anyway, can you paste your code here?

Maybe you are looking for

  • Sharepoint 2013 Document library Issue

    Hi In sharepoint 2013 Doc lib,I uploaded a document and I can see it was successful, but then I can't close the window, or get back to the customer documents unless I "control/alt/delete" and close all IE windows & re-log in. Now, 4 minutes later it

  • Replicating material from R/3 to SRM problem

    Hi experts I have done all configurations for material replication from R/3 to SRM but an error still occuring When I start the initiao load I can see inSMQ1 of backen 2 entries R3AD_MATERIA* and MASS_SRM_MATERIA* in status STOP, and some materials a

  • Junk mail confusion - is this spam?

    I have long been confused by certain behaviour of Mac Mail. When Mail identifies spam (on my Mac, at least), it marks it by changing the text colour in the preview pane brown and moves it to the Junk folder, as per my preferences. However, I get some

  • Inserting Blank Line after subtotal in ALV

    Hi, I am using REUSE_ALV_GRID_DISPLAY for my report output and I am displaying the following fields : Company Code Comp Name  Bank Name Amount Data I am sorting my output based on the company code and displaying the subtotal for each company code. My

  • What formula automatically copy cells in numbers

    what formula automatically copy cells in numbers