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 7489457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:15:02+00:00 2026-05-29T15:15:02+00:00

This example code is a short version of my actual program: import java.awt.BorderLayout; import

  • 0

This example code is a short version of my actual program:

import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.*;


public class Example extends JFrame {

private JPanel contentPane;
private JTable table;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Example frame = new Example();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public Example() {
    //what to do @ close
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 792, 585);

    //content pane
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    //create desktop pane add it to content pane
    final JDesktopPane desktopPane = new JDesktopPane();
    contentPane.add(desktopPane, BorderLayout.CENTER);

    //create Int Frame with table
    JInternalFrame tableIntFrame = new JInternalFrame("TableIntFrame");
    tableIntFrame.setBounds(31, 29, 300, 205);
    desktopPane.add(tableIntFrame);

    //create the table
    table = new JTable();

    table.setFillsViewportHeight(true);
    table.setModel(new DefaultTableModel(
        new Object[][] {
            {"Row 0 (click for more info)"},
            {"Row 1 (click for more info)"},
        },
        new String[] {
            "Collumn 0"
        }
    ));

    //add the table to a ScrollPane
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(table);
    //add Scrollpane to table       
    tableIntFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    tableIntFrame.setVisible(true);

    //Listen for events on selection
    table.getSelectionModel().addListSelectionListener(new
            ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {

            // only fires ones
            if (! e.getValueIsAdjusting())
            { 
                //create info frame with title set to selectedrow index
                createFrame(desktopPane, table.getSelectedRow()+"");

            }

        }
    });
    // Allow only one row to be selected.
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);



}

//Creates an int frame with the title set to the row
private void createFrame(JDesktopPane desktopPane, String selectedRow){

    JInternalFrame InfoIntFrame = new JInternalFrame("Info Row "+selectedRow);
    InfoIntFrame.setBounds(425, 44, 183, 72);
    //add to desktop
    desktopPane.add(InfoIntFrame);
    //set visible
    InfoIntFrame.setVisible(true);
    }
}

How do I get it to work for that clicking a row when it’s corresponding infoIntFrame is already open doesn’t create another instance of infoIntframe? (note: The infoIntFrames have to be created at runtime)

  • 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-05-29T15:15:02+00:00Added an answer on May 29, 2026 at 3:15 pm

    there are two areas:

    1) JInternalFrame tableIntFrame = new JInternalFrame("TableIntFrame"); lost Focus

    2) you have to check if exist in array that returns desktopPane.getAllFrames() before creating new another JInternalFrame, add InternalFrameListener, because (AFAIK) method desktopPane.getAllFrames() returns only visible JInternalFrame

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

take a look at this example code: public class Comment { private Comment() {
This is the example code, I'm using these functions for a program, but scanf
Short version: can you help me fill in this code? var conkeror_settings_dir = ".conkeror.mozdev.org/settings";
Take this example code (ignore it being horribly inefficient for the moment) let listToString
In this example code, I'm trying to offset the Grid 's Canvas position by
There is this example code, but then it starts talking about millisecond / nanosecond
The questions says everything, take this example code: <ul id=css-id> <li> <something:CustomControl ID=SomeThingElse runat=server
With regards this example from Code Complete: Comparison Compare(int value1, int value2) { if
for example this code var html = <p>This text is <a href=#> good</a></p>; var
This is an example code from the prototype site. var url = '/proxy?url=' +

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.