Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: Frozen application buttons will not work

  1. #1
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Frozen application buttons will not work

    I seem to be hitting road block after road block. I had my application working and I made a new class called AddMain and a deleted the other public main class so I can begin testing the app as a whole.

    Now the main menu comes up but I cannot click on any of the buttons. Its just frozen, the JOptionPane pops up telling me I am not connected to mySQL but thats about it. I am using MVC type of a design. Code will be below.

    package addItemBtn.Home.DataBase;
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.TextEvent;
    import java.awt.event.TextListener;
     
    import javax.swing.event.DocumentListener;
     
     
    public class AddItemController 
    {
    	private AddItemModel model;
    	private AddItemView view;
     
    	AddItemController(AddItemModel model,AddItemView view)
    	{
    		this.model = model;
    		this.view = view;
     
    		//adding actionListeners for the AddItemClass
    		view.cancelBtn.addActionListener(new ActionListeners());
    		view.submitBtn.addActionListener(new ActionListeners());
    		view.previewBtn.addActionListener(new ActionListeners());
    		view.nameBox.addActionListener(new ActionListeners());
    		view.priceBox.addActionListener(new ActionListeners());
    		view.locationBox.addActionListener(new ActionListeners());
    		view.descriptionBox.getDocument().addDocumentListener((DocumentListener) new ActionListeners());
     
    		view.frame.setVisible(true);
    	}
     
    	class ActionListeners implements ActionListener, TextListener
    	{
     
    		@Override
    		public void actionPerformed(ActionEvent e) 
    		{
    			try
    			{
    				if(e.getSource() == view.submitBtn)
    				{
    					System.out.println("submit Pressed");
     
    					model.setName(view.getName());
    					model.setLocation(view.getAddress());
    					model.setPrice(view.getPrice());
    					model.setDiscription(view.getTextArea());
     
    				}
    				else if(e.getSource() == view.cancelBtn)
    				{
    					view.frame.dispose();
    					System.out.println("Cancel Pressed");
    				}
    				else if(e.getSource() == view.previewBtn)
    				{
    					System.out.println("Preview pressed");
    					model.setName(view.getName());
    					model.setLocation(view.getAddress());
    					model.setPrice(view.getPrice());
    					model.setDiscription(view.getTextArea());
    				}
    				else
    				{
    					System.out.println("else");
    				}
     
    			}catch(Exception ex)
    			{
    				System.out.println("There was an error "+e);
    			}
     
    		}
     
    		@Override
    		public void textValueChanged(TextEvent e) 
    		{
    			String text;
    			try
    			{
    				if(e.getSource() == view.descriptionBox)
    				{
    					text = view.descriptionBox.getText();
     
    					System.out.println(text);
    				}
    			}catch(Exception ex)
    			{	
    				System.out.println("There was an error text area "+ex);
    			}
     
    		}
     
     
     
    	}
     
    }

    package addItemBtn.Home.DataBase;
     
    import mainMenu.Home.DataBase.StartUpMenu;
    import mainMenu.Home.DataBase.StartUpMenuController;
     
    public class AddMain 
    {
     
    	public static void main(String args[])
    	{
    		StartUpMenu menu = new StartUpMenu();
    		AddItemView view = new AddItemView();
    		AddItemModel model = new AddItemModel();
     
    		new StartUpMenuController(menu);
    		new AddItemController(model,view);
    	}
     
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    It's time you should know that Swing apps should be run on the EDT using a general approach like:
        public static void main( String[] args )
        {
            SwingUtilities.invokeLater( new Runnable()
            {
                public void run()
                {
                    // start Swing app here
                }
            } );
        }
    Search for more info about why this is so.

    We can't test your app to see what's going on, but possibilities include: there's an error occurring out of sight where you have an empty catch{} block or some other code that's hiding the error, a while( true ) loop that's locking up the code, or some other 'invisible' kind of run time error. Add print statements to your code so that you can see what's happening. It might also be a good time to learn how to use a debugger and/or profiler to locate the general problems I've described above more easily.

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    jocdrew21 (September 26th, 2014)

  4. #3
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    Thank you... I didn't know I had to include that in my main method. I will do so for now on. I would have been here for hours staring my my code trying to figure it out. Thank you so much, it works fine now.

  5. #4
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Angry applications just opening up before the button is even hit

    I ran into this before and I double checked all my constructors to make sure I was not calling the new frame somewhere else. Then I took it out of the main statement

    Before:
    public class AddMain 
    {
     
    	public static void main(String args[])
    	{
    		SwingUtilities.invokeLater(new Runnable()
    		{
    			public void run()
    			{
    				StartUpMenu menu = new StartUpMenu();
    				new StartUpMenuController(menu);
     
    				AddItemView view = new AddItemView();
    				AddItemModel model = new AddItemModel();
     
    				new AddItemController(model,view);
     
    			}
    		});
     
    	}

    After:
    public class AddMain 
    {
     
    	public static void main(String args[])
    	{
    		SwingUtilities.invokeLater(new Runnable()
    		{
    			public void run()
    			{
    				StartUpMenu menu = new StartUpMenu();
    				new StartUpMenuController(menu);
     
    				//AddItemView view = new AddItemView();
    				//AddItemModel model = new AddItemModel();
     
    				//new AddItemController(model,view);
     
    			}
    		});
     
    	}
     
    }

    Now it works but naturally once I click add item the new frame pops up but the buttons don't do anything. If I uncomment the addItemView and model two windows just pop open once the app starts.

    errors:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: addItemBtn.Home.DataBase.AddItemController$ActionListeners cannot be cast to javax.swing.event.DocumentListener
    	at addItemBtn.Home.DataBase.AddItemController.<init>(AddItemController.java:28)
    	at addItemBtn.Home.DataBase.AddMain$1.run(AddMain.java:23)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:694)
    	at java.awt.EventQueue$3.run(EventQueue.java:692)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    Last edited by jocdrew21; September 26th, 2014 at 03:40 AM.

  6. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    Even I'm surprised that that simple change had the resotrative effect it apparently had. You need to understand why it's important, when it's important to use (which parts of the app to start in the run() method and which to not), and when it's okay or important to use the standard approach. I haven't looked at your next thread yet, but it may be a product of using this new tool improperly.

    The Swing tutorials on the 'net, in books, and everywhere else, should teach or demonstrate the importance of the running Swing apps on the EDT from the start, but they don't. Now that you've been introduced to it, do the additional research I suggested to understand it so that you use it properly.

    Update

    Now that I have looked at the new thread, I see it is simply a continuation of this one. Please don't start new threads for continuing thoughts/conversations/problems. There's value to you and others in seeing the whole conversation in context.

    Let me look at your new complaint a bit. I don't understand it yet.

    After reviewing the new result, I don't see the connection between the title and the error you posted. The error is complaining about a cast that isn't allowed. Fix that. As for parts of the application opening before the button is pressed that should open them, that means you've gotten things out of order. The Controller should decide what pieices of the View are open when, but something in the logic has taken the authority of the Controller away. Put the Controller back in control.

  7. #6
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    I commented out model and AddItemController in the main method and it still happened. Which leads me to think the issue is in the AddItemView. Then I do something like this:
    public void run()
    			{
    				StartUpMenu menu = new StartUpMenu();
    				new StartUpMenuController(menu);
     
    				//AddItemView view = new AddItemView();
    				AddItemModel model = new AddItemModel();
     
    				//new AddItemController(model,view);
     
    			}

    And it works but naturally the buttons lost their actionListeners and don't do anything anymore. I am staring at addItemController and AddItemView and nothing is standing out.

    package addItemBtn.Home.DataBase;
     
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
     
    import javax.swing.*;
     
    import net.miginfocom.swing.MigLayout;
     
    public class AddItemView
    {
     
    	JFrame frame;
    	JPanel btnPanel,descriptionPan,picturePanel,textPanel;
    	JTextField nameBox,priceBox,locationBox;
    	JLabel nameLbl,descriptionLbl,priceLbl,locationLbl,pictureLbl;
    	JTextArea descriptionBox;
    	JButton submitBtn,cancelBtn,previewBtn;
     
    	JFileChooser fileopen;
     
    	public AddItemView()
    	{
    		//set up frame
    		frame = new JFrame("Add Item");
    		frame.setSize(950,750);
    		frame.setLayout(new MigLayout());
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
    		btnPanel = new JPanel();
    		descriptionPan= new JPanel();
    		picturePanel= new JPanel();
    		textPanel= new JPanel();
     
    		textPanel = textBoxes(textPanel);
    		btnPanel = bottomButtons(btnPanel);
    		descriptionPan = descriptionPanel(descriptionPan);
    		picturePanel = pictureArea(picturePanel);
     
    		//place textFields to top left of frame
    		frame.add(textPanel,"cell 0 1");
    		//place picture panel into top right of frame
    		frame.add(picturePanel,"cell 8 1");
    		//place buttons on bottom of frame
    		frame.add(btnPanel,"dock south");
    		//place descriptionPanel to the center of the frame
    		frame.add(descriptionPan,"dock south");
     
     
    		frame.setVisible(true);
    	}
     
    	JPanel bottomButtons(JPanel panel)
    	{
    		submitBtn = new JButton("Submit");
    		cancelBtn= new JButton("Cancel");
    		previewBtn= new JButton("Preview");
     
    		//panel = new JPanel();
    		panel.setLayout(new FlowLayout());
    		panel.add(submitBtn);
    		panel.add(cancelBtn);
    		panel.add(previewBtn,"wrap");
     
    		return panel;
     
    	}
     
    	JPanel textBoxes(JPanel panel)
    	{
    		nameLbl = new JLabel("Name: ");
    		priceLbl = new JLabel("Price: ");
    		locationLbl= new JLabel("Location: ");
     
    		nameBox = new JTextField(15);
    		priceBox= new JTextField(5);
    		locationBox= new JTextField(15);
     
    		panel.setLayout(new GridLayout(3,6));
     
    		panel.add(nameLbl);
    		panel.add(nameBox);
    		panel.add(priceLbl);
    		panel.add(priceBox);
    		panel.add(locationLbl);
    		panel.add(locationBox);
     
    		return panel;
    	}
     
    	JPanel descriptionPanel(JPanel panel)
    	{
    		descriptionBox = new JTextArea(10,30);
    		JScrollPane scrollPane = new JScrollPane(descriptionBox);
    		panel.setBackground(Color.GRAY);
    		panel.add(scrollPane);
     
    		return panel;
    	}
     
    	JPanel pictureArea(JPanel panel)
    	{
    		fileopen = new JFileChooser();
    		panel.add(fileopen);
     
    		return panel;
    	}
     
    	public String getName()
    	{
    		return nameBox.getText();
    	}
     
    	public String getAddress()
    	{
    		return locationBox.getText();
    	}
     
    	public String getPrice()
    	{
    		return priceBox.getText();
    	}
     
    	public String getTextArea()
    	{
    		return descriptionBox.getText();
    	}
     
    }

    package addItemBtn.Home.DataBase;
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.TextEvent;
    import java.awt.event.TextListener;
     
    import javax.swing.event.DocumentListener;
     
     
      class AddItemController 
    {
    	private AddItemModel model;
    	private AddItemView view;
     
    	protected AddItemController(AddItemModel model,AddItemView view)
    	{
    		this.model = model;
    		this.view = view;
     
    		//adding actionListeners for the AddItemClass
    		view.cancelBtn.addActionListener(new ActionListeners());
    		view.submitBtn.addActionListener(new ActionListeners());
    		view.previewBtn.addActionListener(new ActionListeners());
    		view.nameBox.addActionListener(new ActionListeners());
    		view.priceBox.addActionListener(new ActionListeners());
    		view.locationBox.addActionListener(new ActionListeners());
    		view.descriptionBox.getDocument().addDocumentListener((DocumentListener) new ActionListeners());
     
    		view.frame.setVisible(true);
    	}
     
    	class ActionListeners implements ActionListener, TextListener
    	{
    		//will be used to get strings from textBoxes
    		private String name, location,price,discription;
     
    		@Override
    		public void actionPerformed(ActionEvent e) 
    		{
    			try
    			{
    				if(e.getSource() == view.submitBtn)
    				{
    					System.out.println("submit Pressed");
     
    					model.setName(view.getName());
    					model.setLocation(view.getAddress());
    					model.setPrice(view.getPrice());
    					model.setDiscription(view.getTextArea());
     
    					name = model.getName();
    					location = model.getLocation();
    					price = model.getPrice();
    					discription = model.getDiscription();
     
    					System.out.print(name+ "\n"
    							          + price +"\n"
    							          +location + "\n"
    							          +discription+ "\n");
     
    				}
    				else if(e.getSource() == view.cancelBtn)
    				{
    					view.frame.dispose();
    					System.out.println("Cancel Pressed");
    				}
    				else if(e.getSource() == view.previewBtn)
    				{
    					System.out.println("Preview pressed");
    					model.setName(view.getName());
    					model.setLocation(view.getAddress());
    					model.setPrice(view.getPrice());
    					model.setDiscription(view.getTextArea());
     
    					name = model.getName();
    					location = model.getLocation();
    					price = model.getPrice();
    					discription = model.getDiscription();
    				}
    				else
    				{
    					System.out.println("else");
    				}
     
    			}catch(Exception ex)
    			{
    				System.out.println("There was an error "+e);
    			}
     
    		}
     
    		@Override
    		public void textValueChanged(TextEvent e) 
    		{
    			String text;
    			try
    			{
    				if(e.getSource() == view.descriptionBox)
    				{
    					text = view.descriptionBox.getText();
     
    					System.out.println(text);
    				}
    			}catch(Exception ex)
    			{	
    				System.out.println("There was an error text area "+ex);
    			}
     
    		}
     
     
     
    	}
     
    }

    package addItemBtn.Home.DataBase;
     
    import javax.swing.SwingUtilities;
     
    import mainMenu.Home.DataBase.StartUpMenu;
    import mainMenu.Home.DataBase.StartUpMenuController;
     
    public class AddMain 
    {
     
    	public static void main(String args[])
    	{
    		SwingUtilities.invokeLater(new Runnable()
    		{
    			public void run()
    			{
    				StartUpMenu menu = new StartUpMenu();
    				new StartUpMenuController(menu);
     
    				AddItemView view = new AddItemView();
    				AddItemModel model = new AddItemModel();
     
    				new AddItemController(model,view);
     
    			}
    		});
     
    	}
     
    }

  8. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    It's appropriate that not all elements of your MVC design will be started on the EDT. If you've divided responsibility correctly, the Model wouldn't normally be run on the EDT, and your Controller may not be on the EDT. The View may be the only element of the project started on the EDT.

    Again, it's nearly impossible to give you specific corrections without having code we can run that demonstrates the problem.

    This illustrates the value of building many, MANY small, simple apps with which you can test minor variations, expand slowly and deliberatly, and learn from. You've created way too much code with too wide a footprint to understand the effect of simple changes. And as I noted early on with the "each button in its own package" design, we can't help you with specifics, because we can't (and don't want to) see it all.

  9. #8
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    I get what you are saying.... The errors are coming from this
    /view.descriptionBox.getDocument().addDocumentListener((DocumentListener) new ActionListeners());

    Will consult that API, I am sure I can figure it out.

    As far as the frame opening without anything being pressed has me lost.

    I only separated each MVC in different packages, not each button. Main menu has a package, and add item has a package. I wanted them to be as loosely coupled as possible. Look I am just trying to practice concepts that I think I understand.

    So I am clear you are saying I should not have put my controllers in main? They should be hidden correct? I hope I am not annoying you, I could sense some frustration from you and I am taking your advice. However I didn't understand what the big deal was with the way I as handling the packages.

  10. #9
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    I hope I am not annoying you, I could sense some frustration from you
    You're not annoying or frustrating. I am frustrated at not being able to give specific answers, only general, somewhat theoretical ones.
    are (you) saying I should not have put my controllers in main?
    I'm saying not all elements of the MVC architecture NEED to be run on the EDT, and some shouldn't be. An example of an element that shouldn't be run on the EDT is one that creates other threads to accomplish its function. Another example is one that uses a while( true ) loop for some reason.
    [QUOTE]So I am clear you are saying I should not have put my controllers in main?QUOTE]
    The main() method doesn't have to be where the EDT is created. The Controller could start the EDT and run the View on it. The Model might be started on the main thread - the same thread on which the Controller is run - or it might run on its own thread created by the Controller. There are as many variations as you have the imagination to imagine, but there is likely an optimum variation to do the job.
    They should be hidden correct?
    I don't understand what you mean by hidden. It seems inappropriate, but you may mean something else by it.

  11. #10
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    Ok got it working but I am not sure how I feel about it. This is the menu controller class. When the addItem is pressed it does as expected. What do you think? Do you find it confusing?
    package mainMenu.Home.DataBase;
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
     
     
    import addItemBtn.Home.DataBase.AddItemController;
    import addItemBtn.Home.DataBase.AddItemModel;
    import addItemBtn.Home.DataBase.AddItemView;
     
    public class StartUpMenuController 
    {
    	StartUpMenu menu;
     
    	public StartUpMenuController(StartUpMenu menu)
    	{
    		this.menu = menu;
     
    		menu.closeBtn.addActionListener(new AddListeners());
    		menu.reportsBtn.addActionListener(new AddListeners());
    		menu.findItemBtn.addActionListener(new AddListeners());
    		menu.addBtn.addActionListener(new AddListeners());
    	}
     
     
    	class AddListeners implements ActionListener
    	{
     
    		public void actionPerformed(ActionEvent e) 
    		{
    			try
    			{
    			if(e.getSource()==menu.closeBtn)
    			{
    				menu.frame.dispose();
    			}
    			else if(e.getSource()==menu.addBtn)
    			{
    				AddItemView view = new AddItemView();
    				AddItemModel model = new AddItemModel();
     
    				new AddItemController(model,view);
    			}
    			else if(e.getSource()==menu.reportsBtn)
    			{
     
    			}
    			else if(e.getSource()==menu.reportsBtn)
    			{
     
    			}
     
    			}catch(Exception ex)
    			{
    				System.out.println("There was an error "+e);
    			}
     
    		}
     
    	}
     
     
    }
     
    the main method just looks like this now
    [code=java]
    public static void main(String args[])
    	{
    		SwingUtilities.invokeLater(new Runnable()
    		{
    			public void run()
    			{
    				StartUpMenu menu = new StartUpMenu();
    				new StartUpMenuController(menu);
     
    			}
    		});
     
    	}

    [/code]

  12. #11
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    Confusing? No, it is representative of an early or first MVC design effort. Some comments in the code would be nice. A week from now, you won't be sure why you've written it the way you have, but comments would help remind you.

    Write 10 - 20 more MVC designs. The ubiquitous calculator, board games and multiplayer client-server board games are all good exercises. And then when you're confident in your interpretation of MVC, I'd suggest you try adding variations to them, like exploring how to use Observer/Observable or EventBus as event communication paths or managers.

  13. #12
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    I think you are right. I am trying to make a home database and I keep hitting road blocks. My low coupling attempted is starting to foil.
    This is in my StartUpMenu class
    //this is handled in AddItemController
    	public void handleQuery(String query) throws SQLException
    	{
    		Statement stmt = conn.createStatement();
    		ResultSet rs = stmt.executeQuery(query);
    	}
    this class connects to the database and creates the user interface of the start up page.

    I ten call it:
    if(e.getSource() == view.submitBtn)
    				{
    					System.out.println("submit Pressed");
     
    					model.setName(view.getName());
    					model.setLocation(view.getAddress());
    					model.setPrice(view.getPrice());
    					model.setDiscription(view.getTextArea());
     
    					name = model.getName();
    					location = model.getLocation();
    					price = model.getPrice();
    					discription = model.getDiscription();
     
    					String query ="INSERT INTO info (name,price,discription)"
    							+ "VALUES("+name+" "+price+" "+discription+");";
     
    					menu.handleQuery(query);

    and get a beautiful error:
    There was an error java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Submit,when=1411735250308,modifiers=Button1] on javax.swing.JButton[,337,5,88x29,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Dynamic@72a15a1a,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=2,bottom=0,right=2],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Submit,defaultCapable=true]

    I am debating on throwing this project in the trash and moving on to something else. I seem to be very bad at this.

    --- Update ---

    Observer/Observable or EventBus as event communication paths or managers.
    Thank you

  14. #13
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Frozen application buttons will not work

    No, you're not very bad at programming, but you're not great at creating an appropriate lesson plan to teach yourself how to be a good programmer.

    You're exhibiting the same frustration and sense of failure that I've seen over and over in the 5 or so years I've been a student while trying to help others. That point is typically achieved by reaching too far to do something the 'tutor/student' finds interesting and a goal worth working towards, usually a marketable product or game. Unfortunately, learning programming basics is an essential step that isn't always interesting and rarely results in projects you'll want to put on the refrigerator for all to see. It's often drudgery, boring, and just plain hard work fueled by the excitement one has for the topic and the desire to learn it well (plus pizza, coffee, 'Dew, and other stimulants).

    I can't recommend a good book for Swing/MVC, because I haven't seen one, so you're going to have to become better at defining your self study topics and goals. Search the 'net for, find, and complete all of the Swing MVC tutorials you can find. Do the simple ones first; save the harder ones for later. Some of them will suck, some of them will be okay, one or two might actually be good, but none of them will result in a product you'll want to share with anyone. You'll mold clay into lots of ashtrays. Few will mention the EDT or use it correctly, so you'll have to study that as a separate topic and try using it different ways. By the time you do 10 - 20 of the tutorials, you'll have a much better understanding of Java, OOP, MVC, Swing, and the EDT, and you'll feel like you understand those topics. Then look back at what you've been working on the past few weeks to see how far you've come.

    Give yourself reasonable time to do what I've described. Be patient, set reasonable goals, study hard, learn the basics well, and practice, practice, practice.

  15. #14
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Frozen application buttons will not work

    You are a good mentor.... Will follow the above guidance...

    Have you heard of this book:

    http://www.amazon.com/dp/0596007124/...?tag=nethta-20

Similar Threads

  1. [SOLVED] My fleet of squares doesnt work (simple high school work)
    By macko939 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 20th, 2014, 02:56 PM
  2. maven Application dosen't work , error: Servlet.init() for servlet
    By vector_ever in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 24th, 2013, 04:12 PM
  3. [SOLVED] Password Application I'm Coding Won't Work
    By Liikeaturtle in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2012, 05:43 PM
  4. My buttons will not work
    By ITStudent02 in forum What's Wrong With My Code?
    Replies: 21
    Last Post: June 29th, 2011, 03:36 PM
  5. Out of memory work around for a java application (please help!)
    By javameanslife in forum Java Theory & Questions
    Replies: 5
    Last Post: January 22nd, 2010, 04:27 AM