CasiOo's Profile User Rating: *****

Reputation: 994 Master
Group:
Expert
Active Posts:
2,201 (2.83 per day)
Joined:
05-April 11
Profile Views:
5,482
Last Active:
User is offline 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

Icon   CasiOo has not set their status

Posts I've Made

  1. 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");
    }
    
    
  2. 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;
    		}
    	}
    }
    
    
  3. 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
        //...
    }
    
    
  4. 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
  5. 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:

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    b.netana Icon

    23 Mar 2013 - 17:32
    thank*
  2. Photo

    b.netana Icon

    23 Mar 2013 - 17:32
    wanted to that you for your help with my gui practice
  3. Photo

    raghav.naganathan Icon

    25 Nov 2012 - 21:15
    Hi dude...I would like to tell you that your rep(729) is a perfect cube :) Cheers :)
  4. Photo

    ubunta Icon

    30 Sep 2012 - 23:33
    hi hello
    hope will be fine and feeling well!!!!!!!!!!!!!!
  5. Photo

    Proshnobodhok Icon

    12 Oct 2011 - 12:31
    Hi CasiOo,
    I 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?
  6. Photo

    CasiOo Icon

    28 Jun 2011 - 04:11
    Thank you :)
  7. Photo

    smohd Icon

    26 Jun 2011 - 19:39
    Welcome to contributors group
Page 1 of 1