944,066 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3499
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 15th, 2006
0

Java tutor needed BADLY

Expand Post »
I am looking for someone that can help me online for an hour or so maybe a few times for the next few weeks that can help me understand what I am supposed to do for my class programs. I am not looking for someone to do them for me but to be a guide and tutor.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
korbynlehr is offline Offline
18 posts
since May 2006
Jul 21st, 2006
0

Re: Java tutor needed BADLY

I might suggest picking yourself up a copy of 'Beginning Programming with Java for Dummies"...and if you're feeling particularily sassy, O'Reilly Java In A Nutshell. It's all the reference you'll ever need (except for javax.swing.* and java.awt.* - which are briefly covered in the Dummies book).

Perhaps I could be of some assistance, though. Just post the issue you're having here, on this thread, and I'll help you best I can.
Reputation Points: 23
Solved Threads: 2
Junior Poster in Training
indienick is offline Offline
71 posts
since Aug 2005
Jul 22nd, 2006
0

Re: Java tutor needed BADLY

Quote originally posted by korbynlehr ...
I am looking for someone that can help me online for an hour or so maybe a few times for the next few weeks that can help me understand what I am supposed to do for my class programs. I am not looking for someone to do them for me but to be a guide and tutor.
I am an Architect who is 10 years experienced in Software Development. Its very good that you are seeking help for class programs rather than getting them done as that's the right thing to do. I would be willing to be guide and tutor for $15 an hour. You can choose the time between 6pm and 10 pm EST and the days you want.

Thanks,
Bharat.
Phone 203 428 4124
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bharatchhajer is offline Offline
2 posts
since Jul 2006
Jul 22nd, 2006
0

Re: Java tutor needed BADLY

Pick up a book and start reading it. Then, when you have a problem try to figure it out yourself. If you can't after some time get it solved, then post back to a forum. Paying for a tutor is a terrible idea. As a programmer you need to solve problems on your own. Learn how to look up information and search google.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jul 22nd, 2006
0

Re: Java tutor needed BADLY

Quote originally posted by bharatchhajer ...
I am an Architect who is 10 years experienced in Software Development. Its very good that you are seeking help for class programs rather than getting them done as that's the right thing to do. I would be willing to be guide and tutor for $15 an hour. You can choose the time between 6pm and 10 pm EST and the days you want.

Thanks,
Bharat.
Phone 203 428 4124
By any definition, that's not the right thing to do. If they're school/college/uni class programs, (and not just program classes) maybe you should consider a different course.

Still; I earnt a lot doing other people's schoolwork for money, and on the upside, It taught me and my clients valuable business skills.

Matt
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jul 24th, 2006
0

Re: Java tutor needed BADLY

The problem I am having is getting the last part working. The timer is the part I am having trouble with which is the last code I submitted.





Java Syntax (Toggle Plain Text)
  1. import java.awt.Frame;
  2. import java.awt.event.WindowAdapter;
  3. import java.awt.event.WindowEvent;
  4. import javax.swing.UIManager;
  5. import java.awt.Dimension;
  6. import java.awt.Toolkit;
  7. public class ScoreboardApp
  8. {
  9. public ScoreboardApp()
  10. {
  11. Frame frame = new ScoreboardFrame();
  12. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  13. Dimension frameSize = frame.getSize();
  14. if (frameSize.height > screenSize.height)
  15. {
  16. frameSize.height = screenSize.height;
  17. }
  18. if (frameSize.width > screenSize.width)
  19. {
  20. frameSize.width = screenSize.width;
  21. }
  22. frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
  23. frame.addWindowListener(new WindowAdapter()
  24. {
  25. public void windowClosing(WindowEvent e)
  26. {
  27. System.exit(0);
  28. }
  29. });
  30. frame.setVisible(true);
  31. }
  32. public static void main(String[] args)
  33. {
  34. try
  35. {
  36. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  37. }
  38. catch(Exception e)
  39. {
  40. e.printStackTrace();
  41. }
  42. new ScoreboardApp();
  43. }
  44. }

