CasiOo's Profile
Reputation: 994
Master
- Group:
- Expert
- Active Posts:
- 2,201 (2.83 per day)
- Joined:
- 05-April 11
- Profile Views:
- 5,482
- Last Active:
Today, 03:42 PM- Currently:
- Offline
Previous Fields
- Country:
- DK
- OS Preference:
- Who Cares
- Favorite Browser:
- Opera
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- PC
- Your Car:
- Who Cares
- Dream Kudos:
- 100
- Expert In:
- Java
Latest Visitors
-
Astro52a9 
18 May 2013 - 07:48 -
jawhnay 
14 May 2013 - 14:59 -
DaltonMeserve 
09 May 2013 - 13:53 -
bombinabirdcage 
09 May 2013 - 13:48 -
cornetto456 
30 Apr 2013 - 10:21
Posts I've Made
-
In Topic: throw exception
Posted 21 May 2013
You can have your exception extend RunetimeException, then you do not need to catch it
You could use the class ArithmeticException instead of creating your own class
public double divide(int value1, int value2) { if (value2 == 0) throw new ArithmeticException("Dividing by zero"); } -
In Topic: java gui questions
Posted 19 May 2013
There are different ways. GregBrannon has written a tutorial where he shows a good way of handling it
Greg uses action commands, and I really find them useful too. You could also have an ActionListener for each of the events, but I think it just tend to mess up the code
Use interfaces so you easily can swap out your view, controller, or model
public interface IMenuBarView { public final String NEW_CLICKED; public final String ABOUT_ME_CLICKED; public final String EXIT_CLICKED; public void addNewClickedListener(ActionListener listener); public void addAboutMeClickedListener(ActionListener listener); public void addExitClickedListener(ActionListener listener); } public class MenuBarController implements ActionListener { public MenuBarController(IMenuBarView view) { view.addNewClickedListener(this); view.addAboutMeClickedListener(this); view.addExitClickedListener(this); } @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case: IMenuBarView.NEW_CLICKED break; case: IMenuBarView.ABOUT_ME_CLICKED break; case: IMenuBarView.EXIT_CLICKED break; } } } -
In Topic: java gui questions
Posted 19 May 2013
There is no reason to pass your Main class to the MenuBar
Instead you should let MenuBar extend JMenuBar (Don't name your class MenuBar since there already exist such a class in the API)
Keep your instance variables private to encapsulate them and keep control in the MenuBar class
You really shouldn't allow anyone to modify the instance variables other than the MenuBar class
menuBar = new MenuBar(); setJMenuBar(menuBar);
public class MenuBar extends JMenuBar { private JMenu newMenu //... } -
In Topic: UDP Client side ...
Posted 19 May 2013
Wow you really need to settle down and focus on one project/problem at a time
You have started so many topics the past days, all about different topics and projects
Seems like you want to solve all the world's problems at once... or at least make us solve them for you
You should be spending more time trying to solve the problems yourself -
In Topic: how to write and read binary file
Posted 18 May 2013
Just to follow up on g00se's post, I don't think everyone understand the file.length() / 8
int size = (int) (file.length() / 8);
It makes more sense when you read the documentation
Quote
public final void writeDouble(double v)
throws IOException
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first. If no exception is thrown, the counter written is incremented by 8.
My Information
- Member Title:
- D.I.C Lover
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Years Programming:
- 2½
Contact Information
- E-mail:
- Private
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
b.netana
23 Mar 2013 - 17:32b.netana
23 Mar 2013 - 17:32raghav.naganathan
25 Nov 2012 - 21:15ubunta
30 Sep 2012 - 23:33hope will be fine and feeling well!!!!!!!!!!!!!!
Proshnobodhok
12 Oct 2011 - 12:31I really didnt know the term. nyways seems like you can help me in at least telling me the way to get the related resources. but is it against the IT laws?
CasiOo
28 Jun 2011 - 04:11smohd
26 Jun 2011 - 19:39