Vector and Jtree 4Duke

hi
i am having poblem with my jtree as i am not able to show the object in my vector as a different node
{each object is node of my tree}
unfortunately they all appear flat in the root, and in sequence{as one node} ??
i have done everything but still no answer??
thanks in advance for any solution
public class Gui extends JFrame
{  Vector root = new Vector();
public JTree theTree ;
public SERGui( )
System.out.println(root.size());//root vector is empty
roott = new DefaultMutableTreeNode (root);
model = new DefaultTreeModel (roott) ;
theTree = new JTree (model);      
public Vector addOne(String newString)
if (!root.contains(getQuery))
           root.add(newString);
model.reload();
// //updateTree(); i also try this method whiich does not work
return root;
public void updateTree(){
DefaultMutableTreeNode v = (DefaultMutableTreeNode)theTree.getModel().getRoot();
for(int i=0;i<root.size();i++)
               DefaultMutableTreeNode node = (DefaultMutableTreeNode)root.elementAt(i);
               roott.add(node);
((DefaultTreeModel)theTree.getModel()).reload(v);
//DefaultMutableTreeNode node = null;
print_vector(root);
  //root.clear();
     }and my other class
where i call this methos is as follow
Class Search()
public void countWord(String newString)
{Gui.addOne(newString);
}}

