write my assignment 28990

We have our first project this week. So any questions you may have please fire away, don’t be shy 🙂 It helps keep me on my toes. Plus, I always give out HINTS along the way to make the process less painful so lets get started.:)

Now the quickest way to address this project is in stages for example :

The project basically requires you to what, read a text file and create a calculator interface; that’s it, you can use a file selection dialog box or hard code it; your choice.

you will need a Tokenizer correct? and here are t

private StringTokenizer tok;

   private String token = new String();

   private String nextToken = new String();

   private String line = new String();

   private JFrame frameA; 

   private Scanner fileIn;

   private Scanner scanLine;

   private JButton button;

   private int left, right, left2, right2;

   private int syn = 0;

   private String x;

Then using the scanner and tokenizers you will read that file line by line

 public void createGui(){

       try{

           fileIn = new Scanner(new BufferedReader(new FileReader(file)));

           if(fileIn.hasNextLine()){

               scanLine = new Scanner(line = fileIn.nextLine());

                createWindow(scanLine);

……..

//method using scanners and tokenizers to ensure syntax while creating the gui

    public void createWindow(Scanner scanLine){

       if (scanLine.hasNext()){

           token = scanLine.next();

           if(token .equals(“Window”)){

               if (scanLine.hasNext()){

                   token = scanLine.next();

                   frameA = new JFrame(getString(token));

………………………………………

//method to ensure syntax and determine the layout of the frame

public void createFrameLayout(Scanner scanLine){

if(scanLine.hasNext()){

if((token = scanLine.next()) .equals(“Layout”)){

if(scanLine.hasNext()){ 

token = scanLine.next(); 

tok = new StringTokenizer(token, “:”, true); 

if((token = tok.nextToken()) .equals(“Flow”))

………………………………………………..

//method to determine the parameters used in grid layout

public GridLayout createGridLayout(Scanner scanLine){

tok = new StringTokenizer(token, “[(),]”, true);

if(tok.hasMoreTokens()){

if((token = tok.nextToken()) .equals(“Grid”)){

if(tok.hasMoreTokens()){

if((token = tok.nextToken()) .equals(“(“)){

if(tok.hasMoreTokens()){ 

token = tok.nextToken();

//main method for widget, everything here is added to the frame

public void createWidgets(Scanner fileIn){

while(fileIn.hasNextLine()){

scanLine = new Scanner(line = fileIn.nextLine()); 

if (scanLine.hasNext()){

token = scanLine.next(); 

x = token;

if(x .equals(“Button”)){

frameA.add(button = button(scanLine));

}

else if(x .equals(“Group”)){

for(JRadioButton rB: createGroup(fileIn)) frameA.add(rB);

………………………………………………………

//method for adding widgets to panels, use of recursion here for nested panels

public void createWidget(Scanner fileIn, JPanel jPan){

while(fileIn.hasNextLine()){

line = fileIn.nextLine();

scanLine = new Scanner(line); 

if (scanLine.hasNext()){

token = scanLine.next();

x = token;

if(x .equals(“Button”)){

jPan.add(button(scanLine

 
"Not answered?"
Get the Answer