facebook Twitter RSS Feed YouTube StumbleUpon

Home | Forum | Chat | Tours | Articles | Pictures | News | Tools | History | Tourism | Search

 
 


Go Back   BanglaCricket Forum > Miscellaneous > Support

Support Help & Support

Reply
 
Thread Tools Display Modes
  #1  
Old March 1, 2005, 11:38 PM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361
Default Java Help

Just switching to java, and still dont know many staff. here is small problem, if someone can give me a solution. their must be an easier way to do it, but dont know how.

i've two frame, frame1 is the main frame, frame2 will come up when a button in frame1 is pressed. while frame2 is on, the button on frame1 will not generate frame2 again. and closing frame2 will go back to frame1. this actions can be repeated. the problem i'm having is, as many times i keep pressing the generating button, a new frame2 keeps coming up.

thanks in advance.

here is the code i've:

public void JButton1_actionPerformed(ActionEvent e){
Frame2 f = new Frame2();
f.validate();
f.show();
}


the "new" is causing the trouble. and Frame2.show() gives syntax error.

many not be needed, still, i'm using Borland JBuilder 2005 Enterprise Edition.



Edited on, March 2, 2005, 4:44 AM GMT, by AgentSmith.
Reply With Quote

  #2  
Old March 1, 2005, 11:40 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,678

ektu matha ghuracche. can u re-explain? or post the code? let me see what i can do.
Reply With Quote
  #3  
Old March 1, 2005, 11:40 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,678

ok i think i got what you said. sorry about that. posting the code will be helpful nevertheless. and yes, it probably doesnt matter which IDE you're using here.

Edited on, March 2, 2005, 4:41 AM GMT, by AsifTheManRahman.
Reply With Quote
  #4  
Old March 1, 2005, 11:48 PM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

code posted, atmh. thanks.
Reply With Quote
  #5  
Old March 2, 2005, 02:00 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,678

hmm. looks like you're opening frame2, but not preventing it from opening when one version of frame2 is already open. f.show() should display frame2, but where does it say in the code that it should not be displayed once there's already a frame2 open?

btw - can you post the exact errors you're getting, and the code for the method call?
Reply With Quote
  #6  
Old March 2, 2005, 02:07 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,678

btw - i'm not very familiar with frames and windows (or anything visual for that matter, unless you're talking about web development tools) so i'm not sure how much i may be able to help you.
Reply With Quote
  #7  
Old March 3, 2005, 12:03 AM
Nasif's Avatar
Nasif Nasif is offline
Administrator
BanglaCricket Development
 
Join Date: October 4, 2002
Location: USA
Favorite Player: Mashrafe Mortaza
Posts: 9,094

Before you create new Frame2(), have a global flag variable verification. If flag is unset create new Frame2() then set the flag. After frame2() is closed/destroyed unset that variable again.

Something like this:

if (flag == 0) {
Frame2 f = new Frame2();
flag=1;
f.validate();
f.show();
}


and then in the close/destroy method the last operation should be: flag=0;

That will ensure that your frame2 isn't recreated if its already active. I don't know if its the best way (not a java expert) but it is one way.

By the way, I think NetBeans is much better IDE for Java (and its free ).

Edited on, March 3, 2005, 5:06 AM GMT, by nasif.
Reply With Quote
  #8  
Old March 3, 2005, 12:33 AM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

nasif vai, thanks for the help, i tried that, but the problem here is, i can't unset the flag. i mean, when frame two is closed it should make the flag =0 again. what is the way to do that?

one thing i found is:

setDefaultCloseOperation(flag=0);


the problem is, if i do that, the frame does not close anymore. and i can't use it twice so:
setDefaultCloseOperation(flag=0);
setDefaultCloseOperation(frame2.HIDE_ON_CLOSE);
only executes the first line, doesnot matter which one i put first. so, it will either make the flag zero or close, don't know how to do both.

btw, jbuilder is free too and its more fun to use a professional compiler free than to use a free one.
Reply With Quote
  #9  
Old March 3, 2005, 12:36 AM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

i found it!!!!

just declear the frame outside the stub of the jButton, right at the beginning of

public class Frame1 extends JFrame{......

that way, when i press the jbutton, it will not create a new frame, but will reshow the same frame already created.
Reply With Quote
  #10  
Old March 3, 2005, 09:48 AM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,678

hahaha....basic mistake that all java beginners make! nothing to worry about!
Reply With Quote
  #11  
Old March 13, 2005, 03:43 PM
cricman's Avatar
cricman cricman is offline
Cricket Guru
 
Join Date: February 8, 2005
Location: Deleting Evidence
Favorite Player: Dubya
Posts: 10,102

use Jcreator its the best
Reply With Quote
  #12  
Old March 21, 2005, 08:48 PM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

once again, i'm stuck: this time a bit more complicated. see if anyone can give some tips.

overveiw: i'm writting a software to operate a device (an RFID). it operates in bitwise command. i need to send a packet of binary (=hex) number through rs232 serial port.

problem: the packet has to be in the grup of 8 bits (1 byte). i did it in C, they have this "unsigned char" that has 8 bit. problem with java is, its char is 16 bits(2 bytes). i tryed to use "byte" type variable in java, but i can't. because i can't assign something like

byte var1=0xFF; i'm not able to change the Most sig bit to 1.
and if i'm using a bigger variable say char or int, my device will not take it since they are padded with a huge line of zeros. what can i do? any idea?

in short, i need 8 bit of space where i can use all eight.
Reply With Quote
  #13  
Old March 21, 2005, 08:56 PM
Zunaid Zunaid is offline
Administrator
 
Join Date: January 22, 2004
Posts: 22,100

read this:

http://darksleep.com/player/JavaAndUnsignedTypes.html
Reply With Quote
  #14  
Old March 21, 2005, 09:21 PM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

thanks doc.

how did u find it so quick? i spent some time looking for something like this but did not find any. have u had it read before? in this case, one more question for u (this is just out of curisity, i can use that method anyway). why bother doing all this, is not it be same if we do this?

int a=0x000000FF;
b=(byte)a;

if not, why?

Edited on, March 22, 2005, 2:43 AM GMT, by AgentSmith.
Reply With Quote
  #15  
Old March 22, 2005, 01:10 AM
Nasif's Avatar
Nasif Nasif is offline
Administrator
BanglaCricket Development
 
Join Date: October 4, 2002
Location: USA
Favorite Player: Mashrafe Mortaza
Posts: 9,094

Won't work because the moment you change it into byte type most sig bit can't be modified. You will always need higher type to store lower type ( word to store byte, long to store word etc). Thats why all operations need that byte mask (0xFF).

Not a java guru, but looking at the problem that seems to be the reason. I think C/C++ is the best programming for hardware interface
Reply With Quote
  #16  
Old March 22, 2005, 02:13 AM
Rubu's Avatar
Rubu Rubu is offline
Moderator
 
Join Date: February 15, 2004
Location: Michigan
Favorite Player: Mashrafee Mortaza
Posts: 8,361

yes, the thing i'm trying to do has done in C several times. but when we choose the language for our project, we wanted GUI+database+hardware interface. fast two are harder in C. VB was not an option because we needed it platform free. i'll give it a try, if does not work, i'll have to find a way to run an internal program written in C and get the data from text files or something like that.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On



All times are GMT -5. The time now is 08:07 PM.



Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
BanglaCricket.com
 

About Us | Contact Us | Privacy Policy | Partner Sites | Useful Links | Banners |

© BanglaCricket