69 Posted Topics
I have an unsigned char (8-bits wide, naturally) that contains 8 flag bits. Example: [CODE] unsigned char flag1:1, flag2:1, flag3:1, flag4:1, flag5:1, flag6:1, flag7:1, flag8:1; [/CODE] I would like to take this unsigned char and convert it into a bit array where each bit represents a flag. Pretty much like … | |
I've spent hours trying to get this to work, but I can't seem to figure it out. This site has been good to me with my java problems and I saw this php section so I figured I'd come back and give it a try. What I have and assume … | |
This is actually part of a much bigger program, but I cut it down to the problematic area to make it easier to read. [code=java] import javax.swing.JButton; public class test{ static GameButton[] grid; static class GameButton extends JButton{ int value = 0; } public static void main(String[] args){ grid = … | |
Hi. Well, the past year, I have spent learning GUI programming in Java and have created several games (Asteroids, MineSweeper, TicTacToe, etc, etc) in Java. I was wondering if there is an easy way (is it easy at all?) to go from what I know about GUI programming in Java, … | |
Is there a way to make a frame totally wipe all traces of itself (make it return null) by pressing the X on the window? setDefaultCloseOperation(DISPOSE_ON_CLOSE); doesn't actually make the frame return null, rather, it saves its state and cleans it out of memory... A call to show or pack … | |
I'm trying to create a JButton in 1 of my 2 JFrames which exits the top or current JFrame... If I try: [code] System.exit(0); [/code] The entire, currently running Java Virtual Machine, exits... (both frames) I'm basically trying to get the same result as [code]setDefaultCloseOperation(DISPOSE_ON_CLOSE);[/code] does to the X button … | |
1.) Update Checking. 2.) Score/Record keeping. 3.) Submitting score online. Update Checking: Currently, my program connects to a URL and checks if a new version is available. If one is, it simply opens up a dialog saying a new version is out and to go download it... Is there a … | |
Hi again. I'm trying to get Java to recognize the action of pressing both mouse buttons in the same time. I did some research and I found that Event.getModifiersEx() can help me do what I want, but I can't figure out how to implement it the correct way. Event.BUTTON1_DOWN_MASK is … | |
Hi again. I'm trying to recreate the digital timer in Minesweeper: Top right ----- [url]http://www.uberreview.com/wp-content/uploads/506x363-minesweeper.jpg[/url] 000 -> 002 -> ... -> 009 -> 010 -> etc... I couldn't think of an easier way to do it except to create an Icon for each number and match it to it's corresponding … | |
Re: instead of extending KeyAdapter, try implementing KeyListener | |
I'm trying to add a KeyListener to my JFrame, but it doesn't seem to work when I have a JButton floating around [code=Java]import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Testing extends JFrame implements KeyListener{ public static void main(String[] args){ SwingUtilities.invokeLater(new Runnable() { public void run(){ new Testing(); … | |
[code=java] import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class Testing extends JFrame { public static void main(String[] args){ SwingUtilities.invokeLater(new Runnable() { public void run(){ new Testing(); } }); } private Testing(){ super("tester"); launch(); } private void launch(){ setBounds(200, 200, 300, 300); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel topPanel = new … | |
Re: If you look at the 2nd question, [code=java]if ( gender == 1 ) if ( age >= 65 ) ++seniorFemales;[/code] is the same as saying [code=java]if ( gender == 1 ){ if ( age >= 65 ){ ++seniorFemales; } }[/code] if and else statements don't require { } if their … | |
Re: Find the directory to the bin folder of your latest JDK: Usually, you will find this folder in: "C:\Program Files\Java\YOUR_LATEST_JDK\bin" Then go to Control Panel -> System -> Advanced -> Environment Variables.. In the bottom box, you will see the "System Variables" section. Find "Path". You will see that it … | |
Re: Use this to load your image: [inlinecode]ImageIcon ICON = new ImageIcon("YOUR.GIF");[/inlinecode] Then use this to attach the image to your buttons: [inlinecode]BUTTON.setIcon(ICON);[/inlinecode] Make sure you import the single file or folder that contains the icons into your project. The example above would work if you import just the file. If … | |
Re: extend JFrame to your class and then you can do some work... If you want an example, you can probably use this to get you started: [code=java] import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class test extends JFrame { public boolean mouseClick = false; … | |
I have a JButton with both an ActionListener and a MouseListener: [code=Java] b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae){ performLeftClickAction((JButton)ae.getSource()); } }); b.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent me){ if(SwingUtilities.isRightMouseButton(me)){ performRightClickAction((JButton)me.getSource()); } } }); [/code] Here are the 2 actions for right clicking and left clicking: [code=Java] performLeftClickAction(JButton b){ //problem … | |
Alright, well, this is my 2nd post so far... My first problem was easily repaired ( I incremented an i instead of j in one of my for loops... lol ). But this problem is a little more, how can I say, not a visual mistake, but a implementation thing... … | |
Well, this is my first post on here... I've found your message boards very useful when searching for problems so I decided to register and ask for help on this one since it's a little more specific than what I could find... I've had 3 semesters of programming in college … |
The End.