Java Syntax (Toggle Plain Text)
  1. import javax.swing.JFrame;
  2. import javax.swing.JMenu;
  3. import javax.swing.JMenuBar;
  4. import javax.swing.JMenuItem;
  5. import java.awt.Dimension;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.GridBagLayout;
  9. import java.awt.BorderLayout;
  10. import javax.swing.JPanel;
  11. import java.awt.Color;
  12. import javax.swing.JTextField;
  13. import java.awt.GridBagConstraints;
  14. import java.awt.Insets;
  15. import java.awt.Font;
  16. import javax.swing.JLabel;
  17. import javax.swing.JButton;
  18. import javax.swing.*;
  19. import java.text.*;
  20. public class ScoreboardFrame extends JFrame
  21. {
  22. JMenuItem menuFileExit = new JMenuItem();
  23. JMenu menuFile = new JMenu();
  24. JMenuBar menuBar1 = new JMenuBar();
  25. BorderLayout borderLayout1 = new BorderLayout();
  26. JPanel panelScoreboard = new JPanel();
  27. GridBagLayout gridBagLayout1 = new GridBagLayout();
  28. JTextField txtHomeScore = new JTextField();
  29. JLabel jLabel1 = new JLabel();
  30. JLabel jLabel2 = new JLabel();
  31. JTextField txtGuests = new JTextField();
  32. JTextField txtTime = new JTextField();
  33. JPanel panelButtons = new JPanel();
  34. JButton btnTimeControl = new JButton();
  35. JButton btnHomeAdd = new JButton();
  36. JButton btnHomeSub = new JButton();
  37. JButton btnGuestsAdd = new JButton();
  38. JButton btnGuestsSub = new JButton();
  39. DecimalFormat df = new DecimalFormat("00");
  40. int homeScore = 0;
  41. int guestsScore = 0;
  42. public ScoreboardFrame()
  43. {
  44. try
  45. {
  46. jbInit();
  47. }
  48. catch(Exception e)
  49. {
  50. e.printStackTrace();
  51. }
  52. }
  53. private void jbInit() throws Exception
  54. {
  55. this.setJMenuBar(menuBar1);
  56. this.getContentPane().setLayout(borderLayout1);
  57. this.setSize(new Dimension(534, 300));
  58. this.setTitle("Basketball Scoreboard");
  59. menuFile.setText("File");
  60. panelScoreboard.setBackground(new Color(227, 82, 227));
  61. panelScoreboard.setLayout(gridBagLayout1);
  62. txtHomeScore.setText("00");
  63. txtHomeScore.setPreferredSize(new Dimension(100, 75));
  64. txtHomeScore.setFont(new Font("SansSerif", 1, 60));
  65. txtHomeScore.setForeground(Color.red);
  66. txtHomeScore.setEditable(false);
  67. jLabel1.setText("Home");
  68. jLabel1.setFont(new Font("Dialog", 1, 20));
  69. jLabel1.setForeground(Color.white);
  70. jLabel2.setText("Guests");
  71. jLabel2.setForeground(Color.white);
  72. jLabel2.setFont(new Font("Dialog", 1, 20));
  73. txtGuests.setText("00");
  74. txtGuests.setCaretColor(Color.red);
  75. txtGuests.setForeground(Color.red);
  76. txtGuests.setEditable(false);
  77. txtGuests.setPreferredSize(new Dimension(100, 75));
  78. txtGuests.setFont(new Font("SansSerif", 1, 60));
  79. txtTime.setText("10:00");
  80. txtTime.setFont(new Font("SansSerif", 1, 60));
  81. txtTime.setForeground(Color.red);
  82. txtTime.setEditable(false);
  83. btnTimeControl.setText("Start/Stop");
  84. btnTimeControl.setForeground(Color.red);
  85. btnTimeControl.addActionListener(new ActionListener()
  86. {
  87. public void actionPerformed(ActionEvent e)
  88. {
  89. btnTimeControl_actionPerformed(e);
  90. }
  91. });
  92. btnHomeAdd.setText("Home +");
  93. btnHomeAdd.addActionListener(new ActionListener()
  94. {
  95. public void actionPerformed(ActionEvent e)
  96. {
  97. btnHomeAdd_actionPerformed(e);
  98. }
  99. });
  100. btnHomeSub.setText("Home -");
  101. btnHomeSub.addActionListener(new ActionListener()
  102. {
  103. public void actionPerformed(ActionEvent e)
  104. {
  105. btnHomeSub_actionPerformed(e);
  106. }
  107. });
  108. btnGuestsAdd.setText("Guests +");
  109. btnGuestsAdd.addActionListener(new ActionListener()
  110. {
  111. public void actionPerformed(ActionEvent e)
  112. {
  113. btnGuestsAdd_actionPerformed(e);
  114. }
  115. });
  116. btnGuestsSub.setText("Guests -");
  117. btnGuestsSub.addActionListener(new ActionListener()
  118. {
  119. public void actionPerformed(ActionEvent e)
  120. {
  121. btnGuestsSub_actionPerformed(e);
  122. }
  123. });
  124. menuFileExit.setText("Exit");
  125. menuFileExit.addActionListener(new ActionListener()
  126. {
  127. public void actionPerformed(ActionEvent ae)
  128. {
  129. fileExit_ActionPerformed(ae);
  130. }
  131. });
  132. menuFile.add(menuFileExit);
  133. menuBar1.add(menuFile);
  134. panelScoreboard.add(txtHomeScore, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 1, 1));
  135. panelScoreboard.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 1, 1));
  136. panelScoreboard.add(jLabel2, new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 1, 1));
  137. panelScoreboard.add(txtGuests, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 1, 1));
  138. panelScoreboard.add(txtTime, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  139. this.getContentPane().add(panelScoreboard, BorderLayout.CENTER);
  140. panelButtons.add(btnHomeAdd, null);
  141. panelButtons.add(btnHomeSub, null);
  142. panelButtons.add(btnTimeControl, null);
  143. panelButtons.add(btnGuestsAdd, null);
  144. panelButtons.add(btnGuestsSub, null);
  145. this.getContentPane().add(panelButtons, BorderLayout.SOUTH);
  146. }
  147. void fileExit_ActionPerformed(ActionEvent e)
  148. {
  149. System.exit(0);
  150. }
  151. void btnTimeControl_actionPerformed(ActionEvent e)
  152. {
  153. }
  154. void btnHomeAdd_actionPerformed(ActionEvent e)
  155. {
  156. homeScore++;
  157. txtHomeScore.setText(df.format(homeScore));
  158. }
  159. void btnHomeSub_actionPerformed(ActionEvent e)
  160. {
  161. homeScore--;
  162. txtHomeScore.setText(df.format(homeScore));
  163. }
  164. void btnGuestsAdd_actionPerformed(ActionEvent e)
  165. {
  166. guestsScore++;
  167. txtGuests.setText(df.format(guestsScore));
  168. }
  169. void btnGuestsSub_actionPerformed(ActionEvent e)
  170. {
  171. guestsScore--;
  172. txtGuests.setText(df.format(guestsScore));
  173. }
  174. }

