Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:50:01+00:00 2026-06-09T04:50:01+00:00

String[] titles = {System Code,Domain Name,Organizational Unit,Organization Name}; for(int i=0; i<titles.length; i++) { TableColumn

  • 0
String[] titles = {"System Code","Domain Name","Organizational Unit","Organization Name"};
        for(int i=0; i<titles.length; i++)
        {
            TableColumn column = new TableColumn(table, SWT.LEFT, i);
            column.setText(titles[i]);
            column.setWidth(150);
            column.setMoveable(true);
            column.setResizable(true);
        }

this code works for me but i want to have an array of TableColum, like this one

    Table table;
    TableColumn[] columns;
    table = new Table(composite, SWT.NONE);
    columns = new TableColumn[noOfColumns];
    table.setHeaderVisible(true);

but now you see they are not associated with table. How can i associate all these to columns to table ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:50:03+00:00Added an answer on June 9, 2026 at 4:50 am

    As far as making the columns into an array,

        String[] titles = {"System Code","Domain Name","Organizational Unit","Organization Name"};
        TableColumn[] columns = new TableColumn[titles.length];
        for(int i=0; i<titles.length; i++)
        {
            TableColumn column = new TableColumn(table, SWT.LEFT, i);
            column.setText(titles[i]);
            column.setWidth(150);
            column.setMoveable(true);
            column.setResizable(true);
            columns[i] = column;
        }
    

    For the second part though, you’re trying to get that array into your table?


    Are you using javax.swing.table.TableColumn? As it doesnt appear to have setText and setMoveable methods on it. If you are using it, and fixed that in your code, simply add the following code into the for loop (at the end):

    tableInstance.addColumn(column);
    

    Or do another iteration afterwards/later on:

    for( TableColumn column : columns ) {
        tableInstance.addColumn(column);
    }
    

    tableInstance if your instance of the JTable class

    Here’s a full class with all the issues I found fixed up (you wont need all of it, such as the frame declaration, but just to let you see it all):

    public class TableTest {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            JTable table = new JTable();
            JScrollPane scroll = new JScrollPane(table);
            String[] titles = {"System Code","Domain Name","Organizational Unit","Organization Name"};
            TableColumn[] columns = new TableColumn[titles.length];
            for(int i=0; i<titles.length; i++)
            {
                TableColumn column = new TableColumn(i);
                column.setHeaderValue(titles[i]);
                column.setWidth(150);
                column.setResizable(true);
                columns[i] = column;
                table.addColumn(column);//since we add this here, no real point in keeping
                                        //the columns in an array tbh anymore
            }
            f.add(scroll);
            f.setSize(500, 500);
            f.setVisible(true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
Following scenario: I have user object: ... @Column(name = TITLE) private String title; @NotNull
i have a string like this one $sitesinfo = 'site 1 titles-example1.com/ site 2
private void launchEventPanel(String title) { EventQueue.invokeLater(new Runnable(title) { public void run() { JFrame myFrame
I use this code to get a String array of headings used in a
Exception of type 'System.Web.HttpUnhandledException' was thrown. Step into: Stepping over non-user code 'System.Web.UI.Control.OnLoad' Step
With this code (listApplications is a ListView control): private void ShowApplicationPropertiesForm() { String FullPath
I have a unique 'string' does not contain definition problem. Take following VIew code:
public class MyFrame extends JFrame { public MyFrame(String title) { setSize(200, 200); setTitle(Integer.toString(super.getSize().width)); setLayout(new
Let's say I have two simple models project t.string :title vote t.references :project t.integer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.