Results 1 to 2 of 2
  1. #1
    SANDY_INDIA is offline Member
    Join Date
    Jul 2008
    Posts
    20
    Rep Power
    0

    Default Problem In Swing Components

    I have no. of problems related to Swing. If you have the solution do reply to me.

    MY problems are:
    1) JTABLE: I want to decide the no. of rows at runtime. Actually I need to show the database entries via Table. And these entries can be any no. So How I can Do this????

    2) JTABLE: Second problem with JTABLE is : whenever I write something on the Table Cells, It remains at the left most part of the cell. But I want , It should be at the Center(I try for "Center" but Its not working). More specific: I want my table to work Like the Tables in Ms EXCEL.

    3) JTEXTAREA: Whenever I write something, it continues in a single line until and unless I press enter button. Can't be possible that when Boundary encounters cursor automatically move to next line(Like MS WORD); (And SAME WITH JTEXTFIELD.)

    4) BUTTONGROUP: Its not working in JDK1.5. Any other alternative

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    1 use a DefaultTableModel in your table and then call setRowCount in the model:
    Java Code:
    ((DefaultTableModel)table.getModel()).setRowCount(yourCount);
    2
    Java Code:
    DefaultTableCellRenderer renderer =
        (DefaultTableCellRenderer)table.getDefaultRenderer(String.class);
    renderer.setHorizontalAlignment(JLabel.CENTER);
    3
    Java Code:
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    4 I have never had trouble with ButtonGroup in j2se 1.5
    How are you using it to conclude that it is "not working?"

    See Lesson: Using Swing Components for more.

Similar Threads

  1. Swing Components Placing
    By ne2000 in forum Eclipse
    Replies: 2
    Last Post: 06-23-2008, 09:00 AM
  2. How to print Swing components
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:04 AM
  3. Tab order on swing components
    By ashvin@projectdemo.biz in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2008, 11:06 AM
  4. Where is it best to declare swing components?
    By MacNstuff in forum AWT / Swing
    Replies: 1
    Last Post: 02-06-2008, 01:59 AM
  5. HTML on Swing Components
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-27-2007, 10:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •