DeskTop Vs InternalFrame

dear seniors.....
i m developing a desktop application as MDI
inmy apln, i have a MDI with some internal frames.
while calling the internale frames thru the menu items,
i couldnt get the internal frames as it exactly appears to be.
actually i can get exact internal frame with al its component
positioned at the desired position at the FIRST TIME CALL only.
when i call the same thing again, the components in the internal frames
gets dislocated rather invisible...i duno wht hapens to them....
when resetting every Internal Frame in DesktopPane,
i am removing the older selected Frame.
even then...no use of it...
can anyone help me out in this?
to see my previous post regarding this pls click :
http://forum.java.sun.com/thread.jsp?forum=57&thread=554507&tstart=105&trange=15
any help will be highly appreciated...
-Munas.

I played around with the key board preferences (US with numeric pad vs just plain US)
I once created a list of the differences between those two presets. Here it is. I realize it's tough to read on this web page, but that's because this forum won't let me use html table tags. But if you paste the text into a spreadsheet or word processor, it will instantly format as a table (because tabs are embedded) and be easily readable.
The first column is the US with numeric keypad, and the second column is the plain US. Any commands not on this list are the same in both presets.
Anyone confused by any of those symbols can find an illustrated guide here or here.
* R Record
⇧* ⇧R •Record Toggle
⌃* ⌃⌥⌘R •Capture as Recording
⌅ ⇧↩ Play
. ⌥↩ Pause
0 ↩ Stop
⌃⌅ ⌃⇧↩ •Play from Left Window Edge
⌃0 ⌅ Stop and Go to Last Locate Position
⌃= = Set Locators by Regions/Events/Marquee
= ⇧= Set Rounded Locators by Regions/Events
⇧↩ ⌃↖ •Go to Selection Start
⌃↘ •Go to Selection End
↩ ⌃⌅ •Go to Beginning
/ C Cycle Mode
⌃⌥⌘R Record off for all
C K MIDI/Monitor Metronome Click
⌥* Open Recording Project Settings...
R ⌥L Toggle Library
K ⌥M Toggle Marker List
⌃; ⌘; Add to Arrange...
⇧R ⌃⌥R Event Position and Length in SMPTE Units
⌥⇧R ⌃⌥⇧R Secondary Ruler
⌃⌥⌘⌦ ⌃⌥⌘⌫ Individual Track Zoom Reset
⌃⌥⌦ ⌃⌥⌫ Individual Track Zoom Reset for All Tracks
⌘= ⌥- Trim Regions to Fill within Locators
⌃⌥+ ⌃⌥= Waveform Vertical Zoom In
⌃↖ ⌃↑ Stems: up
⌃↘ ⌃↓ Stems: down
⌃⌦ ⌃⌫ Stems: hide
(that blank line after "Record" means nothing, there's nothing missing; it's just something strange the forum is doing)
Message was edited by: 45rpm