You are passing a Vector into the constructor of the DefaultMutableTreeNode to create the root of your tree. The DefaultMutableTreeNode will use this object's string representation (by calling toString on whatever object you pass in its constructor) as the name of the tree node. So basically you will see the entire contents of the vector as the name of your root node.
You need to traverse your vector, and use each element to create a DefaultMutableTreeNode and add it to your root node.
here is the modified code
public class Gui extends JFrame {
private Vector rootVector = new Vector();
private JTree theTree;
private DefaultMutableTreeNode rootNode;
private DefaultTreeModel model;
public Gui() {
System.out.println(rootVector.size());
//root vector is empty
rootNode = new DefaultMutableTreeNode("Root");
model = new DefaultTreeModel(rootNode);
theTree = new JTree(model);
public Vector addOne(String newString) {
if (!rootVector.contains(newString)) {
rootVector.add(newString);
updateTree();
return rootVector;
public void updateTree() {
rootNode.removeAllChildren();
for (int i = 0; i < rootVector.size(); i++) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(
rootVector.elementAt(i));
rootNode.add(node);
((DefaultTreeModel) theTree.getModel()).reload(rootNode);
Hemant Mahidhara

Similar Messages

  • Difference  between null vector and empty Vector

    What is the diffrence between null vector and empty vector.

    null vector means the JVM doesn't allocate memory.It doesn't exist
    in memory. NO instance!
    empty vector means the JVM allocated memory.It exists in memory.
    it's a instance than is accessabel.But only have on elements.
    GL&HF.

  • Please help, 2D Array of Vectors and Incompatible types :(

    I have a 2D array of vectors called nodeLocations but when I try and access the vector inside I get a compile error.
    My code is something like this:
    nodeLocations[j].addElement(noArc)
    My editor picks up that its a Vector and shows me addElement as an acceptable entry to put after the "." yet the compiler says:
    "addElement(java.lang.Object) in java.util.Vector cannot be applied to (int)"
    Can someone please help?
    Thank you in advance.
    also a related problem:
    I get inconvertible types (says int required) when I try and get an element from a vector stored in a 2D Array. I know that it comes out as an object and so should be cast but it does not seem to work. My code is as follows:
    else if (((int)(nodeLocations[nodeNumber][adjNodeNumber].elementAt(0))) != distance)
    I would appreciate any help anyone can give.
    Similar errors to the above two happen when
    I try a push with a Stack in a vector.
    I try to get something out of the stack inside the vector.

    The Vector class's addElement() method requires an Object parameter. It appears that you're trying to add an int to the Vector. You'll need to create an Integer object and place that into the vector (see sample below) or use the pre-release version of JDK 1.5 which provides autoboxing capabilities.
    int z = 5;
    Integer x = new Integer(z);
    nodeLocations[j].addElement(x);

  • Returning vector and null pointer exception

    Hi, I'm writing a mailing program which so far is working fine, but I have now run into a problem which is completely throwing me. My mailer needs to be able to load multiple attachments - and also to be able to deal with an HTML text which contains multiple images. In each case, what I'm trying to do is to put the attachments and the images into separate vectors and process them through an iterator. The logic, at least, I hope is correct.
    I can get my code to compile but it keeps throwing a null pointer exception a runtime. Somehow, I just can't get it to pass the vector from one part of the code to another.
    Can anyone help me? I've tried various things, none of which seem to work. My code, as it stands, is posted in a skeletal form below.
    Thanks for any ideas:
    public class MailSender
       // declare various variables, including:   
         Vector embeddedImages;
         String HTMLString;
        public MailSender()
            setup();
        private void setup()
         //this part of the program sets up the various parts of the mail  (to, from, body etc)    
          HTMLString = "blah blah blah";  //sample HTMLString   
           Vector embeddedImages = null; //is this correct?
            if (HTMLString.length() > 0)
                processHTMLString(HTMLString);
         private String procesHTMLString(String htmlText)
            Vector embeddedImages = new Vector(); // I construct my vector here, is this correct?
            //Here I process the HTML string to extract the images
            //get the file path of the image and pass it to the vector
            addToVector(imageFile);
            return HTMLString;
        public Vector addToVector(String imageFile)
            embeddedImages.add(imageFile);
            return embeddedImages;
        private void send()
            //this part does the sending of the mail
            //at some part in this method I need to get at the contents of the vector:
            //but this part isn't working, I keep getting a null pointer exception
            Iterator singleImage = embeddedImages.iterator();
            while (singleImage.hasNext())
        public static void main(String[] args)
            MailSender ms = new MailSender();
            ms.send();
            System.out.println("MailSender is done ");
    }

    >>>>while they don't have a clue on how the language and/or programming in general works.
    Thank you, salpeter, for your esteemed estimation of my programming competence.
    >>>What I'm wondering is: how come people always start building applications... blah blah
    The reason being, is that it happens to be my job.
    OK, I'm perhaps slower than most and there are things I don't yet understand but I get paid probably about a tenth of what you do (and maybe even less). I regard it as a kind of apprenticeship which, after a past life having spent twenty years packing crates in a warehouse, is worth the sacrifice. Six months ago I'd never written a line of code in my life and everything I've learned since has been from books, the good people in these forums, and a lot of patient trial and error. It's hard work, but I'll get there.
    I say this, only as encouragement to anyone else who is trying to learn java and hasn't had the benefit of IT training at school and a four year computing course at university paid for by the parents, and for whom the prohibitive cost (in both time and money) of most java courses would never allow them to get on this ladder.
    Excuse my somewhat acerbic posting, but comments such as yours tend to provoke...
    Thank you EverNewJoy for explaining this to me. I haven't had time yet to try it out, but at least the concept now is clear to me.

  • Newbie question about using vectors and arrays

    I'm fairly new to JME development and java in general. I need some help in regards to Vectors and 1 dimensional arrays. I'm developing a blackberry midlet and am saving the queried info i pull back from my server side application with each record saved into the array and subsequently each array saved as an element in the vector, thereby creating a 2D "array".
    However I'm having a problem accessing the elements in the array. Here is a sample of what I mean and where I get stuck:
    Vector _dataTable = new Vector(1, 1);
    String[] r1 = {"a", "b", "c", "d"};
    String[] r2 = {"1", "2", "3", "4"};
    _dataTable.addElement(r1);
    _dataTable.addElement(r2);
    Object temp = _dataTable.elementAt(0); //Save the element as an new object for useNow how do I access the particular indexes of the element of the temp object? Do i need to caste it to an array? Is there another more efficient/easier way I should be storing my data? Any help would be great!
    Edited by: Sotnem2k1 on Apr 1, 2008 7:50 AM
    Edited by: Sotnem2k1 on Apr 1, 2008 7:51 AM

    Thanks for the feedback newark. I have this scenario below:
    // Class for my 1D array
    public class OneRecord {
        private String[] elementData = new String[4];
        public OneRecord() {   
            elementData[0] = null;
            elementData[1] = null;
            elementData[2] = null;
            elementData[3] = null;
        public OneRecord(String v1, String v2, String v3, String v4) {   
            elementData[0] = v1;
            elementData[1] = v2;
            elementData[2] = v3;
            elementData[3] = v4;
        public void setElement(int index, String Data) {
            elementData[index] = Data;
        public String getElement(int index) {
            return elementData[index];
    } Then in my main app I have:
    Vector _dataTable = new Vector(1, 1);
    OneRecord currRecord = new OneRecord("a", "b", "c", "d");
    _dataTable.addElement(currRecord);
    OneRecord temp = (OneRecord)_dataTable.elementAt(1);
    System.out.println(temp.getElement(0)); Are there more efficient data structures out there to save queried data from a server side app? Like I said, i'm still trying to learn the most efficient techniques of coding...esp for the Blackberry. Any suggestions would be great!

  • How to store data from textfile to vector and delete a selected row.

    Can someone teach me how to store data from textfile to vector and delete a selected row. And after deleting, i want to write the changes in my textfile.
    Do someone has an idea? :)

    nemesisjava wrote:
    Can someone teach me how to store data from textfile to vector and delete a selected row. And after deleting, i want to write the changes in my textfile.
    Do someone has an idea? :)What's the problem? What have you done so far? What failed?
    What you described should be pretty easy to do.

  • Vector and my object??

    hi all,
    I am reading a binary file, then creating the object and adding that object in my vector. How can i get it back according to its id? let is say i added all the customers read from file and now i want to get customer 3?
    int thisId=dis.readInt();
    String thisName=dis.readUTF();
    double thisBalance=dis.readDouble();
    Customer cus=new Customer(thisName,thisId,thisBalance);
    cusList.add(cus);
    abdul

    Best possible way is to use Hashtable and put customerid as key and Customer object
    as value.
    Modify your code with,
    Customer cus=new Customer(thisName,thisId,thisBalance);
    some-hashtable-object.put(thisId,cus);
    now if you want to take particular Customer
    use
    Customer c = (Customer)some-hashtable-object.get(any customerid);
    Now if you don't want to use Hashtable and continue with Vector then you have to iterate the,
    Vector and whether object has id 3 .
    like
    for(int i=0;i<Vectorobject.size();i++){
    Customer c = (Customer) Vectorobject.get(i);
    id = c.getCustomerId() // or any method you have to get id;
    // check it....
    But i think Hashtable is the better way to use here.
    I think you understand what i want to say .
    Tarak.

  • Challeging Traversal of Vector and Array

    Hi there ! I would like to render the values of this Vector and Array . How do I print it out to the browser ?
    try
    ResultSet rset = stmt.executeQuery(myQuery);
    System.out.println(" Finish Execute Query !!! ");
    /* Array Contruction */
    int numColumns = rset.getMetaData().getColumnCount();
    while (rset.next())
    aRow = new String[numColumns];
    for (int i=0; i < numColumns; i++){
    aRow[i] = rset.getString(i+1);
    allRows.addElement(aRow);
    return allRows;
    }

    Hi there !
    Thanks for your help but I managed to get it working. For references purposes, I`ll post it here.
    My problem now is this :-
    How can I issue another SQL statement and store the results in the same array?
    Pls note . One Sql per table so, that`s the issue ?
    Can someone help with a followup code ?
    try
    ResultSet rset = stmt.executeQuery(myQuery);
    System.out.println(" Finish Execute Query !!! ");
    /* Array Contruction */
    int numColumns = rset.getMetaData().getColumnCount();
    while(rset.next())
    // for every record instance aRow
    aRow = new String[numColumns];
    // store in aRow the values of the record
    for(int i=0;i<numColumns;i++)
    aRow[i] = rset.getString(i+1);
    //When aRow is full store it in the vector
    allRows.addElement(aRow);
    // when the rset finished print all the Vector
    for(int i=0;i<allRows.size();i++)
    // get returns a String[]
    String[] tmpRow = (String[])allRows.get(i);
    for(int j=0;j<tmpRow.length;j++)
    out.print(tmpRow[j]+" ");
    out.println("");
    }

  • How to use lists or vectors and things?

    Hello !
    I started to code with java about year ago and the first jdk that i used was 1.5.0. Since 1.5.0, generics have been supported and I think that linkedlists, arraylists and whatever have been made differently. I can't use these generics in my mobile applications so I don't how to use vectors and stacks etc, different way in my applications.
    When I used (for instance) arrayists with jdk 1.5.0 or 6, I did it like this:
    ArrayList <AL> al = new ArrayList <AL>();
    void something(){
    for(AL a : al){
    //do something
    But how do I do these with mobile things, and whats the most similar thing compared to linkedlist and arraylist, vector? I really don't know how to add and remove things with these. If someone can point a good tutorial or thread, I would really appreciate that.
    Edited by: RandomNero, for a third time in a row, on Dec 13, 2007 1:42 PM

    Hello,
    there's no typed vectors on J2ME,
    please check out this link : http://java.sun.com/javame/reference/apis/jsr118/java/util/Vector.html
    to know more about J2ME vectors.

  • Easy way to clone a Vector and its Content?

    I have a Vector containing String Arrays. I would like to clone the vector an all it's content.
    Just cloning the vector doesn't work, because just the vector gets cloned whereas the references to the StringArrays in the vector stay the same.
    So i guess i have to clone all the StringArrays too? This would be a very "expensive" process, so i'd like to ask first, if there is another methode to clone a vector and it's content?
    Thanks for your help!

    No. Clone gives you a shallow copy. What you want is a deep copy. However, since Strings are immutable, you only need to deeply copy the string arrays, not the strings themselves. If you were working with mutable objects, this would not be the case and you would need to copy the items in the array as well as the array itself.

  • How can I loop through a Vector and compare

    I'm working on a school project that is a quiz server. Instructors could telnet into the app and create quizes and then users can take them. I have it so it can set up new quizes so far. Right now I'm working on it so the user can choose a quiz and take the test. Since it requires proper user handling I have it so I display the quiz ID and quiz Name. The user would need to enter the quiz ID to take it. I have it that as it displays the ID's it enters them into a Vector. Then I do a loop through all elements until I get one that equals the user selection. I'm having problems with it though. Here's some code:
    do
    quizCheck = false;
    for (int i=0;quizReference.size();i++)
    if (selectionInt==quizReference.elementAt(i))
    quizCheck=true;
    }while (quizCheck==false);
    It's giving me a Error #300:method==(int,java,lang.Object)not found in class testproject.TestProject on the if line. Is there a way to handle this scenario. Also is there a better way?

    Hi,
    elementAt(...) returns an Object - of what type is your selectionInt? - guess, it is a primitve int value, not an Object.
    You can find it easier - say, you have Integer values in that Vector - and selectionInt is an int value - now you can find it using
    int p = quizReference.indexOf(new Integer(selectionInt));
    p is either -1 (if not found) or the index of the first found element, with the same int value as selectionInt.
    Hope, this helps
    greetings Marsian

  • Problem when adding java objects in a vector and passing thru web service

    Hi! I'm getting this error when I try to add a java object I created into a vector and passing it through a web service: java.lang.IllegalArgumentException: No Serializer found to serialize a 'testObj' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'
    This does not happen when I simply add strings or Integer objects into the vector. What am I missing?
    Thanks.

    just chek this
    http://forum.java.sun.com/thread.jspa?threadID=501189&messageID=2370914
    Edited by: garava on Jul 16, 2008 1:13 PM.
    It would be great if you could paste the wsdl part for that vector and just have a look for the complex typr cntent
    like for HashMap we have the following mapping
    <complexType name="HashMap">
      <sequence>
        <element name="item" minOccurs="0" maxOccurs="unbounded">
          <complexType>
            <sequence>
              <element name="key" type="anyType" />
              <element name="value" type="anyType" />
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>Since in Value it should again contain a mapping for the Object which you are trying to pass then only an appropriate serializer and deserilaizer would get generated. Hope this answers your query. For refernece
    http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2
    [http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2|For refernce tutorial]
    Thanks,
    Avadhoot Sawant.
    Edited by: garava on Jul 16, 2008 1:16 PM

  • Consume MouseEvent to prevent JList and JTree from receiving?!

    I have a JTree and a JList where I have made the CellRenderer so that it has a "button" area. When this button is clicked, I want something to happen. This I have achieved just nicely with a MouseListener, as per suggestion from JavaDocs.
    However, the problem is that when a click is deemed to be within the "button", I do not want the tree or list to process it anymore. But doing e.consume(), both on mousePressed or mouseClicked (though it obviously is pressed the JList and JTree themselves listen to) doesn't do jack.
    How can I achieve this functionality?

    da.futt wrote:
    stolsvik wrote:
    Okay, I managed with a hack: It is the order of listeners that's the problem: The ListUI's MouseListener is installed before mine, and hence will get the MouseEvent before me, so it has already processed it when I get it, and hence consuming it makes no difference. No. Normally, listeners are notified latest-registered to earliest-registered. I don't remember seeing an exception to that rule in the core API. well, you are both right (or wrong ;-) - the rule is: the order of listener notification is undefined, it's an implementation detail which listeners must not rely on. "Anecdotical" experience is that AWTListeners are notified first-registered-first-served, while listeners to swing specific events are notified last-registered-first-served. Below is a snippet (formulated in context of SwingX convenience classes, too lazy ...) showing that difference.
    The latter probably stems from hefty c&p of notification by walking the EventListenerList: the earliest code was implemented very near the beginning of Swing when every little drop of assumed performance optimization was squeezed, such as walking from back to front. Using EventListenerList involves lots of code duplication ... so lazy devs as we all are, simply c&p'ed that loop and just changed the concrete event type and method name. More recently, as in the we-use-all-those-nifty-cool-language-features ;-) I've seen more usage of forEach loops (f.i. in beansbinding) so notification is back to first-in-first-served :-)
    Bottom line: don't rely on any sequence - if needed, use an eventBus (or proxy or however it's called) and define the order there. Darryl's suggestion is as close as we can get in Swing (as it's not supported) but not entirely safe: there's no way to get notified when listeners are added/removed and no hook where to plug-in such a bus into the ui-delegate where it would belong.
    Cheers
    Jeanette
    // output
    02.10.2009 14:21:57 org.jdesktop.swingx.event.EventOrderCheck$1 mousePressed
    INFO: first added mouseListener
    02.10.2009 14:21:57 org.jdesktop.swingx.event.EventOrderCheck$2 mousePressed
    INFO: second added mouseListener
    02.10.2009 14:21:58 org.jdesktop.swingx.event.EventOrderCheck$4 valueChanged
    INFO: second added listSelectionListener
    02.10.2009 14:21:58 org.jdesktop.swingx.event.EventOrderCheck$3 valueChanged
    INFO: first added listSelectionListener
    // produced by
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.logging.Logger;
    import javax.swing.JList;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import org.jdesktop.swingx.InteractiveTestCase;
    import org.jdesktop.test.AncientSwingTeam;
    public class EventOrderCheck extends InteractiveTestCase {
        public void interactiveOrderAWTEvent() {
            JList list = new JList(AncientSwingTeam.createNamedColorListModel());
            MouseListener first = new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    LOG.info("first added mouseListener");
            MouseListener second = new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    LOG.info("second added mouseListener");
            list.addMouseListener(first);
            list.addMouseListener(second);
            ListSelectionListener firstSelection = new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    if (e.getValueIsAdjusting()) return;
                    LOG.info("first added listSelectionListener");
            ListSelectionListener secondSelection = new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    if (e.getValueIsAdjusting()) return;
                    LOG.info("second added listSelectionListener");
            list.addListSelectionListener(firstSelection);
            list.addListSelectionListener(secondSelection);
            showWithScrollingInFrame(list, "event order");
        @SuppressWarnings("unused")
        private static final Logger LOG = Logger.getLogger(EventOrderCheck.class
                .getName());
        public static void main(String[] args) {
            EventOrderCheck test = new EventOrderCheck();
            try {
                test.runInteractiveTests();
            } catch (Exception e) {
                e.printStackTrace();
    }

  • Vector and raster within one unflattened PS file?

    Is there a way to save and submit a Photoshop file containing both vestor and raster art-unflattened-so that it stays vector and raster when the client opens it? The issue is: client wants to be able to zoom in on the whole file and not lose sharpness of the type. Seems like a reasonable request. So the finished, unflattened file needs to include both types of layers. Someone suggested using Indesign. Could that work? Didn't Deneba Canvas used to work that way? Can someone point me to a Knowledgebase article that covers it? I posed this question in the Illustrator Forum as well.

    Thanks, Semaphoric. I lost track of saving as a .PSD file.I usually save as TIFF.  That should work.

  • Vector and PNG jagged lines

    Hi!
    I've created a vectorized logo using CorelDraw X7. As my workflow consists of Adobe products, as Lightroom, Photoshop and InDesign, I though it would be convenient to integrate Illustrator in my workflow for better file handling. Then I've faced my first problem: export from Corel to Illustrator. As Corel allowed me to export in .AI file format, that was the best quick solution. But when I opened the file inside Illustrator, it wasn't good looking, and I realized it needed some adjustments. To be honest, the issue was specifically with a line stroke within my logo, noticeably jagged. I've already checked if I was in Pixel Preview Mode, as well as the anti-aliasing options, pixel grid alignment and the document resolution [I've done a extensive search about the issue before posting here, but haven't find anything really helpful]. I tried to redesign the logo using Illustrator, but the ******* line keeps frustrating me.
    I know that I'm working with vectors and that shouldn't be happening, even taking into consideration that the monitor inevitably shows images in pixels. That said, if I zoom in a lot, I can see perfect lines, but zoomed at 100 or 200%, the jagged lines are there. I though that it was just a preview issue from Illustrator that wouldn't affect the output file, so I exported it in PNG, which is the output file I mostly use in those cases, but the issue remained. The line stroke I'm talking about is a fine line with variable width at both tips [wider in the middle and tapering at the ends]. This tapering is what causes the problem, creating a jagged effect from the middle section through the ends. What's curious about it is that the same line, when the original file is opened in Corel, is showed smooth and perfect, in vector lines or after PNG export.
    As it wasn't enough, ironically, if I create the same line in Photoshop and paste it into Illustrator [which recognizes it as a raster image], the output is exactly what I expected when exported to PNG [from Illustrator] and with a far better preview inside Illustrator, though still a bit jagged with 100% zoom. But as I plan to work with vector lines up to the moment of exporting files, a rasterized object wasn't part of my plans...
    I'll be very glad if someone is able to help me. I'm working on CC 2014.
    Follows a link to the open files from Corel and Illustrator. For comparison purposes, inside Illustrator file there are 3 versions of the line, being the first the original Corel vector, the middle one is the Photoshop raster, and the third is the one created inside Illustrator using elipse tool.
    Dropbox - Logo.rar
    PS.: English isn't my native language, so my apologies for some mistakes I may have commited

    Even when I create the same line using Illustrator tools? I though I'd have no problem creating a fine line with variable width.
    Here goes the print screens of what you asked me. The first one is the info of the line created on Corel; the other is the one created on Illustrator:

Maybe you are looking for

  • Document and Element trick!Please give me hand

    hello there I have a question for ya What is the difference between Document and Element regarding XML If I have this Document r ; how I could convert it Element say e; and vice versa it is possible to say Document r; Element e = (Element) r; what ab

  • Get radio button list order

    I am making an online exam project and I am currently able to show choices for each question in random order. I want to control all currently open exam sessions so that each student gets a different order of choices during the time of the exam -- to

  • Problems With My Mail Received By Others

    I am using an eMac with 384MB of Ram and 28.67 GB of DIsk Space.I am using 10.3.9 OS which I just recently installed.The email account is Apple mail 1.3.11(v622/623). I send e-mails using Apple Mail and I have been told by several people that my emai

  • CS5 opening file from file server through explorer gets file not found error

    Hi There, Has anyone come across an issue with CS5 where they open an ai file through Windows Explorer and gets an error file not found after CS5 has started? Opening through CS5's file > open option does not produce the same error and seems to only

  • MacBook/MacBook Pro AC compatibility?

    Can MacBooks be charged safely and effectively with an AC adapter for a MacBook Pro?