javax.swing.event.InternalFrameAdapter Java Examples

The following examples show how to use javax.swing.event.InternalFrameAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryBuilderInternalFrame.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public QueryBuilderInternalFrame(QueryBuilderTableModel queryBuilderTableModel,
                                 QueryBuilder queryBuilder)
{
    _dragObject = null;
    // Set some private variables
    _queryBuilderTableModel = queryBuilderTableModel;
    _queryBuilder = queryBuilder;

    // Create the node that will be used for the property sheet
    _node = new TableNode(queryBuilderTableModel.getFullTableName(),
                          queryBuilderTableModel.getCorrName(),
                          _queryBuilder);
    setResizable(true);
    setFrameIcon(null);
    setIconifiable(false);

    // Add an anonymous listener for the internalFrameOpened event
    addInternalFrameListener(new InternalFrameAdapter() {
        public void internalFrameOpened(InternalFrameEvent e) {
            // As soon as a frame is opened select it.
            // This doesn't seem to work.
            try {
                QueryBuilderInternalFrame.this.setSelected(true);
            } catch(PropertyVetoException pve) {
            }
        }});

    this.setBackground(Color.white);

}
 
Example #2
Source File: AbstractJDashlet.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public AbstractJDashlet() {
	props = new Properties();
	
	if (!confdir.exists())
	{
		boolean ret = confdir.mkdirs();
		logger.debug(confdir + " doesn't exist, create it="+ret);
		
	}

	addInternalFrameListener(new InternalFrameAdapter() {
		@Override
		public void internalFrameClosed(InternalFrameEvent e) {
			AbstractJDashlet dash = (AbstractJDashlet) e.getInternalFrame();
			dash.onDestroy();
			if (dash.getProperties().get("id") != null)
				FileUtils.deleteQuietly(new File(confdir, dash.getProperties().get("id") + ".conf"));
		}
	});
	
	loaded=true;
	setFrameIcon(getIcon());
	setTitle(getName());
	setResizable(true);
	setClosable(true);
	setIconifiable(true);
	setMaximizable(true);
	setBounds(new Rectangle(5,5, 536,346));
}
 
Example #3
Source File: Viewport.java    From opt4j with MIT License 4 votes vote down vote up
/**
 * Creates a widget as a {@link JInternalFrame}.
 * 
 * @param widget
 *            the widget
 * @return the constructed JInternalFrame
 */
protected JInternalFrame createInternalFrame(final Widget widget) {
	final JPanel panel = widget.getPanel();

	final String frameTitle;
	final Icon frameIcon;

	boolean resizable = true;
	boolean closable = true;
	boolean maximizable = true;
	boolean iconifiable = true;

	WidgetParameters parameters = widget.getClass().getAnnotation(WidgetParameters.class);
	if (parameters != null) {
		frameTitle = parameters.title();
		if (!parameters.icon().equals("")) {
			frameIcon = Icons.getIcon(parameters.icon());
		} else {
			frameIcon = null;
		}
		resizable = parameters.resizable();
		closable = parameters.closable();
		maximizable = parameters.maximizable();
		iconifiable = parameters.iconifiable();
	} else {
		frameTitle = null;
		frameIcon = null;
	}

	final JInternalFrame inFrame = new JInternalFrame(frameTitle, resizable, closable, maximizable, iconifiable);
	widget.init(this);

	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			inFrame.addInternalFrameListener(new InternalFrameAdapter() {
				@Override
				public void internalFrameClosed(InternalFrameEvent arg0) {
					widgets.remove(widget);
				}
			});
			inFrame.setFrameIcon(frameIcon);
			inFrame.getContentPane().setLayout(new BorderLayout());
			inFrame.getContentPane().add(panel, BorderLayout.CENTER);

			int windows = desktop.getAllFrames().length;
			windows = windows % 6;
			inFrame.setLocation(OFFSET * windows, OFFSET * windows);
		}
	});

	widgets.put(widget, inFrame);

	return inFrame;
}