Head First Java, 2nd Edition

Author: Kathy Sierra, Bert Bates
4.3
All Stack Overflow 26
This Year Reddit 42
This Month Stack Overflow 5

Comments

by anonymous   2019-07-21

If you don't have any object-oriented programming background, I suggest you should start out by getting familiar with basic OO concept. I recommend reading this book "Head First Java" http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208 and the official java tutorial - http://java.sun.com/docs/books/tutorial/reallybigindex.html

After you get the idea and basic concept on object-oriented programming and java. You can move yourself to use any technology including Oracle technology stack and other OO language such as python and C#.

by anonymous   2019-07-21

If the buffer is full, all strings that is buffered on it, they will be saved onto the disk. Buffers is used for avoiding from Big Deals! and overhead.

In BufferedWriter class that is placed in java libs, there is a one line like:

private static int defaultCharBufferSize = 8192;

If you do want to send data before the buffer is full, you do have control. Just Flush It. Calls to writer.flush() say, "send whatever's in the buffer, now!

reference book: https://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208

pages:453

by anonymous   2019-07-21

Here's an excellent tutorial that might get you started in the right direction:

http://www.myeclipseide.com/documentation/quickstarts/webservices_rest/

Choice of database is relatively unimportant (at least for learning purposes).

If you don't already know Java, then you should definitely dedicate time to learning it. I'd recommend Headfirst Java as a good introduction:

http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208/

by anonymous   2019-07-21

Because type Agg is a more concrete type of Base. Type of a in your declaration is Base. What is in left side of declaration represents the type of an object. Actually a contains method getFields(), but because it is upcasted, the method is hidden in the type Base. I recommend you HeadFirstJava book. It helps you to clear out these concepts.

by passthejoe   2018-03-19

Is this a class that teaches Java?

If so, the two books I have that I think are really good are "Head First Java" https://toptalkedbooks.com/amzn/0596009208 and the new "Computer Science: An Interdisciplinary Approach" https://toptalkedbooks.com/amzn/0134076427

Also, Oracle has a great Java tutorial that is available free on the web and as PDFs and ebooks: https://docs.oracle.com/javase/tutorial/

by ImEasilyConfused   2018-03-19

From OP:

>The exact four books I read are:

>Learning Obj-C

>Learning Java

>iOS Programming: The Big Nerd Ranch Guide

>Android Programming: The Big Nerd Ranch Guide

>However, I would now recommend learning Swift instead of Obj-C. At the time when I was looking into iOS books, good books on Swift were few and far between.

From u/AlCapwn351 in regards to other sources to learn from:

>www.codeacademy.com is a great site for beginners (and it's free). It's very interactive. W3schools is good for learning stuff like JavaScript and HTML among other things.

>When you get stuck www.stackoverflow.com will be a lifesaver. Other than that, YouTube videos help and so do books. Oh and don't be afraid to google the shit out of anything and everything. I feel like an early programmers job is 90% google 10% coding.

>Edit:

>It's also good to look at other peoples code on GitHub so you can see how things work.

by ImEasilyConfused   2018-03-19

From OP:

>The exact four books I read are:

>Learning Obj-C

>Learning Java

>iOS Programming: The Big Nerd Ranch Guide

>Android Programming: The Big Nerd Ranch Guide

>However, I would now recommend learning Swift instead of Obj-C. At the time when I was looking into iOS books, good books on Swift were few and far between.

From u/AlCapwn351 in regards to other sources to learn from:

>www.codeacademy.com is a great site for beginners (and it's free). It's very interactive. W3schools is good for learning stuff like JavaScript and HTML among other things.

>When you get stuck www.stackoverflow.com will be a lifesaver. Other than that, YouTube videos help and so do books. Oh and don't be afraid to google the shit out of anything and everything. I feel like an early programmers job is 90% google 10% coding.

>Edit:

>It's also good to look at other peoples code on GitHub so you can see how things work.

by anonymous   2017-08-20

Your question is how to pass information from one JFrame to another, and this can be done as simply as having one class call a method of the other class. That you haven't done this, and that you've only posted a skeleton program, one with components but with no logic suggests to me that you are still very much a beginner Java programmer, and so my main suggestion is that first and foremost you strive to learn to code, and in particular learn about object oriented principles and how they relate to Java. Without these rudiments under your belt, we can give you code and pointers, but it won't help you much. I suggest that you go to the Java Tutorials and start there, but also that you get a decent book or two on the subject such as Bruce Eckel's Thinking in Java, and/or Head First Java.

As for your actual code I suggest that you not create classes that extend JFrame since that locks you into a JFrame, and again as per my comment above, your tool window should be a non-modal JDialog not a JFrame. If you gear your code towards creating JPanels, then you can place them into JFrames, JDialogs, other JPanels, etc... wherever needed, and so this gives you a lot more flexibility.

The main difficulty in the situation of your program is not passing information from one window to another, one object to another, really, but rather when to do so, since the program is event driven. Myself, I like to use PropertyChangeListeners for this, basically using an observer interface that is already part of the Swing GUI structure. For example in the code below I create two main JPanels, one is displayed within a JFrame, the other within a non-modal JDialog, and I pass button press information (the actionCommand String of the button) to the JTextArea in the main GUI via a PropertyChangeListener:

import java.awt.BorderLayout;
import java.awt.Dialog.ModalityType;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.*;

public class Foo3 {
    private static void createAndShowGui() {
        final MainPanel1 mainPanel1 = new MainPanel1();
        final ToolPanel1 toolPanel1 = new ToolPanel1();

        JFrame frame = new JFrame("Foo3");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(mainPanel1);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        JDialog dialog = new JDialog(frame, "Toolbar", ModalityType.MODELESS);
        dialog.add(toolPanel1);
        dialog.pack();
        dialog.setLocationByPlatform(true);
        dialog.setVisible(true);

        toolPanel1.addPropertyChangeListener(ToolPanel1.ACTION_COMMAND, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                mainPanel1.appendActionCommand((String) evt.getNewValue());
            }
        });
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGui();
            }
        });
    }
}

