How to make only one JFrame active at a time !!!

Hy, I have created a JFrame and I have placed a
JPanel in it. I also have a JButton "New" on the
JPanel. When I click on the "New" Button, another JFrame
appears. But I want ONLY one JFrame to be appeared
at a time. That is when a JFrame appears on the JPanel,
I should not be able to add another one.
If it is not possible to do this with JFrame, then how to do
it with a JDialog
How to do this.
thanks

You can declare a boolean variable in your class and set it to true if you open a window. Next time when you click the NEW button, check whether that boolean value is true or false. If true then don't open a new window. Also when u close the frame window, set the boolean value to false.

Similar Messages

  • How to make only one column non reorderble

    I want to make only one column (Column 0) of my JTable non reorderble.
    I also want to make the same column non resizable and I want to give it a specific size.
    Please help me on this?

    I have implemented a RowHeaderTable class which displays 1, 2, 3, ... in the first column. The column is in the scrollpane's RowHeaderView, so it is not resizable nor reorderable. But its width can be set in your code. Maybe this is what you need.
    Use the class the same way you use a JTable, except 3 added methods:
    getScrollPane();
    setMinRows(int r);
    setRowHeaderWidth(int w);
    Note: The table works perfectly in skinless L&F, such as the default java L&F. It looks ugly in Liquid L&F because I don't know how to steal column header's UI to use on a JList. If someone can help me on this one, I thank you in advance.
    * RowHeaderTable.java
    * Created on 2005-3-21
    * Copyright (c) 2005 Jing Ding, All Rights Reserved.
    * Permission to use, copy, modify, and distribute this software
    * and its documentation for NON-COMMERCIAL purposes and without
    * fee is hereby granted provided that this copyright notice
    * appears in all copies.
    * JING DING MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
    * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
    * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. JING DING
    * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
    * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
    import java.awt.BorderLayout;
    import java.awt.Component;
    import javax.swing.AbstractListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableModel;
    * @author Jing Ding
    public class RowHeaderTable extends JTable {
      private int minRows = 10;                         // Minimum size of the row header.
      private static final int DEFAULT_WIDTH = 30;
      private JScrollPane jsp;
      // The row header is a JList with the same appearance as the column header.
      private JList rowHeader;
      // Repaint row header whenever the table inserts or deletes rows.
      private TableModelListener tmListener = new TableModelListener(){
        public void tableChanged(TableModelEvent e){
          if(e.getType() != TableModelEvent.UPDATE)
            rowHeader.repaint();
      /** Create a new instance of RowHeaderTable.
       * @param model
      public RowHeaderTable(TableModel model){
        setModel(model);
        initializeHeader();
        jsp = new JScrollPane(this);
        jsp.setRowHeaderView(rowHeader);
      private void initializeHeader(){
        rowHeader = new JList(new AbstractListModel(){
          public int getSize(){ return Math.max(getModel().getRowCount(), minRows); }
          public Object getElementAt(int index){ return "" + ++index; }
        setRowHeaderWidth(DEFAULT_WIDTH);
        rowHeader.setFixedCellHeight(getRowHeight());
        rowHeader.setCellRenderer(new TableRowHeaderRenderer());
      public void setRowHeaderWidth(int w){
        rowHeader.setFixedCellWidth(w);
      public void setMinRows(int m){ minRows = m; }
      public void setModel(TableModel model){
        super.setModel(model);
        model.addTableModelListener(tmListener);
      /**Use this method to get the scrollPane, instead of new JScrollPane(table).
       * @return
      public JScrollPane getScrollPane(){ return jsp; }
      protected class TableRowHeaderRenderer implements ListCellRenderer{
        TableCellRenderer colHeaderRenderer;
        public TableRowHeaderRenderer(){
          JTableHeader header = getTableHeader();
          TableColumn aColumn = header.getColumnModel().getColumn(0);
          colHeaderRenderer = aColumn.getHeaderRenderer();
          if(colHeaderRenderer == null)
            colHeaderRenderer = header.getDefaultRenderer();
        public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean hasFocus){
          return colHeaderRenderer.getTableCellRendererComponent(
              RowHeaderTable.this, value, isSelected, hasFocus, -1, -1);
      public static void main(String[] args){
        try {
          UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
        }catch (Exception e){ e.printStackTrace(); }
        String[] columnNames = {"First Name",
            "Last Name",
            "Sport",
            "# of Years",
            "Vegetarian"};
              Object[][] data = {
                   {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
                   {"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
                   {"Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false)},
                   {"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
                   {"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)}
        DefaultTableModel dtm = new DefaultTableModel(data, columnNames);
        RowHeaderTable rht = new RowHeaderTable(dtm);
        rht.setMinRows(0);
        JFrame frame = new JFrame("RowHeaderTable Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(rht.getScrollPane(), BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
    }

  • How to make only one round corner?

    HI,
    How can I make only one (or 2) round corner on a square using the round corner effect?

    You don't say what version you're using, but I know that in CS3 (and probably CS4), there is a script installed that you can use.
    Draw your frame. Open the Scripts panel. Open the subfolders "Application", then "Samples", then "Javascript". With your Frame selected, double-click the script in the list named "CornerEffects.jsx". You'll be presented with a list of options to control what type of corner; and at the bottom the pop-up menu controls which corners get that type of corner.
    (Names may vary somewhat for CS4.)

  • How to open only one web page at a time?

    I used to have it set so when I opened a new web page, the previous one closed. Now, nothing closes automatically and I have about 50 pages open that I have to close. How do I set it so that only one page opens at a time?

    HI Janice,
    You can use a keyboard shortcut to close all windows in Safari. CommandShiftW.
    To close one window, Command + W.
    Carolyn

  • How to make only one row detail disclosed in uix:TableDetail

    I display row details to user with <uix:TableDetail>. I'd like to have only one detail displayed in the same time. When the page first loads, all details should be hidden, but whe user shows one another detail and one is already disclosed, only the new one should be displayed.
    I use <bc4juix:Table> and JDev 9.0.3.2
    Thanks in advance

    Viliam,
    The <table> element has the detailDisclosure complex attribute that you should use to control whether the details for table rows are disclosed. You should databind the detailDisclosure attribute to some DataObjectList that has the "disclosed" key set for each DataObject in the list. Then, when you disclose a new row, you should modify the DataObject for the corresponding row in the DataObjectLlist, and ensure that all other DataObjects set the "disclosed" key to false.
    Hope this helps,
    Ryan

  • How to use only one event case at a time??

    Using LabVIEW, using the event structure is it possible to have only one event case execute at a time. For example, having event case controlled by keyboard, and the other event case controlled by mouse (clicking buttons) and only one being able to execute, not simultaneously. I was considering using a switch of some sort, but each case does not have a "stop if true/false" so I am open to a new method or work around. I attached code. I do not want output to be able to be sent from the keyboard case and mouse case at the same time.
    Thanks,
    Andrew
    Attachments:
    WiFi Motor Control & Cam Stripped.vi ‏29 KB

    Ah, OK. all you need is to keep state in a shift register that ensures that all "key down/mouse down" events are discarded after each key down/mounse down event until a key up or mouse up (resp.) has occured.
    Overall, you code is still way to complicated for this simple task. For example, you could eliminate all these "select" primitives and place the approriate diagram constant inside the respective case. On the other hand it is too simplistic, because you would think that certain key combinations should be allowed concurrently (e.g. up and left).
    What does the receiver actually do with the codes? Do you have any documentation for this device?
    LabVIEW Champion . Do more with less code and in less time .

  • How to make only one colour show.

    Okay so say I take some footage I just shot and I want the colour blue to ONLY show up and all the other colours turn black and white, how would I do this?
    so ONLY blue will be in the footage, the other colours are black and white.
    Thanks

    Welcome to the forum.
    As stated, Leave Color Effect is exactly what you want. I'd like to put in a bit of a plug for Adobe Classroom in a Book Premiere Pro CS5, Adobe Press, out very soon, if not already on shelves where you are. The author covers this very Effect very well. Doubt that you will find a better tutorial on the Effect anywhere else.
    Also, it's great reading, and a book worth every $.
    Good luck,
    Hunt

  • Html Widget Crashes. How to load only one html widget at a time?

    I have a bunch of html widgets which are just tab navigators with html pages inside of them. I must have about 20 of them , mostly leading to google image searches for common searches I tend to do in my work. Instead of constantly searching for these things on google I just click on the tab with the google search for say..."tree images".  Its very fast and effecient for me.
    The problem is now I have so many that it crashes photoshop, or crashes adobe configurator most of the time if I try to open the panel file. Im guessing that the panel I made tries to load all 20 google image searches at once, instead of only loading the page I click on one at a time. Is there anyway to stop configurator from loading my html widgets that arent clicked on ?

    Anyone?

  • How to Show only One Credit Column at a time

    Hi,
            This is the Query :- it displays  all the credit columns simultaneously
    SELECT OINV.DocDate AS 'Posting date',
                          OCRD.GroupNum AS 'Payment Terms', OCRD.Balance AS 'Amount', OINV.DocTotal AS ' Debit Amount',
                          CASE WHEN OCRD.GroupNum = 7 THEN (OINV.DocTotal - OCRD.BALANCE) ELSE 0 END AS 'Credit 7',
                          CASE WHEN OCRD.GroupNum = 9 THEN (OINV.DocTotal - OCRD.BALANCE) ELSE 0 END AS 'Credi 9',
                          CASE WHEN OCRD.GroupNum = 5 THEN (OINV.DocTotal - OCRD.BALANCE) ELSE 0 END AS 'Credi 5',
    OINV.DocDueDate AS 'Due date ',OINV.Address
    FROM         OCRD INNER JOIN
                          OINV ON OINV.CardCode = OCRD.CardCode
    WHERE (OINV.DocDate  BETWEEN '04/08/11' AND '06/09/11'  AND OINV.CardCode = 'C00356')
    - it displays  all the credit columns simultaneously
    i want if GroupNum =7 then ,it should display the data in Credit 7 Column and rest Credit 5 and Credit 9 should be hide (Credit 5 and Credit 9 columns should not be shown in the data)
    Similarly, if GroupNum =5 then, it should display the data is Credit 5 Column and rest Credit 7 and Credit 9 should be hide
    similarly for GroupNum =9.
    Kindly give me the solution for this problem.
    Regards
    Rahul

    Hi Rahul.....
    Try this.....
    SELECT OINV.DocDate AS 'Posting date',
    OCRD.GroupNum AS 'Payment Terms', OCRD.Balance AS 'Amount', OINV.DocTotal AS ' Debit Amount',
    (Case When OCRD.GroupNum=7 Then (OINV.DocTotal - OCRD.BALANCE)
    Else
    Case When OCRD.GroupNum=9 Then (OINV.DocTotal - OCRD.BALANCE)
    Else
    Case When OCRD.GroupNum=5 Then (OINV.DocTotal - OCRD.BALANCE)
    Else 0
    End End End) As 'Credit',
    OINV.DocDueDate AS 'Due date ',OINV.Address
    FROM OCRD INNER JOIN
    OINV ON OINV.CardCode = OCRD.CardCode
    WHERE (OINV.DocDate BETWEEN '04/08/11' AND '06/09/11' AND OINV.CardCode = 'C00356')
    Regards,
    Rahul

  • Delete only one text message at a time w/o deleting entire conversation?

    Does anyone know how to delete only one text message at a time without having to delete the entire conversation? The only two options I get are "clear conversation" or "cancel."
    HP   Windows XP  

    That's the same option I get too. It seems to me I recall seeing somewhere that you could delete individual messages in a thread but I don't remember where.
    It seems silly to limit deletions to only the entire conversation since with most phones you can delete individual messages.

  • I want to make only one node draggable in the tree. How?

    I want to make only one node draggable in the tree. How?
    when we have only
    tree.setDragEnable(true)which makes draggable the entire nodes in the tree.
    Thanks -

    Hi Andrea
    Just to clarify things up: is this what you want?
    package treeDnD;
    * DragJustOneNode.java
    import java.awt.*;
    import java.awt.datatransfer.*;
    import java.awt.dnd.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class DragJustOneNode extends JFrame {
        private JTree tree;
        private DefaultTreeModel model;
        private DefaultMutableTreeNode root;
        public DragJustOneNode() {
            super("Only child 1 is draggable!");
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setSize(400,300);
            setLocationRelativeTo(null);
            tree = new JTree();
            tree.setDragEnabled(true);
            getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
            tree.setTransferHandler(new TreeTransferHandler());
            root = new DefaultMutableTreeNode(new NodeData(0, "root"));
            root.add(new DefaultMutableTreeNode(new NodeData(1, "child 1")));
            root.add(new DefaultMutableTreeNode(new NodeData(2, "child 2")));
            root.add(new DefaultMutableTreeNode(new NodeData(3, "child 3")));
            root.add(new DefaultMutableTreeNode(new NodeData(4, "child 4")));
            model = new DefaultTreeModel(root);
            tree.setModel(model);
        public static void main(final String args[]) {new DragJustOneNode().setVisible(true);}
    class NodeData{
        private int id;
        private String data;
        public NodeData(final int id, final String data){
            this.id = id;
            this.data = data;
        public int getId() {return id;}
        public void setId(final int id) {this.id = id;}
        public String getData() {return data;}
        public void setData(final String data) {this.data = data;}
        public String toString() {return data;}
    class TreeTransferable implements Transferable{
        private NodeData nodeData;
        public TreeTransferable(NodeData nodeData){
            this.nodeData = nodeData;
        public DataFlavor[] getTransferDataFlavors() {
            return new DataFlavor[]{DataFlavor.stringFlavor};
        public boolean isDataFlavorSupported(DataFlavor flavor) {
            return true;
        public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
            return nodeData;
    class TreeTransferHandler extends TransferHandler{
        private DefaultMutableTreeNode sourceNode, targetNode;
        public boolean canImport(final JComponent comp, final DataFlavor[] transferFlavors) {
            NodeData nodeData = (NodeData) (sourceNode).getUserObject();
            if(nodeData.getId() == 1) return true;
            return false;
        protected Transferable createTransferable(final JComponent c) {
            JTree tree = ((JTree)c);
            sourceNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            return new TreeTransferable((NodeData) sourceNode.getUserObject());
        public int getSourceActions(final JComponent c) {return DnDConstants.ACTION_MOVE;}
        public boolean importData(final JComponent comp, final Transferable t) {
            JTree tree = ((JTree)comp);
            DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
            targetNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode)targetNode.getParent();
            if(parent == null) return false;
            model.removeNodeFromParent(sourceNode);
            model.insertNodeInto(sourceNode, parent, parent.getIndex(targetNode));
            tree.setSelectionPath(new TreePath(model.getPathToRoot(sourceNode)));
            return true;
    }

  • How to make the condition type active

    hi,
    how to make the condition type active when its in inactive stage and its showing yellow triangle and y in the control features of it.
    and
    how to solve if is showing a statement as "INITAILISED".
    regards,
    balajit

    Dear Balaji,
    Yes it will come as Inactive mode.....If you make the 2 condition Class is same in single Pricing procedure ,In Standard system will display like this only..
    For Example:PR00-Condition class is Price
    EX00-Condition class is Price
    Then first Condition type will become Inactive.. change the Class of the Second Condition Type.
    Best Regards
    raj.

  • Make only one layer of a video brighter

    Hi,
    I have few layers of videos, I am trying to make only one layer brighter.
    How can I do that?
    Thanks,

    Hmm, select the layer in the timeline, go to the effects menu, scroll down to color correction, in that menu choose brightness and contrast and adjust the brightness to your liking. It will only be applied to that layer.

  • I was trying to add an itunes library to my computer, and now my itunes library can not be found. An ipod can be synced with only one iTunes library at a time. How can I find my Itunes library, complete with playlists ?

    I was trying to add an itunes library to my computer, and now my itunes library can not be found. An ipod can be synced with only one iTunes library at a time. How can I find my Itunes library, complete with playlists ?

    I have the same problem too and tried alot of things like time zone , restarting or changing DNS of wifi connection to 8.8.8.8 still nothing happens .. !!
    iPhone 5s, iOS 8.3

  • HT204088 How how can I synch my ipod + iphone music to my new computer? I get the same error  "my ipod or iphone is synched with another itunes library.An Ipod can be synched with only one itunes library at a time. What would I like to do Erase and Synch

    How can I synch my ipod & iphone music (purchased from itunes on my old laptop) to my new laptop? I keep getting the same message on my itunes on my new laptop: " The ipod/Iphone is synched with another itunes library. An ipod/iphone can be synched with only one itunes library at a time. What would you like to do - Erase and Synch or Transfer Purchases?" What do I do?
    A couple of other items:
    1) I am guessing Apple does not keep a history of all my music purchases? As I did not have my entire library backed-up anywhere, and relying on the music I have on my ipod and my iphone as my only source of itunes music....I have lost over 500 songs!!!
    2) I used to have an Apple account under another account name, and since have switched to a new account name. Is there anyway to find the history of purchases from my old Apple account name and transfer these over to my new account name and onto my new laptop?
    I hope someone can help, I am having a very difficult time trying to obtain answers. Angie

    The iphone/ipod is NOT a storage/backup device.  Not maintaining a backup copy is a big mistake.
    You can transfer itunes purchases from your iphone/ipod to your computer:
    Authorize your computer for all accounts and then click  File>Transfer Purchases

Maybe you are looking for