I add a timeout for InputStream read().

I am looking for a timeout for InputStream read() since Java doesn't support it. I use a Timer class to handle the timeout value and put the InputStream.read() into another thread. When the time is up, the Timer object will stop the thread of reading. What do you think about this solution? Do you have any other better solution?
thanks

and any ideas on how to stop this blocking read() method from an InputStream (Java 5)???? When googling on this topic I find an incredible amount of questions on this subject BUT no solutions. What to do?? I'm a little bit affraid it comes down to hacking the JVM finding the Thread in some memory block and removing it with brute force.
hmmm when I think of it, it's really driving my crazy.... the only thing I can think of is throwing my PC out of the window and buy a new one. Unfortunately there's no budget for that it will cost to many PCs :-)
Edited by: R_e_n_s on Jun 3, 2008 6:45 AM

Similar Messages

  • Set a timeout for "read from text file"

    I Need to read from a text file on a remote pc and use the read from text file function to do this. It wotks but sometimes this pc is down causing long wait times in my vi.
    Is there a way to set a timeout for the read from text file function, or is there an other solution?
    Thank you

    You could check that the path is valid first before you attempt to read the file.  hen put the file read in a True-False case structure based on the results of the check.  You can use the function "Check if File or Folder Exists"  It checks whether a file or folder exists on disk at a specified path. This VI works with standard files and folders as well as files in LLB files.   The function is found in the File I/O --> Advanced File Functions palette.
    Tom

  • I bought a relative's original iPad. I want to leave the apps on it and add my own pdfs to read. My itunes account is really for my iPod. the computer says that if I "Sync" the iPad will be erase, and become like my iPods. how can I just get my files onto

    I am a first-time iPad owner/user. I bought a relative's original iPad. I want to leave the apps on it and add my own pdfs to read. My itunes account is really for my iPod. iTunes message says that if I "Sync" the iPad will be erase, and become like my iPods. If I make a new iTunes account, would the apps be erased when I tried to use it?
    How can I just get my files onto this iPad, and still have the apps that my relative left there for me?
    Thank you.

    iPads sync to 1 computer only.
    All media and apps are tied to the Apple ID that purchased them.
    Without your relatives ID and password, you cannot update any of the Apps.
    I am pretty certain he is also violating Apples terms of service by giving you the apps.

  • Developing an Add-in for Adobe Reader to insert the PDF into Lotus Notes

    Hi
    We currently have a document management solution in MS Word & Excel, where by you can open/create a document click a button that is linked to a macro and it brings a Document Management screen up and allows you to save the file into a new Lotus Notes Document.
    We are now trying to get the same functionality into Adobe Reader, whereby a user can open a PDF they have on their PC and then go to a menu item and it will perform similar function to our macro/VB that we have setup in MS Word & Excel.
    Does anyone know of anyone who has developed such an idea or could point me in the right direction of where to start developing as I have never developed any add-in/plug-ins for Adobe Reader.
    This needs to be done really in Visual Basic, but any help would be great
    Thanks
    Ian

    You start by downloading the Acrobat SDK.
    In the SDK is information about developing a plugin for Reader, which will require you to obtain a license from Adobe.  Submit the necessary paperwork to see if you are approved.   It doesn’t make much sense to start development if you don’t get approval.
    Once approved, you will want a copy of Adobe Acrobat for development as it’s easier than developing with Reader.
    Plugins are developed in C/C++ and there are samples in the SDK.

  • Developing an Add-in for Adobe Reader to check Open PDF's into Lotus Notes

    Hi
    We currently have a document management solution in MS Word & Excel, where by you can open/create a document click a button that is linked to a macro and it brings a Document Management screen up and allows you to save the file into a new Lotus Notes Document.
    We are now trying to get the same functionality into Adobe Reader, whereby a user can open a PDF they have on their PC and then go to a menu item and it will perform similar function to our macro/VB that we have setup in MS Word & Excel.
    Does anyone know of anyone who has developed such an idea or could point me in the right direction of where to start developing as I have never developed any add-in/plug-ins for Adobe Reader.
    Thanks
    Ian

    Try the forum for Acrobat SDK:
    http://forums.adobe.com/community/acrobat/acrobat_sdk

  • Use labview to read an Excel file to some control and add a checkbox for each row

      As the subject say,I need to use labview to read an excel file,and show it in some control,such as mclb;then ,I should add an checkbox for each row,enable me to choose the row i want.What should I do ? Many Thanks.
    Solved!
    Go to Solution.

    Hi,
    to answer your question:
    - read an excel file
    - show it in some control, such as a MCLB
    - add an checkbox for each row
    - choose the row you want
    Hint to make it easier: I wouldn't use checkboxes, as the MCLB already allows to select rows by mouseclick…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Set TimeOut for SwingWorker

    nice day,
    1/ how can I get real Html size in kB with intention to set as maxValue to ProgressMonitor
    2/ how can I set/synchronize current valueOfDownLoadedHtml in kB to ProgressMonitor throught downloading Html content
    3/ how can I set TimeOut for this Tast, (maybe ... could I use Timer)
    import java.awt.BorderLayout;
    import java.awt.Insets;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;
    import java.nio.charset.Charset;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.ProgressMonitor;
    import javax.swing.SwingWorker;
    public class ProgressMonitorDemo extends JPanel implements ActionListener, PropertyChangeListener {
        private static final long serialVersionUID = 1L;
        private ProgressMonitor progressMonitor;
        private JButton startButton;
        private JTextArea taskOutput;
        private Task task;
        private int sizeIn_kB = 0;
        class Task extends SwingWorker<Void, Void> {
            private String str;
            int progress = 0;
            public Task(String str) {
                this.str = str;
            @Override
            public Void doInBackground() {
                if (str.equals("Loads")) {
                    addBackgroundLoadsData();
                    setProgress(0);
                    while (progress < sizeIn_kB && !isCancelled()) {
                        progress += sizeIn_kB;
                        setProgress(Math.min(progress, sizeIn_kB));
                return null;
            @Override
            public void done() {
                if (str.equals("Loads")) {
                    Toolkit.getDefaultToolkit().beep();
                    startButton.setEnabled(true);
                    progressMonitor.setProgress(0);
        public void addBackgroundLoadsData() {
            InputStream in = null;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            String charset ="";
            try {
                String UrlString = "http://java.sun.com/";
                URL url = new URL(UrlString);
                URLConnection conn = url.openConnection();
                sizeIn_kB = conn.getContentLength();
                charset = conn.getContentEncoding();
                conn.setRequestProperty("Accept-Charset", charset);
                in = conn.getInputStream();
                int len;
                byte[] buf = new byte[1024];
                while ((len = in.read(buf)) > 0) {
                    bos.write(buf, 0, len);
                in.close();
                String charEncoding = Charset.defaultCharset().name();
                //String fileEncoding = System.getProperty("file.encoding");
                //System.out.println("File Encoding: " + fileEncoding);
                //System.out.println("Char Encoding: " + charEncoding);
                //System.out.println("Char Encoding: " + Charset.availableCharsets());
                charEncoding = "cp1250";
                String groupImport = new String(bos.toByteArray(), charEncoding);
                conn = null;
            } catch (IOException ioException) {
                ioException.printStackTrace();
                JOptionPane.showMessageDialog(null, ioException.getMessage(), "Htlm error", JOptionPane.ERROR_MESSAGE);
            } catch (StringIndexOutOfBoundsException ioException) {
                ioException.printStackTrace();
                JOptionPane.showMessageDialog(null, ioException.getMessage(), "InputStream error", JOptionPane.ERROR_MESSAGE);
        public ProgressMonitorDemo() {
            super(new BorderLayout());
            startButton = new JButton("Start");
            startButton.setActionCommand("start");
            startButton.addActionListener(this);
            taskOutput = new JTextArea(5, 20);
            taskOutput.setMargin(new Insets(5, 5, 5, 5));
            taskOutput.setEditable(false);
            add(startButton, BorderLayout.PAGE_START);
            add(new JScrollPane(taskOutput), BorderLayout.CENTER);
            setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        @Override
        public void actionPerformed(ActionEvent evt) {
            progressMonitor = new ProgressMonitor(ProgressMonitorDemo.this, "Running a Long Task", "", 0, 100);
            progressMonitor.setProgress(0);
            task = new Task("Loads");
            task.addPropertyChangeListener(this);
            task.execute();
            startButton.setEnabled(false);
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == null ? evt.getPropertyName() == null : "progress".equals(evt.getPropertyName())) {
                int progress = (Integer) evt.getNewValue();
                progressMonitor.setProgress(progress);
                String message = String.format("Completed %d%%.\n", progress);
                progressMonitor.setNote(message);
                taskOutput.append(message);
                if (progressMonitor.isCanceled() || task.isDone()) {
                    Toolkit.getDefaultToolkit().beep();
                    if (progressMonitor.isCanceled()) {
                        task.cancel(true);
                        taskOutput.append("Task canceled.\n");
                    } else {
                        taskOutput.append("Task completed.\n");
                    startButton.setEnabled(true);
        private static void createAndShowGUI() {
            JFrame frame = new JFrame("ProgressMonitorDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JComponent newContentPane = new ProgressMonitorDemo();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    See the session-descriptor element of weblogic.xml deployment descriptor:
    http://download.oracle.com/docs/cd/E21764_01/web.1111/e13712/weblogic_xml.htm#i1071981

  • ACE timeout for different Serverfarms

    I have a Business unit that publishes an application that is externally available. We Reverse Proxy the VIP to allow the connection externally. They would like to impose different application timeouts for internal users (1 hour) and external users (30 Minutes) . The application can not differentiate between an external or internal source so our option is either seperate serverfarms with seperate real servers with different configuration files.
    My question is, is there any other way to do this within the ACE so that we don't have to spin up seperate Servers with different configuration files.
    I would also like  to maintain one VIP address if possible.

    You can maintain 1 VIP but you'll have to use header rewrite and work with dev. team of your application.
    It's related to the session state tracked by a cookie the application sends (either as a Set-Cookie or a token embedded in URLs)
    Make two different serverfarms (with the same set of real servers).
    Make a class-map matching the IP addresses of internal users (RFC 1918 ?)
    For this class-map, add a field in each HTTP request coming in
    "X-Internal:YES"
    apply this on each request with the option
    header-rewrite per-request
    The application team just has to parse each header for the pattern you've just added and then changing the timeout value to the one they want.
    For the class-default (external users) you can add "X-Internal:NO", it's cleaner but not strictly necessary.

  • Timeout for readline

    Dear all,
    When reading some data from an input stream e.g. readline(), it is waiting for incoming data. Is it possible to set a timeout that make reading abort after a certain time?
    I know how to use timers but I'm not familiar with any aborting procedures for readLine()
    Thanks for any help in advance,
    Ron

    import java.io.*;
    * @author  Ian Schneider
    public class HowFastAreYou implements Runnable {
        public void run() {
            try {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                System.out.println("you typed " + in.readLine());
            } catch (IOException ioe) {
                ioe.printStackTrace();
        public static final void main(String[] args) throws Exception {
            Thread t = new Thread(new HowFastAreYou());
            t.start();
            Thread.sleep(1000);
            t.interrupt();
            System.out.println("too late buddy");
    }Threads tutorial - there are two threads used in this example. The first thread is spawned by the jvm itself when main is invoked. This thread spawns the input thread. InputStreams are usually blocking (synchronous) , that is, the current thread will no return from a read call until data is present (versus nio, which provides support for an asynchronous API). So the spawned thread is waiting for input, but the main thread carries on, where it then sleeps for one second. If you haven't pressed return by then, the main thread "interrupts" the input thread. This means the blocking operation ends.

  • Setting timeout for all the web test scripts in the solution

    Hello,
    I have around 16 web test scripts (using VSTS 2010 ultimate version) in my project (in a solution). By default the timeout set for each request is 60 sec. I need to increase the timeout to 180 sec. Currently, I am clicking on each request and modifying
    the timeout parameter from the Properties window.
    Is there any common setting for timeout available which would be acting across all the scripts?
    Thanks.

    Hello,
    We only can set Timeouts for a separate request in Visual Studio Web Test. There is no way to set Timeout for all requests in VS IDE. But you can write you own logic code using
    Timeout Property in a web test plugin to set Timeout for all requests in a web test.
    About how to write a web test plugin, please see:
    How to: Create a Web Performance Test Plug-In
    Best regards,
    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

  • Hi I have two questions. I am using NAS 4.1 and was wondering is it possible to set a different session timeout for different users? How is the session timeout set? Thanks, YS

     

    <i>I am using NAS 4.1 and was wondering is it possible to set a different session timeout for different users?</i>
    Um, there is no such thing as NAS4.1.
    I'm assuming that you mean NAS4.0 (maybe NAS4.0sp1?). If so, then the session timeouts are specified in the session section of the NTV configuration files.
    AFAIK, you can specify session timeouts on a per user basis.

  • Timeout for content

    Hello
    9iAS with Portal 9.0.2 in Sun Solaris
    I am working with Oracle Reports Builder and Oracle Portal.
    I've saved my reports with JSP extension.
    So, I've made some portlets with these reports into PEOPLE_APP db provider.
    Now, when I run my pages with these portlets, some times (most of times) the following error appears instead of the report:
    Timeout for content=[any_number]
    I've already researched in OTN and Metalink forums, I've changed my zone.properties and http.conf files, but it didn't resolve my problem.
    So, what else I need to do in order to solve my problem? Any other ideas?
    Thanks.
    P.S: We've sent lots of questions with no satisfactory response from Oracle.
    We've noticed that Oracle provided extremely poor support.
    Maybe this isn't a good solution. Maybe there isn't a solution, at least in this way.
    Take a look in some fragments of messages, found in OTN and Metalink forums:
    "I've increased the timeout but that doesn't help.
    It's also very strange that after rebooting the server in Portal 3.0.8/ias1.0.2.1 my pages appeared in 10-20 seconds and now in Portal 3.0.9/ias1.0.2.2 it takes two to four minutes. And this slow performance is only while retrieving the page for the first time. The second time I retrieve a page it's there in a few seconds.
    So, I do not think it has anything to do with the provider's timeout...."
    "But maybe it's the Portal-schema itself which causes this problem. I heard someone saying that he missed indexes after a Portal-upgrade --> maybe this is my problem too, although i didn't have any error-messages in the upgrade-logfiles...."
    "Unfortunately we did not yet solve these timeout problems. Oracle is currently studying several logfiles and traces.
    At first we thought that we had the timeout problems only after starting up the server. But now we noticed that the timeouts are repeated after 5 to 7 days. For some reason it looks as if Portal is refreshing the cache at that moment, but we can not find anywhere a refreshperiod of 120 hours or so..."
    "Having wrestled with these Timeout errors for months with no satisfactory response from Oracle, I came across someone's solution yesterday and, for me, it worked immediately. Please keep in mind before doing this that it is in direct opposition to what the new "Troubleshooting Issues in Oracle9iAS Portal Architecture and Performance (3.0.9.8.2)" whitepaper states....."
    "After many many performance problems and timeouts issues which Oracle provided extremely poor support we finally learned that all of our problems where related to the same things - Oracle has not tuned this product before shipping it. Numerous little bugs and coding errors were a small part of the fixes. The real problem is that all the indexes have subscriber id as the first column which is always set to one and is not used in the majority of querys which makes these indexes useless for performance... (http://metalink.oracle.com/metalink/plsql/ml2_gui.startup)"
    "Sr. Oracle how long do I need to wait for real solutions? (http://metalink.oracle.com/metalink/plsql/ml2_gui.startup)"

    You must have registered some provider for your portlets. Go to adminstration screens of portal. Goto edit provider from there and increase the portlet timeout.
    Also change the time out value in your provider.xml for the corresponding JSPs.

  • Timeouts for Portlets

    I get timeouts for some of my portlets on a Page that I have
    built. I want to know whether increasing the Provider timeout
    will stop this problem and where does it get its default seeting
    from. If it is hard coded does it override the settings from
    zone.properties file.

    thanks candance...but I hardly believe that this is the only spot, since I am getting this weird "timeout for content", do you know what's up with that?

  • How to let add external apps for simple users?

    How to let add external apps for simple users? Simple users don't have login server administer rights, so how can they add external apps for their use?

    ...Edit External applications portlet sais:
    Error: An unexpected error occurred: User-Defined Exception (WWC-43000)
    :(((

  • How to add mouse listener for a single row alone

    I have a requirement. In a JTable when I double click a particular row the cells in the row should set to the width which I have provided.
    The problem with my code is when I click fourth row in the table, the first row gets adjusted.
    So how I need help is
    only if I click the first row, the first row cell size should get adjusted not when I click fourth row.
    Similarly if I give some cell width and height for fourth row cells, then when I double click the fourth row, the fourth should alone get adjusted and not the other rows.
    Hope I have explained clearly.
    How can it be achieved?
    Please find below my code. Everything is hardcoded. So it may look messy. Please excuse.
    // Imports
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    class SimpleTableExample extends JFrame {
    // Instance attributes used in this example
    private JPanel topPanel;
    private JTable table;
    private JScrollPane scrollPane;
    String data1 = "";
    String data2 = "123456789ABCDEFGHIJKLMNOPQRSTUVQWXYZabcdefghijklmnopqrstuvwxyzaquickbrownfoxjumpedoverthelazydog";
    int size = data2.length();
    // Constructor of main frame
    public SimpleTableExample() {
         // Set the frame characteristics
         setTitle("Simple Table Application");
         setSize(400, 200);
         setBackground(Color.gray);
         // Create a panel to hold all other components
         topPanel = new JPanel();
         topPanel.setLayout(new BorderLayout());
         getContentPane().add(topPanel);
         // Create columns names
         String columnNames[] = { "SEL", "DESIGN DATA", "PART NUMBER" };
         // Create some data
         String dataValues[][] = { { data1, data2, "67", "77" },
              { "", "43", "853" }, { "", "89.2", "109" },
              { "", "9033", "3092" } };
         DefaultTableModel model = new DefaultTableModel(dataValues, columnNames);
         model.addColumn("PART TITLE");
         model.addColumn("SPECIAL INSTRUCTIONS");
         table = new JTable(model) {
         public boolean isCellEditable(int rowIndex, int colIndex) {
              return false;
         // set specific row height
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         int colInd = 0;
         TableColumn col = table.getColumnModel().getColumn(colInd);
         int width = 50;
         col.setPreferredWidth(width);
         int colInd2 = 1;
         TableColumn col2 = table.getColumnModel().getColumn(colInd2);
         int width2 = 100;
         col2.setPreferredWidth(width2);
         int colInd3 = 2;
         TableColumn col3 = table.getColumnModel().getColumn(colInd3);
         int width3 = 10;
         col3.setPreferredWidth(width3);
         int colInd4 = 3;
         TableColumn col4 = table.getColumnModel().getColumn(colInd4);
         int width4 = 10;
         col4.setPreferredWidth(width4);
         int colInd5 = 4;
         TableColumn col5 = table.getColumnModel().getColumn(colInd5);
         int width5 = 10;
         col5.setPreferredWidth(width5);
         table.addMouseListener(new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
              JTable target = (JTable) e.getSource();
              int row = target.getSelectedRow();
              int column = target.getSelectedColumn();
              TableColumn col1 = table.getColumnModel().getColumn(0);
              col1.setPreferredWidth(50);
              TableColumn col2 = table.getColumnModel().getColumn(1);
              col2.setPreferredWidth(400);
              table.getColumnModel().getColumn(1).setCellRenderer(
                   new TableCellLongTextRenderer());
              table.setRowHeight(50);
              TableColumn col5 = table.getColumnModel().getColumn(4);
              col5.setPreferredWidth(200);
         // Create a new table instance
         // table = new JTable(dataValues, columnNames);
         // Add the table to a scrolling pane
         scrollPane = new JScrollPane(table);
         topPanel.add(scrollPane, BorderLayout.CENTER);
    // Main entry point for this example
    public static void main(String args[]) {
         // Create an instance of the test application
         SimpleTableExample mainFrame = new SimpleTableExample();
         mainFrame.setVisible(true);
    class TableCellLongTextRenderer extends JTextArea implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
         boolean isSelected, boolean hasFocus, int row, int column) {
         this.setText((String) value);
         this.setWrapStyleWord(true);
         this.setLineWrap(true);
         // set the JTextArea to the width of the table column
         setSize(table.getColumnModel().getColumn(column).getWidth(),
              getPreferredSize().height);
         if (table.getRowHeight(row) != getPreferredSize().height) {
         // set the height of the table row to the calculated height of the
         // JTextArea
         table.setRowHeight(row, getPreferredSize().height);
         return this;
    Edited by: 915175 on Aug 3, 2012 4:24 AM

    Hi
    Try below code. Hope this will help
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    public class SimpleTableExample extends JFrame {
    private JPanel topPanel;
    private JTable table;
    private JScrollPane scrollPane;
    String data1 = "";
    String data2 = "123456789ABCDEFGHIJKLMNOPQRSTUVQWXYZabcdefghijklmnopqrstuvwxyzaquickbrownfoxjumpedoverthelazydog";
    int size = data2.length();
    // Constructor of main frame
    public SimpleTableExample() {
    // Set the frame characteristics
    setTitle("Simple Table Application");
    setSize(400, 200);
    setBackground(Color.gray);
    // Create a panel to hold all other components
    topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    getContentPane().add(topPanel);
    // Create columns names
    String columnNames[] = { "SEL", "DESIGN DATA", "PART NUMBER" };
    // Create some data
    String dataValues[][] = { { data1, data2, "67", "77" },
    { "", "43", "853" }, { "", "89.2", "109" },
    { "", "9033", "3092" } };
    DefaultTableModel model = new DefaultTableModel(dataValues, columnNames);
    model.addColumn("PART TITLE");
    model.addColumn("SPECIAL INSTRUCTIONS");
    table = new JTable(model) {
    public boolean isCellEditable(int rowIndex, int colIndex) {
    return false;
    // set specific row height
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    int colInd = 0;
    TableColumn col = table.getColumnModel().getColumn(colInd);
    int width = 50;
    col.setPreferredWidth(width);
    int colInd2 = 1;
    TableColumn col2 = table.getColumnModel().getColumn(colInd2);
    int width2 = 100;
    col2.setPreferredWidth(width2);
    int colInd3 = 2;
    TableColumn col3 = table.getColumnModel().getColumn(colInd3);
    int width3 = 10;
    col3.setPreferredWidth(width3);
    int colInd4 = 3;
    TableColumn col4 = table.getColumnModel().getColumn(colInd4);
    int width4 = 10;
    col4.setPreferredWidth(width4);
    int colInd5 = 4;
    TableColumn col5 = table.getColumnModel().getColumn(colInd5);
    int width5 = 10;
    col5.setPreferredWidth(width5);
    // Cell Render should apply on each column -- add by Rupali
    for(int i=0; i< table.getColumnModel().getColumnCount(); i++){
    table.getColumnModel().getColumn(i).setCellRenderer( new TableCellLongTextRenderer());
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
    JTable target = (JTable) e.getSource();
    int row = target.getSelectedRow();
    int column = target.getSelectedColumn();
    setTableCellHeight(table,row,column); //Added by Rupali
    TableColumn col1 = table.getColumnModel().getColumn(0);
    col1.setPreferredWidth(50);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    col2.setPreferredWidth(400);
    TableColumn col5 = table.getColumnModel().getColumn(4);
    col5.setPreferredWidth(200);
    // Create a new table instance
    // table = new JTable(dataValues, columnNames);
    // Add the table to a scrolling pane
    scrollPane = new JScrollPane(table);
    topPanel.add(scrollPane, BorderLayout.CENTER);
    * Created By Rupali
    * This will set cell's height and column's width
    * @param table
    * @param row
    * @param column
    public void setTableCellHeight(JTable table, int row, int column) {
    // set the JTextArea to the width of the table column
    setSize(table.getColumnModel().getColumn(column).getWidth(),
    getPreferredSize().height);
    if (table.getRowHeight(row) != getPreferredSize().height) {
    // set the height of the table row to the calculated height of the
    // JTextArea
    table.setRowHeight(row, getPreferredSize().height);
    // Main entry point for this example
    public static void main(String args[]) {
    // Create an instance of the test application
    SimpleTableExample mainFrame = new SimpleTableExample();
    mainFrame.setVisible(true);
    class TableCellLongTextRenderer extends JTextArea implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    this.setText((String) value);
    this.setWrapStyleWord(true);
    this.setLineWrap(true);
    return this;
    }

Maybe you are looking for

  • Foreign curr reval for open items - questions - very urgent

    Hi all, Can anyone explain me the account determination for open item exchange rate difference postings? 1.     What are the accounts meant for under tab Exchange rate difference realized (Loss, Gain) 2.     What are the account meant for under tab v

  • Exchange Final Cut Pro 5 discs for upgrade to Intel

    I have Final Cut Pro 5 install discs and recently upgraded to iMac with Intel processor.  Is there a way to exchange the discs to Intel version?

  • Report services error

    Hi guys, I've tried so many things and still nothing. Whenever I boot my comp the report service is not running. Then I try to run it manually through the services pannel I get the message asking to contact the vendor. Here's the message from log vie

  • Creating a global layout in CO03

    Hi Expert, Can anyone tell me what authorizations/Parameter IDs are required to create a global variant in transaction CO03 -> goto Costs -> Analysis ? I can create and save a layout that is user-specific, but I cannot make it global. Any ideas? I al

  • Spry.Data.HTML Firefox .vs. IE

    Hi, I have a relatively simple page with two HTML table data sources. ds1 = Flashcontent.html and ds2 = PDFcontent.html and their respective tables, FlashDemoContent and PDFDemoContent. I'm using a Spry Tab widget that contains two tabs, and Spry rep