class MainPanel1 extends JPanel {
    private JTextArea actionCommandArea = new JTextArea(30, 50);
    private JScrollPane scrollPane = new JScrollPane(actionCommandArea);

    public MainPanel1() {
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        setLayout(new BorderLayout());
        add(scrollPane, BorderLayout.CENTER);
    }

    public void appendActionCommand(String text) {
        actionCommandArea.append(text + "\n");
    }
}

class ToolPanel1 extends JPanel {
    public static final String ACTION_COMMAND = "action command";
    public static final String[] BTN_TEXTS  = {
        "Select Element",
        "Insert Image",
        "Insert Text",
        "Insert Hyperlink",
        "Change Page Background",
        "Insert Textbox",
        "Insert Radio Button", 
        "Insert Checkbox",
        "Insert Horizontal Rule",
        "Insert Button",
        "Insert Drop-Down List",
        "Insert List",
        "Add Script"
    };
    private String actionCommand = "";

    public ToolPanel1() {
        int rows = 0; // variable number of rows
        int cols = 2; // 2 columns
        int hgap = 5;
        int vgap = hgap;
        setLayout(new GridLayout(rows, cols, hgap, vgap));
        setBorder(BorderFactory.createEmptyBorder(hgap, hgap, hgap, hgap));

        for (String btnText : BTN_TEXTS) {
            add(new JButton(new ButtonAction(btnText)));
        }
    }

    public String getActionCommand() {
        return actionCommand;
    }

    private class ButtonAction extends AbstractAction {
        public ButtonAction(String name) {
            super(name);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            String oldValue = "";
            String newValue = e.getActionCommand();
            actionCommand = newValue;
            ToolPanel1.this.firePropertyChange(ACTION_COMMAND, oldValue, newValue);
        }
    }
}

A more robust design would be to use a Model-View-Controller type design, but this is a bit more advanced, and you'll need to get some more code experience under your belt before using this, I think. also check out these links to similar questions/answers.

by anonymous   2017-08-20

In future you should post these sorts of questions on the Programmers Q&A site.

If you want to learn best practices your best bet is to learn from multiple sources. That way you see the content from multiple perspectives and that is the best way to gain your own perspective on the subject. You sound pretty keen on videos although to be honest I wouldn't recommend them. You can learn much more from written articles, tutorials and books like Head First Java and the official Java Tutorial etc. with examples and exercises. You cannot learn programming without doing it.

by anonymous   2017-08-20

A few things stood out to me as your goals:

  1. You want formal training on how to program (this is independent of a language)
  2. You want to learn how to develop apps for a mobile device
  3. Your boss is on board with goals 1 and 2, but wants to see the best return on her investment.

I think the easiest way for you to meet all of these goals is to start learning how to program with Java. Java is often used in introductory computer science courses, so you should be able to learn the language and programming concepts in parallel. Once you have that foundation, you will be able to start learning Android development, since Android applications are built with the Java language.

You can start off by reading some of the resources from Oracle: http://download.oracle.com/javase/tutorial/java/concepts/index.html

And there are plenty of good intro books too:

There is nothing wrong with starting off by learning Python. Once you have a good grasp of programming fundamentals, you can learn new languages relatively quickly. However, from your boss's perspective, there is more value in paying for you to learn a language for mobile development and programming at the same time.

by Fortyrunner   2017-08-20

You really need a copy of Head First Java

by shuman1981   2017-08-19

https://toptalkedbooks.com/amzn/0596009208

Yeah, it was a good quick read (one week at the beach) and the exercises were not mundane. It's great for visual learners as well if you're into that sort of thing.

by minotaurohomunculus   2017-08-19

Head First Java. It's the easiest book on Java to read that I've found.

https://toptalkedbooks.com/amzn/0596009208

by AlphaOmegaTubbster   2017-08-19

Here are a few helpful resources to help you out.

Firstly, you probably need a beginners grasp on Java. For that, I would highly recommend: https://toptalkedbooks.com/amzn/0596009208

You do not need to go through the entire book, But it would be more helpful to you.

Secondly, I highly recommend this android book: https://toptalkedbooks.com/amzn/0321804333

They literally walk you step-by-step.

However, if you do not feel you can teach yourself programming there is always this option: http://appinventor.mit.edu/explore/ I haven't personally messed around with it but it doesn't require any programming experience.

Here is a free online class that starts tomorrow if you have the time. https://www.coursera.org/course/androidpart1

or this one that is already finished but you can still access the material. https://www.coursera.org/course/androidapps101

You could also go at your own pace through it.

Here is also a udemy course that also teaches you java. I would get it now before the price goes back up to 200 bucks. https://www.udemy.com/android-lollipop-complete-development-course/?dtcode=hfFhrtG2ans8

I haven't personally taken it, but a friend of mine has and he loves it.

Basically, just start reading and learning. The big nerd ranch book that I listed has some really great beginner apps that teach you the basics.

Persistence is the key. Don't give up, fight through the pain. Google like crazy.It's worth it, trust me.