Similar Messages

  • How can i change the background color of a visible JDesktopPane

    I tried this things but nothing happened ->
    getDesktopPane().setBackground(color);
    list = Tool.findComponent(getDesktopPane(), JPanel.class);
    for (int i = 0; i < list.size(); i++)
    list.get(i).setBackground(color);
    getMainFrame().getContentPane().setBackground(color);
    peter
    "No trees were destroyed in the sending of this message. However,
    a large number of electrons were terribly inconvenienced."

    I'm not sure if this is anything close to what you are looking for, and if not, oh well. No harm done.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Random;
    import javax.swing.JButton;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JPanel;
    class InternalFrameTest extends JPanel
        private JDesktopPane desktop = new JDesktopPane();
        private JInternalFrame internalFrame = new JInternalFrame("Foobars Rule!");
        private Random random = new Random();
        public InternalFrameTest()
            setPreferredSize(new Dimension(400, 400));
            setLayout(new BorderLayout());
            add(desktop);
            internalFrame.setSize(new Dimension(200, 200));
            JButton changeColorBtn = new JButton("Change Color");
            changeColorBtn.addActionListener(new ActionListener()
                @Override
                public void actionPerformed(ActionEvent e)
                    desktop.setBackground(new Color(
                            random.nextInt(256),
                            random.nextInt(256),
                            random.nextInt(256)));
            JPanel buttonPanel = new JPanel();
            buttonPanel.add(changeColorBtn);
            internalFrame.add(buttonPanel);
            internalFrame.setVisible(true);
            desktop.add(internalFrame);
            internalFrame.setLocation(30, 30);
        private static void createAndShowUI()
            JFrame frame = new JFrame("InternalFrameTest");
            frame.getContentPane().add(new InternalFrameTest());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    createAndShowUI();
    }

  • Jinternalframe won't hide more than once.

    hiya,
    i have a jinternalframe and when i click the close button it hides, but if i show it again and then try to click the close button it doesn't hide. the following code demonstrates the problem - click open then the x to close the internalframe then open again and try to hide the frame. nb i am using jdk1.2.2, i'm not sure if it happens in jdk1.3, but i could really do with a workaround for this...anyone got one?
    thanks!
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JDesktopPane;
    public class Test extends Frame implements ActionListener {
        JButton openButton;
        JLayeredPane desktop;
        JInternalFrame internalFrame;
        public Test() {
            super("Internal Frame Demo");
            setSize(500,400);
            this.addWindowListener(new WindowAdapter() {
                                       public void windowClosing(WindowEvent evt) {
                                           Window win = evt.getWindow();
                                           win.setVisible(false);
                                           win.dispose();
                                           System.exit(0);
            openButton = new JButton("Open");
            Panel p = new Panel();
            p.add(openButton);
            add(p, BorderLayout.SOUTH);
            openButton.addActionListener(this);
            // Set up the layered pane
            desktop = new JDesktopPane();
            desktop.setOpaque(true);
            add(desktop, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            if ((internalFrame == null)) {
                System.out.println("making new frame");
                internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
                internalFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                internalFrame.setBounds(50, 50, 200, 100);
            boolean there = false;
            for (int i = 0; i < desktop.getComponentCount(); i++) {
                if (desktop.getComponent(i).equals(internalFrame))
                    System.out.println("already there.");
                    there = true;
            if (!there) desktop.add(internalFrame, new Integer(1));   
            internalFrame.show();
        public static void main(String args[]) {
            Test sif = new Test();
            sif.setVisible(true);

    By Default with JBuilder u have this internalframe and
    JDeskTopPane!!!
    it works just fine (closing and opening again)::::
    Why don't u work with independent classes like:
    JDesktopPane(1), several (JInternalFrame) ???
    // example JDesktopPane ::
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Desktop extends JFrame {
    BorderLayout borderLayout1 = new BorderLayout();
    private JDesktopPane desktopPane = new JDesktopPane();
    JMenuBar menuBar1 = new JMenuBar();
    JMenu menuFile = new JMenu();
    JMenuItem menuFileNewFrame = new JMenuItem();
    public Desktop() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    public void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout1);
    this.setContentPane(desktopPane);
    this.setSize(new Dimension(600, 400));
    menuFile.setText("File");
    menuFileNewFrame.setText("New Frame");
    menuFileNewFrame.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    fileNewFrame_actionPerformed(e);
    menuFile.add(menuFileNewFrame);
    menuBar1.add(menuFile);
    this.setJMenuBar(menuBar1);
    static public void main(String[] args) {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception e) {
    Desktop desktop = new Desktop();
    desktop.setVisible(true);
    void fileNewFrame_actionPerformed(ActionEvent e) {
    InternalFrame frame = new InternalFrame();
    frame.setBounds(0, 0, 450, 300);
    desktopPane.add(frame, new Integer(1));
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if(e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    // example JInternalFrame ::
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class InternalFrame extends JInternalFrame {
    BorderLayout borderLayout1 = new BorderLayout();
    public InternalFrame() {
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    public void jbInit() throws Exception {
    this.setClosable(true);
    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);
    this.getContentPane().setLayout(borderLayout1);
    }

  • Controlling a label's text with Threads

    Hello,
    I couldn't find a specific topic about Java Threads and that's why i am writing here.
    I am developing a kind of strategy game and in one module i need to show the total amount of money the user has.
    - at first, when the game starts, the player chooses an amount.
    - the game starts and the player buys something
    - the amount should be updated, for a logical and routine transaction.
    But since the frame which is responsible from such transactions differ from the main frame, i could not do the update operations.
    e.g.
    public class GameMain extends JFrame{
    //The label is here
    }//end of gamemain
    class TransactionFrame extends JInternalFrame{
    //The internal frame has some buttons and radio buttons to allow the user to make transactions, purchasing of certain tools
    }//end of transactionframeThe best way that came into my mind was to update the label in my GameMain class whenever the player selects , say "Add" button in TransactionFrame.
    I had many tests before to do it with a certain paint method to handle those issues, but i couldn't find a solution.
    On the other hand, the TransactionFrame class' instances are created in some other class which I think wouldn't be relevant to say here, because it does nothing to do here.
    What i want to do is, as defined above,
    - i want to update the label in GameMain and
    - it should be updated whenever "Add" button is clicked in the TransactionFrame, which is a JInternalFrame.
    Here is what i have tried:
    1. i added a flag value in the TransactionFrame's "Add" button, and whenever it becomes "true", the Thread controlling the Label's text of GameMain, is triggered
    and the new amount will be presented to the user.
    -->But, although the player doesn't click anything on the internal frame, the thread in the main frame consideres it as clicked and tries to run something else.
    2. the other thing is, I put the amount at the internal frame as a string (drawn in paint method of this frame),
    --> This time, I updated the amount here but whenever I close the frame and create the frame by clicking on some button, the amount remains as chosen in the starting phase.
    (e.g. user selected 5000$, then bought something, the new amount: 4000$, ok, i close the frame and reopen it, the amount is: 5000$ !).
    I hope that I described the problem clearly here,
    What i expect is given above, if you'd like to advice me to try other things, please do not hesitate.
    Thank you,
    led1433

    You're probably long gone, so I'm not sure you'll see this, but my opinion is that your next step is to try to decrease the cohesion (I think that's what it's called) of your code so that the code that represents your main GUI has little knowledge of the code that represents the JInternalFrame and visa versa. I'm no pro at this, but one way to possibly do this is to give both public methods that get and set the amount and then let a Controller class call these methods. For instance:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class Test3B {
      private static void createAndShowUI() {
        final Main3B main = new Main3B();
        main.getComponent().setPreferredSize(new Dimension(500, 400));
        final Internal3B internalGui = new Internal3B();
        internalGui.addSetAmountBtnListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String amtString = internalGui.getAmountFieldText().trim();
            try {
              int amount = Integer.parseInt(amtString);
              main.setAmount(amount);
            } catch (NumberFormatException nfe) {
              JOptionPane.showMessageDialog(main.getComponent(), "Enter integers only",
                  "Error", JOptionPane.ERROR_MESSAGE);
        JInternalFrame internalFrame = new JInternalFrame();
        internalFrame.getContentPane().add(internalGui.getMainPanel());
        internalFrame.setBounds(10, 10, 400, 300);
        internalFrame.setClosable(true);
        main.addInternalFrame(internalFrame);
        JFrame frame = new JFrame("Test3B");
        frame.getContentPane().add(main.getComponent());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
            createAndShowUI();
    class Main3B {
      private static final String AMOUNT_LABEL = "Amount is: ";
      private int amount = 0;
      private JPanel mainPanel = new JPanel();
      private JLabel amountLabel = new JLabel(AMOUNT_LABEL + amount, SwingConstants.LEFT);
      private JDesktopPane desktop = new JDesktopPane();
      public Main3B() {
        desktop.setBorder(BorderFactory.createLineBorder(Color.blue));
        mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        mainPanel.setLayout(new BorderLayout());
        mainPanel.add(amountLabel, BorderLayout.NORTH);
        mainPanel.add(desktop, BorderLayout.CENTER);
      public void addInternalFrame(JInternalFrame internalFrame) {
        desktop.add(internalFrame);
        internalFrame.setVisible(true);
      public void setAmount(int amount) {
        this.amount = amount;
        amountLabel.setText(AMOUNT_LABEL + amount);
      public int getAmount() {
        return amount;
      public JComponent getComponent() {
        return mainPanel;
    class Internal3B {
      private JPanel mainPanel = new JPanel();
      private JTextField amountField = new JTextField(10);
      private JButton setAmountBtn = new JButton("Set Amount");
      public Internal3B() {
        mainPanel.add(new JLabel("Enter New Amount:"));
        mainPanel.add(Box.createHorizontalStrut(5));
        mainPanel.add(amountField);
        mainPanel.add(Box.createHorizontalStrut(15));
        mainPanel.add(setAmountBtn);
      public JPanel getMainPanel() {
        return mainPanel;
      public String getAmountFieldText() {
        return amountField.getText();
      public void addSetAmountBtnListener(ActionListener al) {
        setAmountBtn.addActionListener(al);
    }

  • JProgressBar and ObserverPattern in multiple document app??

    Hi,
    I'm working on a multiple document application with jInternalFrames. There is one very time-consuming process and therefore I'd like to show a progressbar for the user to know, that the programm is still running.
    So Icreated a seperate internalFrame with a jProgressBar and I implemented the observer pattern.
    Now the problem is: my time-consuming process (which is in the observable-class) notifies the internalFrame whenever one percent of work is done,
    and the programm even enters the update method of the internal frame. In this update method i set the value of the
    progress bar, but nothing happens. I tried a repaint() and even a paintImmediately() but nothing happens until
    my time-consuming process is done. That's not exactly what i call a progressbar... ;-) It is even worse as the whole view of the application is faulty once I minimized and then resized the main window while my time-consuming process is running.
    So I already found some articles and I fear I have to work with threads. But how?
    can anyone explain to me what method I have to run as a thread and how can I refresh my internalFrame respectively the progressbar then?
    I hope anyone can help me...

    * Progress_Test.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Progress_Test extends JFrame {
        public Progress_Test() {
            initComponents();
        private void initComponents() {
            desktop = new JDesktopPane();
            internalFrame = new JInternalFrame();
            panel = new JPanel();
            progressBar = new JProgressBar();
            progressBar.setVisible(false);
            toolbar = new JToolBar();
            startBtn = new JButton();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setTitle("Test Progress");
            internalFrame.setPreferredSize(new Dimension(200, 100));
            internalFrame.setVisible(true);
            panel.add(progressBar);
            internalFrame.getContentPane().add(panel, BorderLayout.CENTER);
            startBtn.setText("Start");
            startBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    startBtnActionPerformed(evt);
            toolbar.add(startBtn);
            internalFrame.getContentPane().add(toolbar, BorderLayout.NORTH);
            internalFrame.setBounds(0, 0, 200, 100);
            desktop.add(internalFrame, JLayeredPane.DEFAULT_LAYER);
            getContentPane().add(desktop, BorderLayout.CENTER);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
        private void startBtnActionPerformed(ActionEvent evt) {
            if( ltThread == null || !ltThread.isAlive() ){
                progressBar.setValue(0);
                LongTask lt = new LongTask();
                ltThread = new Thread(lt);
                ltThread.start();
        public static void main(String args[]) {
            new Progress_Test().setVisible(true);
        private JDesktopPane desktop;
        private JInternalFrame internalFrame;
        private JPanel panel;
        private JProgressBar progressBar;
        private JButton startBtn;
        private JToolBar toolbar;
        private Thread ltThread;
        public class LongTask implements Runnable{
            public LongTask() {
                progressBar.setMaximum(max);
            public void run(){
                progressBar.setVisible(true);
                int n=0;
                while ( n<max ){
                    n++;
                    progressBar.setValue(n);
                    try{Thread.sleep(1000);}catch(Exception ex){}
                progressBar.setVisible(false);
            private int max=10;
    }

  • Problem  in saving the JInternalFrame

    Hi everyone!!
    please help me!!
    When I open a new JInternalFrame in my created program and typed
    some words in the textarea, and open again another JInternalFrame
    and type some words in it, the save the first InternalFrame that I open,
    how come that the last internalframe was saved and not the one that I
    choose to saved. here is my code..
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.io.*;
    public class Test extends JFrame {
              JTextArea textArea = new JTextArea();     
              JTextArea textArea2 = new JTextArea();
              JDesktopPane desktop = new JDesktopPane();
              JScrollPane scroll = new JScrollPane();
              JInternalFrame internalFrame = new JInternalFrame("Internal",false,true,true,true);
              String fileName;
             int cnt;
       public Test() {
              JMenuBar toolBar = new JMenuBar();
              JMenu file = new JMenu("File");     
              JMenuItem newF = new JMenuItem("New");
              newF.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {newFile();}
              file.add(newF);     
              JMenuItem open = new JMenuItem("Open");
              open.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {openFile();}
              file.add(open);
            JMenuItem save = new JMenuItem("Save");
            save.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {saveFile();}
            file.add(save);     
            file.addSeparator();
            JMenuItem exit = new JMenuItem("Exit");
            exit.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {close();}
            file.add(exit);
            addWindowListener(new WindowAdapter()
               public void windowClosing(WindowEvent evt)
                 dispose();
                 System.exit(0);
              toolBar.add(file);
              setJMenuBar(toolBar);
            add(desktop);
         void newFile() {
              cnt++;
            String count = "frame";
            internalFrame = new JInternalFrame(count+cnt,true,true,true,true);
             internalFrame.add(new JScrollPane(textArea = new JTextArea()));
            desktop.add(internalFrame);
            internalFrame.moveToFront();
             internalFrame.setSize(500,300);
            internalFrame.setVisible(true);    
         void openFile() {
              JFileChooser fileOpen = new JFileChooser();
              int rVal = fileOpen.showOpenDialog(this);          
              if(rVal == JFileChooser.APPROVE_OPTION) {
                   File fileSelected = fileOpen.getSelectedFile();
                   try {
                        textArea.read(new FileReader(fileSelected), null);               
                   catch(IOException exp) {
         void saveFile() {
              JFileChooser filesave = new JFileChooser();
              int rVal = filesave.showSaveDialog(this);
              if(rVal == JFileChooser.APPROVE_OPTION) {
                   File fileSelected = filesave.getSelectedFile();
                   try {
                        textArea.write(new FileWriter(fileSelected));
                   catch(IOException exp) {
         void close() {
              System.exit(0);
         public static void main(String[] args) {
              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
               } catch (Exception e) { }          
              Test body = new Test();
              body.setSize(700,500);
              body.setLocation(150,80);
            body.show();          
    }

    Because you have only one textArea;
    Here is a modified one>>Select the frame before do save
    i used a seperate variable id to uniquely identify each textArea,you can use your count variable itself.
    check the code u will know:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.io.*;
    public class Test extends JFrame {
              JTextArea[] textArea = new JTextArea[20];int id=0;
              JTextArea textArea2 = new JTextArea();
              JDesktopPane desktop = new JDesktopPane();
              JScrollPane scroll = new JScrollPane();
              JInternalFrame internalFrame = new JInternalFrame("Internal",false,true,true,true);
              String fileName;
             int cnt;
       public Test() {
              JMenuBar toolBar = new JMenuBar();
              JMenu file = new JMenu("File");
              JMenuItem newF = new JMenuItem("New");
              newF.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {newFile();}
              file.add(newF);
              JMenuItem open = new JMenuItem("Open");
              open.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {openFile();}
              file.add(open);
            JMenuItem save = new JMenuItem("Save");
            save.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {saveFile();}
            file.add(save);
            file.addSeparator();
            JMenuItem exit = new JMenuItem("Exit");
            exit.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {close();}
            file.add(exit);
            addWindowListener(new WindowAdapter()
               public void windowClosing(WindowEvent evt)
                 dispose();
                 System.exit(0);
              toolBar.add(file);
              setJMenuBar(toolBar);
            add(desktop);
         void newFile() {
              cnt++;
            String count = "frame";
            internalFrame = new JInternalFrame(count+cnt+" "+id,true,true,true,true);
             internalFrame.add(new JScrollPane(textArea[id++] = new JTextArea()));
            desktop.add(internalFrame);
            internalFrame.moveToFront();
             internalFrame.setSize(500,300);
            internalFrame.setVisible(true);
         void openFile() {
              JFileChooser fileOpen = new JFileChooser();
              int rVal = fileOpen.showOpenDialog(this);
              if(rVal == JFileChooser.APPROVE_OPTION) {
                   File fileSelected = fileOpen.getSelectedFile();
                   try {
                    JInternalFrame ji=desktop.getSelectedFrame();
                    int no=Integer.parseInt(ji.getTitle().substring(ji.getTitle().indexOf(' ')+1,ji.getTitle().length()));
                        textArea[no].read(new FileReader(fileSelected), null);
                   catch(IOException exp) {
         void saveFile() {
              JFileChooser filesave = new JFileChooser();
              int rVal = filesave.showSaveDialog(this);
              if(rVal == JFileChooser.APPROVE_OPTION) {
                   File fileSelected = filesave.getSelectedFile();
                   try {
                    JInternalFrame ji=desktop.getSelectedFrame();
                    int no=Integer.parseInt(ji.getTitle().substring(ji.getTitle().indexOf(' ')+1,ji.getTitle().length()));
                        textArea[no].write(new FileWriter(fileSelected));
                   catch(IOException exp) {
         void close() {
              System.exit(0);
         public static void main(String[] args) {
              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
               } catch (Exception e) { }
              Test body = new Test();
              body.setSize(700,500);
              body.setLocation(150,80);
            body.show();
    }

  • Creation of an applet JApplet in a desktop JDesktopPane

    how its posible to load from a jar file an applet which come from package my.package.myclass of the jar file.
    next i want to put it in a JInternalFrame and put this desktop frame in a JDesktopPane.
    indeed i can move the applet around with other applets in a little window!
    here's the code of the desktop_panel.javapackage kevin_shell;
    import kevin_shell.Kdemos.*;
    import java.awt.*;
    import java.awt.event.*;
    import java2d.MemoryMonitor;
    //import java2d.demos.Lines.*;
    import javax.swing.*;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.Border;
    import com.l2fprod.gui.plaf.skin.Skin;
    import com.l2fprod.gui.plaf.skin.SkinLookAndFeel;
    public class desktop_panel extends JPanel {
    JInternalFrame win_info = new JInternalFrame();
    public void killme(KDemo demo) {
    demo = null;
    public void view_image(String file) {
    thread_load_cube load = new thread_load_cube(file);
    load.start();
    JPanel jPanel2 = new JPanel();
    JDesktopPane pan_workspace = new JDesktopPane();
    public void paint(Graphics p) {
    p.setColor(Color.blue);
    p.fillRect(0, 0, 1000, 1000);
    p.setColor(Color.red);
    p.drawString("kevin OS", 10, 10);
    super.paint(p);
    BorderLayout borderLayout1 = new BorderLayout();
    JPanel jPanel3 = new JPanel();
    JButton jButton1 = new JButton();
    JInternalFrame win_memory = new JInternalFrame();
    JInternalFrame win_terminal = new JInternalFrame();
    MemoryMonitor win_mem = new MemoryMonitor();
    KClock win_perf = new KClock();
    JPanel jPanel4 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JButton jButton2 = new JButton();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JButton but_collect = new JButton();
    JButton but_refresh = new JButton();
    JTextField nb_free = new JTextField();
    Border border1;
    Border border2;
    JLabel jLabel2 = new JLabel();
    JTextField ed_jdk_path = new JTextField();
    JTextField nb_total = new JTextField();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel5 = new JLabel();
    bean_clock bean_clock1 = new bean_clock();
    JPanel jPanel5 = new JPanel();
    JPanel jPanel1 = new JPanel();
    JTabbedPane tabber = new JTabbedPane();
    BorderLayout borderLayout2 = new BorderLayout();
    JList list1 = new JList();
    JList list_system = new JList();
    JList list3 = new JList();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    JButton jButton5 = new JButton();
    JButton jButton6 = new JButton();
    test_applet Itest_applet = new test_applet();
    JButton jButton7 = new JButton();
    public desktop_panel() {
    try {
    jbInit();
    System.out.println("initializing desk");
    bean_clock1.setLocation(0, 0);
    bean_clock1.setSize(win_info.getPreferredSize());
    //bean_clock1.start();
    pan_workspace.add(win_info);
    win_info.show();
    win_info.setLocation(0, 0);
    win_info.setSize(win_info.getPreferredSize());
    //Class bruno=java.lang.ClassLoader.getSystemClassLoader().loadClass("demo_cube");
    //Object b=bruno.newInstance();
    pan_workspace.add(win_memory);
    win_memory.show();
    win_memory.setSize(win_memory.getPreferredSize());
    pan_workspace.add(win_terminal);
    win_terminal.show();
    win_terminal.setSize(win_terminal.getPreferredSize());
    pan_workspace.add(win_mem);
    win_mem.setVisible(true);
    win_mem.setSize(win_mem.getPreferredSize());
    pan_workspace.add(win_perf);
    win_perf.setVisible(true);
    win_perf.setSize(100, 100);
    win_perf.setLocation(400, 400);
    win_perf.startClock();
    //list_system.add("welcome to kevin os");
    //tabber.add(list_system);
    tabber.add(list1);
    tabber.add(list3);
    win_terminal.getContentPane().add(tabber, BorderLayout.CENTER);
    win_terminal.setSize(300, 300);
    win_terminal.setResizable(true);
    win_terminal.setLocation(400, 400);
    System.out.println("ok");
    } catch (Exception e) {
    e.printStackTrace();
    class thread_load_cube extends Thread {
    String file;
    thread_load_cube() {
    file = "pics/babe1.jpg";
    thread_load_cube(String f) {
    file = f;
    //win_cube
    public void run() {
    try {
    System.out.println("cube loading");
    Class demo = java.lang.ClassLoader.getSystemClassLoader().
    loadClass("kevin_shell.Kdemos.demo_cube");
    KDemo win_cube = (KDemo) demo.newInstance();
    //list_system.add("win cube (loading....)");
    java.net.URL stoneURL = main_win.class.getResource(file);
    java.net.URL skyURL = main_win.class.getResource(
    "pics/babe2.jpg");
    //win_cube=new demo_cube();
    win_cube.set_parameters(stoneURL, skyURL);
    //pan_workspace.add(win_cube);
    win_cube.show();
    win_cube.setLocation(300, 300);
    win_cube.setSize(300, 300);
    win_cube.setResizable(true);
    win_cube.setTitle("java 3d cube");
    win_cube.setIconifiable(true);
    win_cube.init();
    win_cube.setClosable(true);
    System.out.println("ok");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.out.println("problem with class");
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    System.out.println("acces problem");
    } catch (InstantiationException e) {
    e.printStackTrace();
    System.out.println("instance");
    class thread_load_j3d extends Thread {
    public void run() {
    //list_system.add("j3d test loading...");
    //kev
    try {
    Class demo = java.lang.ClassLoader.getSystemClassLoader().
    loadClass("kevin_shell.Kdemos.demo_j3d");
    KDemo win = (KDemo) demo.newInstance();
    //pan_workspace.add(win);
    win.show();
    win.setLocation(300, 300);
    win.setSize(300, 300);
    win.setResizable(true);
    win.setTitle("j3d test");
    win.setIconifiable(true);
    win.init();
    win.setClosable(true);
    System.out.println("ok");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.out.println("problem with class");
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    System.out.println("acces problem");
    } catch (InstantiationException e) {
    e.printStackTrace();
    System.out.println("instance");
    private void jbInit() throws Exception {
    border1 = BorderFactory.createMatteBorder(4, 4, 4, 4,
    new Color(91, 91, 91));
    border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
    Color.white, Color.white,
    new Color(153, 153, 204),
    new Color(153, 153, 204));
    jButton2.setBackground(Color.white);
    jButton2.setBorder(BorderFactory.createLineBorder(Color.black));
    jButton2.setPreferredSize(new Dimension(70, 70));
    //jButton2.setIcon(new ImageIcon(desktop_panel.class.getResource("icons/on_kevin.gif")));
    jButton2.setMargin(new Insets(0, 0, 0, 0));
    jButton2.setBounds(new Rectangle(9, 6, 52, 54));
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 70));
    jLabel1.setForeground(SystemColor.desktop);
    jLabel1.setText("kevin os 1.0");
    jLabel1.setBounds(new Rectangle(66, 6, 255, 22));
    this.setLayout(borderLayout1);
    this.setBackground(UIManager.getColor("EditorPane.selectionBackground"));
    jPanel2.setLayout(null);
    jPanel2.setBackground(UIManager.getColor(
    "InternalFrame.activeTitleBackground"));
    jPanel2.setMaximumSize(new Dimension(100, 100));
    jPanel2.setMinimumSize(new Dimension(100, 100));
    jPanel2.setPreferredSize(new Dimension(100, 100));
    jPanel3.setBackground(new Color(255, 231, 0));
    jPanel3.setPreferredSize(new Dimension(60, 10));
    jButton1.setBackground(Color.white);
    jButton1.setBorder(BorderFactory.createLineBorder(Color.black));
    jButton1.setPreferredSize(new Dimension(50, 50));
    //jButton1.setIcon(new ImageIcon(desktop_panel.class.getResource("icons/info.gif")));
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton1_mouseClicked(e);
    pan_workspace.setBackground(UIManager.getColor(
    "List.selectionBackground"));
    pan_workspace.setOpaque(false);
    pan_workspace.setAlignmentX((float) 0.0);
    pan_workspace.setAlignmentY((float) 0.0);
    pan_workspace.setLayout(null);
    win_memory.setToolTipText("");
    win_memory.getContentPane().setBackground(SystemColor.controlDkShadow);
    win_memory.setTitle("memory");
    win_memory.setBorder(border2);
    win_memory.setIconifiable(true);
    win_memory.setNormalBounds(new Rectangle(10, 10, 381, 254));
    win_memory.setPreferredSize(new Dimension(381, 254));
    win_memory.setMinimumSize(new Dimension(381, 254));
    win_info.setFrameIcon(null);
    win_info.setPreferredSize(new Dimension(269, 230));
    win_info.setMinimumSize(new Dimension(269, 230));
    win_info.setBorder(border2);
    win_info.getContentPane().setBackground(UIManager.getColor(
    "CheckBoxMenuItem.selectionBackground"));
    win_info.setMaximumSize(new Dimension(100, 100));
    win_info.setResizable(true);
    win_info.setIconifiable(true);
    win_info.setTitle("kevin OS info");
    but_collect.setBackground(Color.orange);
    but_collect.setText("garbage collector");
    but_collect.setBounds(new Rectangle(13, 114, 162, 31));
    but_collect.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    but_collect_mouseClicked(e);
    but_refresh.setText("refresh");
    but_refresh.setBounds(new Rectangle(11, 150, 162, 32));
    but_refresh.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    but_refresh_mouseClicked(e);
    nb_free.setBackground(Color.white);
    nb_free.setDisabledTextColor(Color.white);
    nb_free.setEditable(false);
    nb_free.setBounds(new Rectangle(107, 40, 108, 22));
    jPanel4.setBackground(UIManager.getColor(
    "InternalFrame.activeTitleBackground"));
    jLabel2.setBackground(Color.pink);
    jLabel2.setFont(new java.awt.Font("Dialog", 1, 50));
    jLabel2.setForeground(Color.red);
    jLabel2.setText("-OS-");
    jLabel2.setBounds(new Rectangle(98, 12, 139, 52));
    ed_jdk_path.setBackground(Color.white);
    ed_jdk_path.setDisabledTextColor(Color.white);
    ed_jdk_path.setEditable(false);
    ed_jdk_path.setBounds(new Rectangle(104, 14, 190, 22));
    nb_total.setBackground(Color.white);
    nb_total.setDisabledTextColor(Color.white);
    nb_total.setEditable(false);
    nb_total.setBounds(new Rectangle(228, 40, 108, 22));
    jLabel3.setToolTipText("");
    jLabel3.setText("free");
    jLabel3.setBounds(new Rectangle(106, 70, 112, 16));
    jLabel5.setBounds(new Rectangle(228, 70, 112, 16));
    jLabel5.setText("total");
    jLabel5.setToolTipText("");
    win_terminal.setTitle("terminal");
    jPanel5.setLayout(borderLayout2);
    jButton3.setPreferredSize(new Dimension(50, 27));
    jButton3.setText("cube");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton3_actionPerformed(e);
    jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton3_mouseClicked(e);
    jButton4.setText("test");
    jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton4_mouseClicked(e);
    jButton5.setText("skin cool");
    jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton5_mouseClicked(e);
    jButton6.setText("skin xp");
    jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton6_mouseClicked(e);
    jButton7.setText("test applet");
    jButton7.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton7_actionPerformed(e);
    win_memory.getContentPane().add(jPanel4, BorderLayout.CENTER);
    jPanel4.setLayout(null);
    jPanel4.setMinimumSize(new Dimension(100, 100));
    jPanel4.setPreferredSize(new Dimension(100, 100));
    jLabel6.setText("java memory");
    jLabel6.setBounds(new Rectangle(16, 40, 78, 18));
    jLabel4.setText("jdk path");
    jLabel4.setBounds(new Rectangle(18, 16, 76, 18));
    this.add(jPanel3, BorderLayout.WEST);
    jPanel3.add(jButton7);
    jPanel3.add(jButton1, null);
    jPanel3.add(jButton3, null);
    jPanel3.add(jButton4, null);
    jPanel3.add(jButton5, null);
    jPanel3.add(jButton6, null);
    this.add(pan_workspace, java.awt.BorderLayout.CENTER);
    jPanel4.add(jLabel4, null);
    jPanel4.add(jLabel6, null);
    jPanel4.add(but_collect, null);
    jPanel4.add(ed_jdk_path, null);
    jPanel4.add(nb_free, null);
    jPanel4.add(nb_total, null);
    jPanel4.add(but_refresh, null);
    jPanel4.add(jLabel3, null);
    jPanel4.add(jLabel5, null);
    win_info.getContentPane().add(jPanel2, BorderLayout.CENTER);
    jPanel2.add(jButton2, null);
    jPanel2.add(jLabel1, null);
    jPanel2.add(jLabel2, null);
    tabber.add(list1, "list1");
    tabber.add(list_system, "list_system");
    tabber.add(list3, "list3");
    void but_refresh_mouseClicked(MouseEvent e) {
    nb_free.setText(String.valueOf(java.lang.Runtime.getRuntime().
    freeMemory()));
    nb_total.setText(String.valueOf(java.lang.Runtime.getRuntime().
    totalMemory()));
    void jButton1_mouseClicked(MouseEvent e) {
    win_info.show();
    win_info.setLocation(0, 0);
    //win_info.setSize(100,100);
    void but_collect_mouseClicked(MouseEvent e) {
    java.lang.Runtime.getRuntime().gc();
    but_refresh_mouseClicked(e);
    //list_system.add("collecting memory");
    void jButton3_mouseClicked(MouseEvent e) {
    //win_cube.begin_anim();
    void jButton4_mouseClicked(MouseEvent e) {
    thread_load_j3d load = new thread_load_j3d();
    load.start();
    void jButton6_mouseClicked(MouseEvent e) {
    try {
    Skin skin = null;
    //windows xp
    skin = SkinLookAndFeel.loadThemePack("skins/BeOS-theme.jar");
    // set the skin
    SkinLookAndFeel.setSkin(skin);
    // ask Swing to use Skin Look And Feel
    UIManager.setLookAndFeel(
    "com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
    SwingUtilities.updateComponentTreeUI(this);
    this.validate();
    this.updateUI();
    } catch (Exception er) {
    System.out.println("Failed loading L&F: ");
    er.printStackTrace();
    void jButton5_mouseClicked(MouseEvent e) {
    try {
    Skin skin = null;
    skin = SkinLookAndFeel.loadThemePack("skins/themepack.zip");
    // set the skin
    SkinLookAndFeel.setSkin(skin);
    // ask Swing to use Skin Look And Feel
    UIManager.setLookAndFeel(
    "com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
    } catch (Exception er) {
    er.printStackTrace();
    void jButton3_actionPerformed(ActionEvent e) {
    thread_load_cube load = new thread_load_cube();
    load.start();
    public void jButton7_actionPerformed(ActionEvent e) {
    JApplet applet=null;
    frame_applet frame=null;
    try{
    //ExtClassLoader ecl = new ExtClassLoader("/home/kevinet/CODE/JAVA/jlguiapplet2.3.1-selfsigned/lib/jlguiapplet2.3.jar");
    //Class demo = ecl.loadClass("javazoom.jlgui.player.amp.PlayerApplet");
    Class demo = java.lang.ClassLoader.getSystemClassLoader().loadClass("kevin_shell.Kdemos.test_applet");
    applet = (JApplet) demo.newInstance();
    frame=new frame_applet(applet);
    } catch (ClassNotFoundException cnfe) {
    cnfe.printStackTrace();
    System.out.println("problem with class");
    catch (IllegalAccessException iae) {
    iae.printStackTrace();
    System.out.println("acces problem");
    catch (InstantiationException ie) {
    ie.printStackTrace();
    System.out.println("instance");
    System.out.println("hello");
    pan_workspace.add(frame);
    applet.init();
    //applet.setLocation(0,0);
    applet.start();
    frame.setVisible(true);
    frame.show();
    frame.setLocation(300, 300);
    frame.setSize(300, 300);
    frame.setResizable(true);
    frame.setTitle("test applet");
    frame.setIconifiable(true);
    frame.setClosable(true);
    }

    What about calling getLocation on the applet itself?
    Otherwise, if you are using Swing, you can try (where "this" is the applet object):
    javax.swing.SwingUtilities.getWindowAncestor(this).getLocation();
    or
    javax.swing.SwingUtilities.convertPointToScreen(this.getLocation(), this);
    The latter should work, at least.

  • InternalFrame repaint problem, pls help

    I am develop my final year project which is a drawing tool using the Model-View-Controller with Observer and internalFrame. When more than one document is create in the program, the content of activated internalFrame can display properly, but the problem is that other internalFrame also repaint the content become to the activated internalFrame content.
    How can i make other inernalFrame repaint the content properly??
    public class Sketcher
    public static void main(String[] args)
    theApp = new Sketcher();
    theApp.init();
    public void init()
    window = new SketchFrame("Sketcher", this); // Create the app window
         window.setBounds(0,0,500,500);
    window.addWindowListener(new WindowHandler() // Add window listener
    // Handler for window closing event
    public void windowClosing(WindowEvent e)
    {  window.checkForSave();  };
    desktop = new JDesktopPane(); //a specialized layered pane
    createFrame();
    window.getContentPane().add(desktop, BorderLayout.CENTER);
    window.setVisible(true);
    // Return a reference to the application window
    public SketchFrame getWindow()
    return window;
    // Return a reference to the model
    public SketchModel getModel()
    return sketch;
    // Return a reference to the view
    public SketchView getView()
    return view;
    // Handler class for window events
    class WindowHandler extends WindowAdapter
    // Handler for window closing event
    public void windowClosing(WindowEvent e)
    // Code to be added here later...
    public void insertModel(SketchModel newSketch)
         MyInternalFrame frame2 = new MyInternalFrame();
         frame2.setVisible(true); //necessary as of kestrel
         sketch2 = new SketchModel(); // Create the model
         view2 = new SketchView(this); // Create the view
    sketch.addObserver((Observer)view2); // Add the view as observer
    sketch.addObserver((Observer)window); // Add the app window as observer
         JComponent c = (JComponent) frame2.getContentPane();
         c.add(view, BorderLayout.CENTER);
         desktop.add(frame2);
         try {
         frame2.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    protected void createFrame() {
    MyInternalFrame frame = new MyInternalFrame();
         frame.setVisible(true); //necessary as of kestrel
         sketch = new SketchModel(); // Create the model
         view = new SketchView(this); // Create the view
              JComponent c = (JComponent) frame.getContentPane();
         sketch.addObserver((Observer)view); // Register the view with the model
         sketch.addObserver((Observer)window); // Register window as observer
    c.add(view, BorderLayout.CENTER);
    desktop.add(frame);
    try {
    frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    JDesktopPane desktop;
    private JTextArea JtextArea;
    private SketchModel sketch, sketch2; // The data model for the sketch
    private SketchView view, view2; // The view of the sketch
    private static SketchFrame window; // The application window
    private static Sketcher theApp; // The application object

    You should call frame2.setVisible(true) after the addition of view in the contentPane of the frame :
    public void insertModel(SketchModel newSketch) {
       MyInternalFrame frame2 = new MyInternalFrame();
       sketch2 = new SketchModel(); // Create the model
       view2 = new SketchView(this); // Create the view
       sketch.addObserver((Observer)view2); // Add the view as observer
       sketch.addObserver((Observer)window); // Add the app window as observer
       JComponent c = (JComponent) frame2.getContentPane();
       c.add(view, BorderLayout.CENTER);
       desktop.add(frame2);
       try {
           frame2.setSelected(true);
       catch (java.beans.PropertyVetoException e) {}
       frame2.setVisible(true); //necessary as of kestrel
    }I hope this helps,
    Denis

  • I am having problem adding internalFrame to a frame

    Hi,
    I am not able to see the internalframe in a frame but my main frame is showing up properly. I have added the internalframe to the desktop.
    can somebody help me out.
    code for the internalframe.
    public void createInternalFrame() { 
    // Use a suitable internal frame constructor.
    JInternalFrame iFrame = new JInternalFrame(
    "Calendar",
    true, // can be resized
    true, // can be closed
    true, // can be maximized
    false); // can be iconified
    // iFrame.setLocation(70, 80);
    iFrame.setSize(300, 200);
    iFrame.setVisible(true);
    desktop.add(iFrame);
    container.add(desktop); //container is the contentpane.
    iFrame.moveToFront();
    // desktop.setOpaque(true);
    iFrame.show();
    // iFrame.validate();
    System.out.println("button 2");
    try { 
    iFrame.setSelected(true);
    } catch (java.beans.PropertyVetoException ex) { 
    System.out.println(
    "Exception while selecting an internal frame");
    }

    The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html]How to Use Internal Frames has working examples.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Regarding panels and internalframes

    Hello! I've been working at this problem for hours and I still can't seem to find a way to work it out. Anyway, hopefully someone will hear me out and help me out. I can't seem to create internal frames in java.
    I've created a class that extends JFrame. I then divided this into two panels. What I wanted to do was to have the second panel contain internal frames. So what I did was contentPane.add(new InternalFrame);
    The class InternalFrame simply extends JPanel. The problem is here.
    In my InternalFrame constructor, I've created a JDesktopFrame which will hold my internal frames. and then I created JInternalFrame and added it into the desktopframe. The problem is, it doesn't show. Is there anyone who could help me out? What am I doing wrong?
    Thanks!

         public classTry()
              JInternalFrame iframe = new JInternalFrame("Try",true,true,true,true);
              iframe.setSize(256,256);      
              iframe.pack();
              iframe.show();
    Here's the code snippet from my extends JFrame class:
    desktop = new JDesktopPane();
              this.getContentPane().add(desktop);
              desktop.add(new classTry());
                   this.pack();
         this.show();
    Thanks for taking time. I'm still trying to work on it as well though.

  • Identify if internalFrame is open or closed in desktopPane

    Hi guys. I was wondering if there was any code which could identify if a particular internalFrame is open or close inside a JDesktopPane? The example code are as followed.
    public class jFrame2 extends javax.swing.JFrame {
        JInternalFrame jif1 = new JInternalFrame();
        JInternalFrame jif2 = new JInternalFrame();
        JButton btnOne = new JButton("Frame 1");
        JButton btnTwo = new JButton("Frame 2");
        public jFrame2() {
            loadContents();
        public void loadContents() {
            // Load all contents of the main Frame except the two JInternalFrames
        private void btnOneActionPerformed(java.awt.event.ActionEvent evt) {
            // Load JInternalFrame jif1
        private void btnTwoActionPerformed(java.awt.event.ActionEvent evt) {
            // Load JInternalFrame jif2
    }I just need a code which could return if internalFrame is open inside the JDesktopPane.

    Some time ago I was trying to achieve the same (or sort of) and came out with this:
        public void hasJif(String title){
            JInternalFrame [] jifs = win.desktop.getAllFrames();
            for(int i = 0; i < jifs.length; i++){
                if(jifs.getTitle().equals(title)){
    jifs[i].dispose();
    break;
    }win is the JFrame, desktop is the JDesktopPane, title as it suggests is the JIF's title that you're looking for, and if it's already in the JDP it is disposed, I don't know if this approach is "neat" (and i guess is not :P) but still it might help you, Here is the  [JIF API|http://java.sun.com/javase/7/docs/api/javax/swing/JInternalFrame.html]  that is always helpful.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Iconifying the InternalFrame -- Urgent

    When the layout of desktop pane is set to GridLayout, iconifying the internal frames on the desktop pane displaying as Buttons occupying the whole desktop.
    I want to arrange the InternalFrames like in windows at the taskbar
    Scenario:
    I tried to arrange the InternalFrame on the Desktop Pane in Tile Horizontal, Tile Vertical and Cascade windows like in Windows fashion. But when they arranged in Horizontal and Vertical mode, when I tried to iconfying an Internal Frame, it is occupying the whole screen.
    Requirement:
    I want the internal frame has to be dispalyed as a small button at the south position like in windows.
    Thanks in Advance
    Meghu

    When the layout of desktop pane is set to GridLayout, iconifying the internal frames on the desktop pane displaying as Buttons occupying the whole desktop.
    I want to arrange the InternalFrames like in windows at the taskbar
    Scenario:
    I tried to arrange the InternalFrame on the Desktop Pane in Tile Horizontal, Tile Vertical and Cascade windows like in Windows fashion. But when they arranged in Horizontal and Vertical mode, when I tried to iconfying an Internal Frame, it is occupying the whole screen.
    Requirement:
    I want the internal frame has to be dispalyed as a small button at the south position like in windows.
    Thanks in Advance
    Meghu

  • The desktop - please help.

    Hello,
    I have a program as follows:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * A class to test the JDesktopPane methods.
    public class Test extends JFrame {
       private JDesktopPane desktop;
       public Test( ) {
          setTitle( "Desktop Test");
          setSize( 600, 400);
          setVisible( true);
          addWindowListener( new WindowAdapter( ) {
             public void windowClosing( WindowEvent e) {
                System.exit( 0);
          desktop = new JDesktopPane( );
          setContentPane( desktop);
          calculateSize( );
       public void calculateSize( ) {
          System.out.println( "Width is: " + desktop.getWidth( ));
          System.out.println( "Height is: " + desktop.getHeight( ));
          System.out.println( "Desktop is: " + desktop);
       public static void main( String[] args) {
          Test t = new Test( );
    }Why are the getWidth() and getHeight() methods (of the JDesktopPane class) returning 0, and why is the line:
    System.out.println( "Desktop is: " + desktop);returning the size of the desktop pane as 0x0. Since internalFrames can be added to this desktop at any location it must have some dimension (and not 0x0), so please can you help and show me how to obtain the the width and height of the desktop.
    Thank you in advance.

    OK what you need to do is add a "t.show()" command in the "main" method to show the frame, the frame hasn't been painted yet, so it has no dimension.

  • JscrollPane, Resize when InternalFrame maximize

    Hello all. I have 4 Internal Frames that contain 1 Jtable´s each, and all JTable´s has a JscrollPane. I have the four Internal frames added to a JFrame using GridLayout.. I add code below thats important.
    // Create an Desktop For That All Four I-Frame Use
    JDesktopPane forInternalFrameDesktop = new JDesktopPane();
    // Create an Internal Frame For CustomTable.
    JInternalFrame customerFrame = new JInternalFrame("Add Customer To Order",true,false,true,true);
    // Create Table For Customer InternalFrame.
    customerModel = new DefaultTableModel(customerRow,customerCol);
    customerTable = new JTable(customerModel)
    customerTable.setOpaque(true);
    // Create an ScrollPane for customerTable. 
    JScrollPane scroll = new JScrollPane(customerTable);
    scroll.set //  ? What will i put here
    // Set Size for customFrame
    customerFrame.setBounds(0, 0, 500,210);
    // Add customFrame to the Desktop.
    forInternalFrameDesktop.add(customerFrame);
    customerFrame.setVisible(true);
    // This is in MainFrame. an Normal JFrame that uses GridLayout To Lay out my Four I-Frames.
    GridLayout MstLayout = new GridLayout(0,2);
    mstFrame.setLayout(MstLayout);
    mstFrame.add(customerIFrame());
    mstFrame.add(productInternalFrame());
    mstFrame.add(orderReadyInternalFrame());
    mstFrame.add(orderDoneInternalFrame());When i maximize any of the four I-Frames, or the main frame i want the ScrollPane to follow. I know there is 1 row command to do that, had it before, but have forgott it. Anyone that has better memory then me?

    I use one
    JDesktopPane forInternalFrameDesktop = new JDesktopPane();I use four.
    private JInternalFrame orderDoneInternalFrame() {
            JInternalFrame orderDone = new JInternalFrame("Order Ready to Send",true,false,true,true);
            JPanel panel = new JPanel();
            orderDoneCol.addElement("Customer ID");
            orderDoneCol.addElement("Product Id");
            orderDoneCol.addElement("Quantity");
            orderDoneModel = new DefaultTableModel(orderDoneRow,orderDoneCol);
            orderDoneTable = new JTable(orderDoneModel);
            orderDoneTable.getTableHeader().setReorderingAllowed(false);
            JScrollPane scroll = new JScrollPane(orderDoneTable);
            orderDone.setBounds(510,320, 500,300);
            orderDone.add(panel);
            panel.add(scroll);
            forInternalFrameDesktop.add(orderDone);
            orderDone.pack();
            orderDone.setVisible(true);
            return orderDone;
        }And one mainFrame holding it all.
    public JFrame productFrame() {
            JFrame mstFrame = new JFrame();
            GridLayout MstLayout = new GridLayout(0,2);
            mstFrame.setLayout(MstLayout);
            mstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            mstFrame.setSize(1000,700);
            mstFrame.setJMenuBar(openMenu());
            mstFrame.add(customerInternalFrame());
            mstFrame.add(productInternalFrame());
            mstFrame.add(orderReadyInternalFrame());
            mstFrame.add(orderDoneInternalFrame());
            mstFrame.pack();
            mstFrame.setVisible(true);
            return mstFrame;
    }Does this make sence to you? Is this the wrong way to handle InternalFrames?

  • PhotoShop CS2 Bridge caused strange loss of desktop visibility/memory ??

    I have a G5 (Duel) running Tiger 10.4.6. Just lately the Bridge in Photoshop CS2 has not been working too well - it became very slow and sometimes didn't "see" my images. Yesterday I could get it to find my image folders at all. Then all my desktop started to look weird - even when I wasn't using the Bridge. So I closed all the applications and restarted the computer. To my horror all my desktop and preferences (dock, safari, desktop picture, folders etc.) had been lost. At first I thought I had somehow lost all my image folders but using spotlight I found them all there - distribted in places I had never put them. I sorted everything out again and re-did all my customised stuff but it was scary! At no time did the computer give me any warning of any trouble. It did not crash or anything. I was running QuarkXpress 5 (classic 9) as well and had a Skype window open (although I wasn't using it to talk at the time) Does anyone have any suggestions as to why this happened - has it happened to anyone else ? Thanks for any help.. Diana
    Mac G5   Mac OS X (10.4.6)   Duel 2.3 1.5 GB DDR SDRAM

    windscape wrote:
    Hi jamba,
    I think the issue is that your output of lspci shows no Audio device. Perhaps it got disabled in the BIOS? dmesg output may indicate something else afoot with your audio hardware.
    Hope that helps.
    I'll check out dmesg output.  also still need to check if something got disabled in the BIOS.
    !snd_intel8x0m  <- is your problem. Your sound module got blacklisted so un-list it. Modprobe it then try sound again or just reboot and it should work.
    moonswan.  snd_intel8x0 is the sound card (I think), in the alsa wiki it said it was recommended to blacklist snd_intel8x0m as a quirk fix. 
    No sound with or without it blacklisted still :-(
    thanks

Maybe you are looking for

  • JMS issues when migration from weblogic 9.2 to 10.3.5

    We are facing some issues when migration from weblogic 9.2 to 10.3.5 In  weblogic 9.2 :_ BMP Entity EJBs used in our project are read-only in nature using entity cache, below is the configuration details <!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Syst

  • Creating a package for proxy scenario?

    Hi friends, Can you give me some info regarding package creation while generating proxy? In which system we need to create package? Thanks in advance Bala

  • I want help

    Hello, i want to know on which line at which place my text cursor is moving. i want to access line number. as jn ms word where is your cursor you can get the line number and position. How can i get line number and position of text cursor in JTextPane

  • Nullpointer error when trying to test dispatcher in Identity Center

    Hi all, I am getting a nullpointer exception when I am trying to test my dispatcher in Identity Center.  In tools/options/java I have defined where the java.exe and jvm.ddl are located. I had tried to use a Java 1.6 before, but I got a 126 error whic

  • Adobe flash hangs on Safari install

    Hi all, Should I just be happy that Safari refuses to talk Flash, thus saving me from power sucking purgatory unless I want to launch Chrome?  Probably. Here's my setup: Mid-2010 MacBook Pro 15" now running a clean install of Yosemite, but I restored