Java Syntax (Toggle Plain Text)
  1. import javax.swing.JTextField;
  2.  
  3. public class ScoreboardTimer extends Thread
  4. {
  5. private int counter; // the number of seconds remaining on the timer
  6. private boolean isRunning; // toggle variable that controls whether the counter is decremented or not
  7. private JTextField timerDisplay; // reference to the GUI object displaying the timer
  8. // getters and setters for the variables
  9. public boolean toggleRunning()
  10. {
  11. // toggles the value of isRunning variable; called from click handler on/off button on frame
  12. }
  13. public void run()
  14. {
  15. while (counter > 0)
  16. {
  17. // delay one second with sleep() method
  18. // if clock is running, decrement counter and update display
  19. }
  20. }
  21. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
korbynlehr is offline Offline
18 posts
since May 2006
Jul 24th, 2006
0

Re: Java tutor needed BADLY

you don't need to extend thread to make a timer, there's already two (javax.swing.Timer and java.utils.Timer) personally i prefer java.utils.Timer, but more often than not i use javax.swing.Timer to avoid conlict issues in swing applications.

if you absolutely must use a thread, you don't need to extend it... I had some code to use a Thread as a Timer; (incedently - you can't call some old Thread methods like you could in previous versions without experiencing crashes..) the method doesn't extend thread, just creates a thread and listens to its run() calls.

But, i've lost that code, and can only find some code that's very wasteful, it creates a new Thread instance every 10th of a second, and eats up the stack like some kind of.. stack monster.

Read this page:

http://www.velocityreviews.com/forum...er-thread.html

it was actually quite difficult to find on google, i'd say 99 times out of ten people use the Timer objects rather than writing thier own.

Matt
Last edited by MattEvans; Jul 24th, 2006 at 11:50 pm.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jul 25th, 2006
0

Re: Java tutor needed BADLY

Using the java.utils.timer class is fine. It is highly recommended NOT to use the javax.swing.timer class. It will mess up your swing ui.
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005
Jul 25th, 2006
0

Re: Java tutor needed BADLY

really? i use it on jframes that don't really have uis (just a big Canvas/Cavnas3D); what does it mess up specifically?
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jul 25th, 2006
0

Re: Java tutor needed BADLY

When using the javax.swing.Timer class if the process kicked off by the timer is long (as in longer then several milla seconds), it is posible to see the Swing UI freeze for the amount of time it takes the process to run.

Which IMO is a bad thing.
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: JTable help!
Next Thread in Java Forum Timeline: Uploading





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC