How do I only allow 1 internal frame to be added?

Could you pls show me how can I do this, I need some code to learn how this code work.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Test1a extends JFrame
     private JLabel label1;
//     private JLabel label2;
     private JLabel label3;
     private JLabel label4;
     private JLabel label5;
     private JDesktopPane theDesktop;
     public Test1a()
          super("TESTING JLABEL");
          setLayout(new BorderLayout(5, 5));
        JMenuBar bar = new JMenuBar();
      JMenu addMenu = new JMenu( "Add" );
      JMenuItem newFrame = new JMenuItem( "Internal Frame" );
      addMenu.add( newFrame );
      bar.add( addMenu );
      setJMenuBar( bar );
       theDesktop = new JDesktopPane();
      add( theDesktop, BorderLayout.CENTER );
      newFrame.addActionListener(
         new ActionListener()
            // display new internal window
            public void actionPerformed( ActionEvent event )
               // create internal frame
               JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true);
               MyJPanel panel = new MyJPanel();
               frame.add( panel, BorderLayout.CENTER );
               frame.pack(); // set internal frame to size of contents
               theDesktop.add( frame );
               frame.setVisible( true );
          label1= new JLabel ();
          label1.setText("Label 1");
          add(label1, BorderLayout.WEST);
     //     label2= new JLabel ("Label 2", SwingConstants.CENTER);
     //   add(label2, BorderLayout.CENTER);
          label3= new JLabel ();
          label3.setText("Label 3");
          add(label3, BorderLayout.EAST);
          label4= new JLabel ("Label 4", SwingConstants.CENTER);
          add(label4, BorderLayout.NORTH);
          label5= new JLabel ("Label 5", SwingConstants.CENTER);
          add(label5, BorderLayout.SOUTH);
=============================================
import java.awt.*;
import javax.swing.*;
// class to display an ImageIcon on a panel
class MyJPanel extends JPanel
   private ImageIcon imageIcon;
   // load image
   public MyJPanel()
      imageIcon = new ImageIcon("yellowflowers.png");
   // display imageIcon on panel
   public void paintComponent( Graphics g )
      super.paintComponent( g );
      imageIcon.paintIcon( this, g, 0, 0 );
   public Dimension getPreferredSize()
      return new Dimension( imageIcon.getIconWidth(), imageIcon.getIconHeight() ); 
========================================
import javax.swing.*;
public class Test1b
     public static void main (String args[])
          Test1a test1a = new Test1a();
          test1a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          test1a.setSize(800, 600);
          test1a.setVisible(true);
}

You where given an answer in your original posting:
http://forum.java.sun.com/thread.jspa?threadID=5146301

