Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Add JScrollPane to ShowMessageDialog

setpreferredsize

  • Please log in to reply
2 replies to this topic

#1 Animus

Animus

    CC Regular

  • Member
  • PipPipPip
  • 26 posts

Posted 05 March 2012 - 05:55 PM

StringBuilder builder = new StringBuilder();
    for(int z = 0; z < list.length; z++){

        builder.append(  "Student name" + list[z].name.First + " " + list[z].name.Last +"\n"+"column"+list[z].chairLocation.Column + "row"
                +list[z].chairLocation.Row+ "\n");
    }
JScrollPane scrollPane = new JScrollPane(new JLabel(s));
        scrollPane.setPreferredSize(new Dimension(200,100));
        Object message = scrollPane;
    JOptionPane.showMessageDialog(null,scrollPane,builder.toString());<---ERROR HERE

am i doing this right?
im trying to print out a list with JOptionpane but its too long and i wanna add theat Scrollbar.
i dont now how to do it. dont know the code.
  • 0

#2 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 05 March 2012 - 07:58 PM

Could you just use a JTextArea instead?
How to Use Text Areas (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
  • 0

#3 Animus

Animus

    CC Regular

  • Member
  • PipPipPip
  • 26 posts

Posted 05 March 2012 - 11:12 PM

0_0
JTextArea nameTextArea = new JTextArea(10, 20);
for (int b=0; b<list.length; b++){
    for (String q : list[b].name.First) {
    nameTextArea.append(s);
    nameTextArea.append("\n");
}

   
}
tried this. says its not applicable to expression type.
the heck O_o

---------- Post added at 05:12 PM ---------- Previous post was at 04:55 PM ----------

what the minute. im using this as output. is it really ok to use a JtextArea?
  • 0





Also tagged with one or more of these keywords: setpreferredsize

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download