Similar Messages

  • How do I only allow people on my buddy list to contact me (and stop spam)

    How do I only allow people on my buddy list to contact me (and stop spam)

    Go to iChats prefs/accounts

  • How can I only allow free apps to be downloaded?

    How can I only allow free apps to be downloaded to my IPhone 4S?

    Sorry, but there's no way I know of to restrict downloading to free apps only. You can turn off purchasing of apps completely, but if purchasing is allowed, it's open other than by age range. You can of course remove any purchase method, but I don't believe that blocks the purchase; you just end up owing money.
    Regards.

  • How to renable a closed Internal frame?

    Hi Friends,
    I got few intenal frames which can be closed at any point. I dont loose the Jinternalframe Object though. Can I again show the internal frame even if some closes the the internal frame window. Please let me know how ? I will be glad.
    Regards,
    Ravi.

    rather than actually closing the JInternalFrames, use setVisible(false) on a frame to hide it from the user. If you want to bring the window back simply call setVisible(true) on the frame you want to reinstate. You can override the default window closing behaviour to do this fairly easily.

  • How do I only allow certain users to print in color?

    Product Name: HP Color LaserJet Professional CP5225dn Printer (CE712A)
    Operating System Installed: Windows 7 Enterprise (64bit)
    I work at a K-12 school and purchased the HP Color LaserJet Professional CP5225dn Printer (CE712A) for use in our computer lab. I would like to know if it is possible to have it so that only certain users can print in color (possibly put a password on it). I know the cost for color is higher, and therefore, would like it so that students have to approve through teacher if they want to print in color.
    We are running it on our Print Server (networked) not through USB.
    Thank you for the help.

    Hi,
    That's a very good question actually. In my corporate networks, we are talking about hundreds of laser printers and the ONLY thing we can do: only allow people access to a set of mono laser printers, not all printers. For example, the following printer is using B&W as default but can't stop users to print in colors if they could access to the resourse:
    Regards. 
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How do I only allow SPECIFIC webpages the ability to refresh or redirect?

    Is there some way to have FIrefox only allow specific webpages the ability to reload or refresh a page? I already know of the
    Tools -> Advanced -> Warn me when webpages attempt to refresh or reload the page
    option. I am looking for the ability to only allow specific webpages, not ALL webpages.

    Without additional information on the addon, as the documentation provided is sorely lacking, this addon doesn't help much.
    Now if Firefox itself had a built-in whitelist / blacklist of pages allowed to redirect/refresh automatically, I'd be all for it.
    Appreciate the thought cor-el, but it doesn't help.

  • How do I only allow logged in users to see Wiki?

    I have set up a server and the website, but it only works if you forward the urls, in the DNS machine records, to the public ip address of my of my router. I only want to allow logged in users to be able to click on a wiki homepage link to see it. Also, typing in the internal ip address of a device on my network doesn't get me to my server unless I allow the Internet to see the wiki.
    So I would like to...
    1. Make users log in to be able to see anything, like people, profiles, and wikis.
    2. Allow intranet access to server with host names and server ip address
    3. Allow logged in VPN users to see the site (I'm guessing this would go along with number 2)
    4. If I need to add a custom site, how would I add the site so it would pop up when the URL is typed in and have a login window to be able to go the wiki site
    5. I don't want to mess up Profile Manager either
    I've tried many different things and can get one thing to work, but not the other.
    Thanks in advance!!!

    Files to change:
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclientbase/pu blic/javascripts/sprockets.js
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/app/co ntrollers/application_controller.rb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/app/he lpers/entity_url_helper.rb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/app/mo dels/sources/my_documents.rb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/app/mo dels/sources/my_favorites.rb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/app/vi ews/layouts/application.html.erb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/config /routes.rb
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclient/config /initializers/register_apple_plugins.rb
    Folder to delete to remove iPad version of wiki
    /Applications/Server.app/Contents/ServerRoot/usr/share/collabd/coreclientmobile/ public
    There are way to many lines of code in these files that are different to go through one by one.  I have put the files in google docs (server 2.2.1 mods). 
    There is a great program at the mac app store called CompareMerge you can go through the files line by line to see what is different. 
    Before doing anything I recommend coping all files that you are changing/deleting some where safe so if something goes wrong you can go back to the originals.
    Once all files have been replaced/deleted you have to open the server app and stop/start wikis

  • How do I only allow comments on certain pages?

    I have a Blog and I obviously don't want every page to allow comments. It seems that you allow comments or not. Surely this cant be. Do do you allow comments on some entries and not others.

    Doesn't anyone know if its possible?

  • How can I only allow my Apple TVs access to my LAN?

    In my set-up, I have three Apple TVs in separate rooms all connected to a LAN via their ethernet ports. They are connected via a switch to my Airport Extreme and my Mac Mini is also connected to Airport as an iTunes server. The Airport runs a WiFi network for internet access but I don't want people to be able to plug their computers into my LAN and have access to the whole set-up.
    What can I do to achieve this?
    I don't want the Apple TV's to rely on the WiFi so I can use MAC Address Filtering, since it is patchy and streaming HD videos is more stable via ethernet. I have looked into setting-up an 802.1x network but when investigating the Configurator app to set-up the Apple TVs to access an 802.1x network it refers only to WiFi set-ups again. Also, I don't know much about RAIDUS servers and authentication, such as whether I'd need any additional hardware etc.
    Any help would be gratefully received.
    JB

    ...any app launched from /Applications holds only the permissions of the user launching the app, regardless of the owner (presumably because anyone, including "root" can install applications into /Applications).
    It has nothing to do with where the application is installed. Any executable runs with the permissions of the user who runs it. The only exception is a binary executable with the SUID or SGID bit set, and then only if it's on the root device, and only if it's not an Aqua application. The SG/UID bits are ignored otherwise.
    So, anyone who has installed Wireshark from the "native .dmg" by drag-and-dropping won't be able to use the suid trick because the OS will ignore the suid permissions.
    Sorry, I don't understand this at all. Wireshark invokes dumpcap as a child process to capture packets. If dumpcap is installed anywhere on the root device as SUID root, then it will run as root regardless of who invokes it.
    The suid method will only work for Macports and Fink installations...
    That's not correct. There are many SUID or SGID executables in a default installation of the Mac OS, and none of them comes from MacPorts or Fink.

  • How can i only allow the activation of the JDialog on top?

    Hi to all,
    i have a problem with a mask swing
    Well, my problem is this:
    In a window, when i click on save button, it's open a customizing JDialog. But i would like how i can deny a click out of this JDialog, that is on top.
    In other words, in this situation, with a jdialog on top, if the user click once again on the save button or out of this jdialog, the jdialog must stay on top and active.
    How i can this?
    Please help me!!
    the code that realize my class is this:
    public class ConsegnaOrdineDialog extends JDialog implements ActionListener {
         private JOptionPane optionPane;
         private String dataOrdine;
         private JButton si, no;
         private JTextField dataConsegna;
         public ConsegnaOrdineDialog(String dataOrdine) {
              this.dataOrdine = dataOrdine;
              dataConsegna = new JTextField();
              si = new JButton("Si");
              no = new JButton("No");
              si.addActionListener(this);
              no.addActionListener(this);
              JPanel panel = new JPanel();
                 panel.setLayout(new BorderLayout(5, 10));
                 panel.add(dataConsegna, BorderLayout.NORTH);
                 panel.add(si, BorderLayout.WEST);
                 panel.add(no, BorderLayout.EAST);
              Object[] options = {panel};
              optionPane = new JOptionPane("La data �:",
                    JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.NO_OPTION,
                    null,
                    options,
                    dataConsegna);
              setContentPane(optionPane);
         public void actionPerformed(ActionEvent e) {
              if (e.getSource() == si) {
              if (e.getSource() == no) {
                   super.dispose();               
    }

    in the constructor
    setModal(true);

  • Internal frame dragging perfermance problem in JDK1.4.1

    Hi there,
    When using internal frame with outline(not faster or LIVE_DRAG_MODE) property with JDK 1.4.1_01 (windows), the speed of internal frame dragging is terrible(very very slow).
    The same code runs fine with JDK1.3.X, and it's performance(dragging speed) is acceptable(not very good, so so) when using JDK 1.4.0_X.
    I've tried both motheds to set the property as follow, and got the same result:
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    But, after I commented the line: g.setXORMode(Color.white); //line Num: 279
    in the class javax.swing.DefaultDesktopManager.java, the speed of dragging is very well(as same as when running with JDK1.3.X).
    My qestions are:
    - How can I improve the internal frame dragging performance in JDK 1.4.1_01(windows)?
    - Does my testing mean to a bug in the implementation of the abstract method Graphics.setXORMode() in the JDK 1.4.1_01 windows version ?
    TIA
    In terms of the test case, we may just use the follows:
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/InternalFrameDemo.java
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/MyInternalFrame.java

    Anyone know if this is registered as a bug? I couldn't find it.

  • Port Access mode allow tagged frames ?

    Hello,
    From my understanding Cisco Catalyst switch port access mode only allow untagged frames to be received and proceeded. Tagged frames received on access mode port should be discarded.
    But I have found in BCMSN course Student Guide following phrase
    If a non-802.1Q-enabled device or an access port receives an 802.1Q frame, the tag data is
    ignored, and the packet is switched at Layer 2 as a standard Ethernet frame.
    Is in this case term access related to non Cisco equipment ? Or where are some Cisco Catalysts HW/SW combinations in which access mode port accept also tagged frames ?
    With Best Regards
    Tomas

    Hello Tomas,
    802.1Q tagged frames with a vlan-id = access vlan of the port are accepted on Cisco Catalysts.
    for Sure it was in 2004-2005 when I did L2 security tests and read about the following:
    This is the basis for one of the L2 security attack that is called vlan hopping:
    if you send a frame with two 802.1Q tags and:
    a) the external tag vlan-id = port access vlan
    b) the same vlan is used as native vlan in a inter-switch trunk
    the attacker can send a frame from vlan X to vlan y bypassing L3 security and routing devices.
    the recommendation is to use as native vlan a dedicated vlan for all trunks that is never used on access ports.
    Hope to help
    Giuseppe

  • I have Snow Leopard and would like to upgrade to Moutain Lion OS but I am only allowed 3 gigs of download data /mo. and Mt.Lion is 4 gigs. So How can I obtain the upgrade. The apple store does not sell the upgrade on a CD. It is only available by download

    I have Snow Leopard OSx on my MacBookPro. I would like to upgrade to Mt.Lion. OSx but am only allowed 3 gigs/mo download of data from my internet provider. I've attempted to purchase a CD from Apple store but they said it's only available through on-line downloads. How can I upgrade?

    Contact Customer Service: Contacting Apple for support and service - this includes international calling numbers.

  • I downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    hi philly, thanks for getting back to me, especially on such a busy day.
    I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
    I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
    I have the 'icloud' enabled and wondered if it had anything to do with that.
    i have successfully downloaded another full album totally into the music app, but this first album is causing me problems.

  • I want to set up Firefox to only allow certain pages to load - how do I do this?

    My children are having my old laptop and I dont want them to be able to 'stumble' across anything unsuitable.
    How can I set up Firefox so that it only allows pages to load from websites I choose?
    Thanx!

    See:
    * https://support.mozilla.com/kb/Parental+controls
    * http://kb.mozillazine.org/Parental_controls

Maybe you are looking for

  • My iMac's iPhoto is crashing on startup on Mountain Lion. Help!

    Since upgrading my daughter's iMac to Mountain Lion from the latest version of Lion last night, it's crashing on startup every time. This happens even if I unmount the drive that has my photo library on it or try to start it in recovery mode to repai

  • Trouble with TO_TIMESTAMP converting from Java Date

    I have a Jelly script that initializes my database. I have some "TIMESTAMP" columns that I want to set to the current time. I set a variable at the top of the script to the current time, so I can use that throughout the script. The resulting excerpt

  • Macbook Desktop Question

    Hello, I am new to the Macbook just converted from PC! It is hard getting used to the system but i am trying to learn. I watch alot of youtube videos and i have seen that everyone has a hard drive icon on their desktop. Why is that? Is that a default

  • Case when null statement

    Afternoon Folks, The line highlighted in Bold is where I have the issue. I want it to pick up NULL or Blanks in the method type has well as types E,G,T. I've tried NULL is the statement, "", and '' put none of these work. What am I doing wrong? I'm u

  • Static Class Function vs. Instance Variables

    I'm making a Wheel class to spin the wheels on some toy trains as they move back and forth. Each wheel on the train is an instance of the Wheel class and there are several of them. I thought it would be great to just have a static class function to t