Java Code Examples for javax.swing.JPanel.setVisible()

The following are Jave code examples for showing how to use setVisible() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BrainControl   File: StartGuiView.java   View Source Code Vote up 8 votes
protected void init(){
	agentPanels = new ArrayList<AgentPanel>();
	configPanel = new ConfigPanel(controller, model);

	this.setSize(configPanel.levelButtons.size() * 300 + 300, screenHeight/2);
	LayoutHelper.putGrid(this.getContentPane(), configPanel, 0, 0, 1,1, 1.0, 1.0);

	agentConfigPanel = new JPanel();
	GridBagLayout gBL = new GridBagLayout();
	gBL.rowWeights = new double[] {};
	gBL.columnWeights = new double[] {};
	agentConfigPanel.setLayout(gBL);
	agentConfigPanel.setVisible(true);

	LayoutHelper.putGrid(this.getContentPane(), agentConfigPanel, 0, 1, 1,1, 1.0, 1.0);
}
 
Example 2
Project: GamingPlatform   File: GiocoRecensioniView.java   View Source Code Vote up 7 votes
/**
 * Initialize the contents of the frame.
 */
public void initialize(){
	JPanel panel_7 = new JPanel();
	panel_7.setBounds(0, 0, 665, 415);
	frmPiattaformaGaming.getContentPane().add(panel_7);
	panel_7.setLayout(new MigLayout());
	panel_7.setVisible(true);
	
	JTextArea ta = new JTextArea();
	ta.setEditable(false);
	panel_7.add(ta);
	
	ArrayList<Recensione> al = new GiocoController(gioco).allReviews();
	for( Recensione r : al ){
		ta.setText(ta.getText() + "  - " +  r.getTesto() + "\n\n");
	}
	
	JButton btnBack = new JButton("Indietro");
	panel_7.add(btnBack, "pos 267px 345px, width 110, height 15");
	
	JScrollPane scroll = new JScrollPane(ta);
	scroll.setVerticalScrollBarPolicy ( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
	scroll.getVerticalScrollBar().setUnitIncrement(20);
	scroll.setSize(460,240);
	panel_7.add(scroll, "pos 0px 0px, width 660, height 340");
	
	btnBack.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			panel_7.setVisible(false);
			new GiocoView(frmPiattaformaGaming, utente, gioco);
	}});
}
 
Example 3
Project: incubator-netbeans   File: VisualDesignerPopupFactory.java   View Source Code Vote up 6 votes
void hideOtherMenus(JMenu menu) {
    for(JMenu m : containerMap.keySet()) {
        if(m != menu) {
            // hide if not an ancestor of this menu
            if(!isAncestor(m,menu)) {/* && 
                    (canvas.isTopLevelMenu(m) ||
                     canvas.hasSelectedDescendants(m))
                    ) {*/
                JPanel popup = containerMap.get(m);
                popup.setVisible(false);
            }
        }
    }
}
 
Example 4
Project: incubator-netbeans   File: MenuEditLayer.java   View Source Code Vote up 6 votes
void showMenuPopup(final JMenu menu) {
    getPopupFactory();
    // if already created then just make it visible
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel view = hackedPopupFactory.containerMap.get(menu);
        view.setVisible(true);
    } else {
        if(!isConfigured(menu)) {
            configureMenu(null, menu);
        }
        final JPopupMenu popup = menu.getPopupMenu();
        
        if(!(popup.getUI() instanceof VisualDesignerPopupMenuUI)) {
            popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
        }
        if (menu.isShowing()) {
            //force popup view creation
            hackedPopupFactory.getPopup(menu, null, 0, 0);
            
            // do later so that the component will definitely be on screen by then
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        popup.show(menu,0,menu.getHeight());
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        //ignore anyexceptions caused by showing the popups
                    }
                    
                }
            });
        }
    }
    this.validate();
}
 
Example 5
Project: incubator-netbeans   File: MenuEditLayer.java   View Source Code Vote up 6 votes
private void unconfigureMenu(final JMenu menu) {
    if (hackedPopupFactory == null) return; // Issue 145981

    // restore the UI
    menu.getPopupMenu().setUI(menuPopupUIMap.get(menu));
    
    // restore all children
    JPanel popup = hackedPopupFactory.containerMap.get(menu);
    if(popup != null) {
        for(Component c : popup.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent) c);
            }
        }
        
        //hide the popup(s) if it's still visible
        if(menu.getPopupMenu() != null) {
            menu.getPopupMenu().setVisible(false);
        }
        popup.setVisible(false);
        //layers.remove(popup);
    }
    VisualDesignerJPanelPopup pop = hackedPopupFactory.getPopup(menu);
    if(pop != null) {
        pop.hide();
    }
    if(popup != null) {
        popup.setVisible(false);
    }
    menu.setPopupMenuVisible(false);
    hackedPopupFactory.containerMap.remove(menu);
}
 
Example 6
Project: incubator-netbeans   File: ClassesControllerUI.java   View Source Code Vote up 5 votes
private void initComponents() {
    setLayout(new BorderLayout());

    final JPanel staticFieldsBrowserPanel = classesController.getStaticFieldsBrowserController().getPanel();
    staticFieldsBrowserPanel.setPreferredSize(new Dimension(250, 500));
    staticFieldsBrowserPanel.setVisible(false);

    contentsSplit = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                           classesController.getClassesListController().getPanel(), staticFieldsBrowserPanel);
    contentsSplit.setResizeWeight(1d);

    final JPanel legendPanel = new LegendPanel(false);
    legendPanel.setVisible(false);

    tweakSplitPaneUI(contentsSplit);

    add(contentsSplit, BorderLayout.CENTER);
    add(legendPanel, BorderLayout.SOUTH);

    staticFieldsBrowserPanel.addHierarchyListener(new HierarchyListener() {
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                    legendPanel.setVisible(staticFieldsBrowserPanel.isShowing());
                }
            }
        });
}
 
Example 7
Project: jaer   File: CollapsablePanel.java   View Source Code Vote up 5 votes
public CollapsablePanel(String title, JPanel contentPanel) {  
    super(new GridBagLayout());  
    this.title = title;
    
    GridBagConstraints gbc = new GridBagConstraints();  
    gbc.insets = new Insets(1, 3, 0, 3);  
    gbc.weightx = 1.0;  
    gbc.fill = GridBagConstraints.HORIZONTAL;  
    gbc.gridwidth = GridBagConstraints.REMAINDER;  
    
    selected = false;  
    headerPanel = new HeaderPanel();  
  
    setBackground(new Color(200, 200, 220));  
    this.contentPanel = contentPanel;  
  
    add(headerPanel, gbc);  

    
    add(contentPanel, gbc);  
    contentPanel.setVisible(false);  
  
    JLabel padding = new JLabel();  
    gbc.weighty = 1.0;  
    add(padding, gbc);  
  
}
 
Example 8
Project: TrabalhoFinalEDA2   File: mxVertexHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected JComponent createPreview()
{
	JPanel preview = new JPanel();
	preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
	preview.setOpaque(false);
	preview.setVisible(false);

	return preview;
}
 
Example 9
Project: Tarski   File: mxVertexHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected JComponent createPreview() {
  JPanel preview = new JPanel();
  preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
  preview.setOpaque(false);
  preview.setVisible(false);

  return preview;
}
 
Example 10
Project: VASSAL-src   File: TurnTracker.java   View Source Code Vote up 5 votes
public void addTo(Buildable b) {
  //Create the turn window
  turnWindow = new TurnWindow();
  turnWindow.pack();
  turnWindow.setVisible(false);

  launchWidget = new JPanel();
  launchWidget.setLayout(new BorderLayout());
  launchWidget.setBorder(BorderFactory.createEtchedBorder());
  GameModule.getGameModule().getToolBar().add(launchWidget);
  launchWidget.setAlignmentY(0.0F);
  launchWidget.setVisible(false);

  GameModule.getGameModule().getToolBar().add(launch);
  launch.setAlignmentY(0.0F);
  launch.setEnabled(false);

  setDocked(isDocked());

  GameModule.getGameModule().addCommandEncoder(this);
  GameModule.getGameModule().getGameState().addGameComponent(this);
  idMgr.add(this);

  //Global Property support
  lastCommand.addTo((MutablePropertiesContainer) b);
  lastTurn.addTo((MutablePropertiesContainer) b);

}
 
Example 11
Project: JITRAX   File: MainWindow.java   View Source Code Vote up 4 votes
public MainWindow() {
	workspace = new Workspace();
	barMenu = new MenuBar(workspace);
	queryList = new QueryList();
	console = new Console();
	databaseViewerPanel = new DatabaseViewer();

	setLocale(new Locale(DEFAULT_LANG));
	setResourceBundle(ResourceBundle.getBundle(BUNDLES_LOCATION, getLocale()));

	mainContainer = new JPanel(new BorderLayout());
	JPanel rightPanel = new JPanel(new BorderLayout());
	JPanel rightInnerPanel = new JPanel(new BorderLayout());
	
	rightInnerPanel.add(queryList, BorderLayout.WEST);
	rightInnerPanel.add(workspace, BorderLayout.CENTER);
	
	// HORIZONTAL SPLITPANE
	horSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
			rightInnerPanel, console);
	horSplitPane.setOneTouchExpandable(true);
	setUpHorSplitPaneHeight();
	
	// VERTICAL SPLITPANE
	//JSplitPane verSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, 
		//	databaseViewerPanel, rightPanel);
	//verSplitPane.setResizeWeight(VERTICAL_SPLITPANE_DEFAULT_WEIGHT);
	//verSplitPane.setOneTouchExpandable(true);
	
	rightPanel.add(horSplitPane, BorderLayout.CENTER);
	mainContainer.setBorder(new EmptyBorder(BORDER_GAP, BORDER_GAP, BORDER_GAP, BORDER_GAP));
	
	setLayout(new BorderLayout());
	mainContainer.add(databaseViewerPanel, BorderLayout.WEST);
	mainContainer.add(horSplitPane);
	add(mainContainer, BorderLayout.CENTER);
	
	mainContainer.setVisible(false);
	setJMenuBar(barMenu);
	setListeners();
	buildWindow();
	
	// Make relational algebra code editor focused
	addWindowFocusListener(new WindowAdapter() {
	    public void windowGainedFocus(WindowEvent e) {
	        getWorkspace().getRelationalAlgebraCodeEditor().requestFocusInWindow();
	    }
	});
	
	/**
	 * Redirect System.out to the console in the GUI.
	 */
	redirectOutputToConsole();

	translate();
}
 
Example 12
Project: incubator-netbeans   File: VCSCommitPanel.java   View Source Code Vote up 4 votes
protected void showProgress() {
    JPanel p = getProgressPanel();
    p.setVisible(true);
}
 
Example 13
Project: incubator-netbeans   File: FeaturesView.java   View Source Code Vote up 4 votes
private JPanel createContainer(ProfilerFeature feature) {
    JPanel container = new JPanel(new BorderLayout(0, 0));
    container.putClientProperty(ProfilerFeature.class, feature);
    
    JPanel results = feature.getResultsUI();
    JPanel xresults = new JPanel(new BorderLayout()) {
        public void paint(Graphics g) {
            super.paint(g);
            if (hintLabel != null) {
                Dimension dim = hintLabel.getSize();
                int x = (getWidth() - dim.width) / 2;
                int y = (getHeight() - dim.height) / 2;
                
                g.setColor(hintColor);
                g.fillRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                g.setColor(Color.LIGHT_GRAY);
                g.drawRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                
                g.translate(x, y);
                hintLabel.paint(g);
                g.translate(-x, -y);
            }
        }
    };
    xresults.add(results, BorderLayout.CENTER);
    container.add(xresults, BorderLayout.CENTER);
    
    JPanel settings = feature.getSettingsUI();
    if (settings != null) {
        JPanel pan = new JPanel(new BorderLayout(0, 0)) {
            public void setVisible(boolean visible) {
                super.setVisible(visible);
                for (Component c : getComponents()) c.setVisible(visible);
            }
        };
        pan.setOpaque(true);
        pan.setBackground(UIUtils.getProfilerResultsBackground());
        pan.add(settings, BorderLayout.CENTER);
        JSeparator sep = UIUtils.createHorizontalLine(pan.getBackground());
        pan.add(sep, BorderLayout.SOUTH);
        pan.setVisible(settings.isVisible());
        container.add(pan, BorderLayout.NORTH);
    }
    
    return container;
}
 
Example 14
Project: incubator-netbeans   File: CommitPanel.java   View Source Code Vote up 4 votes
private void hideSection(JPanel sectionPanel) {
    sectionPanel.setVisible(false);
}
 
Example 15
Project: AgentWorkbench   File: DynForm.java   View Source Code Vote up 4 votes
@Override
protected DefaultMutableTreeNode addSingleMultipleNode(DefaultMutableTreeNode node, boolean isInnerClass){
	
	// --- Get all needed information about the node, which has to be copied --------
	DynType dt = (DynType) node.getUserObject();
	String clazz = dt.getClassName();
	OntologySingleClassSlotDescription oscsd = dt.getOntologySingleClassSlotDescription();
	
	JPanel oldPanel = dt.getPanel();
	JPanel parentPanel = (JPanel) oldPanel.getParent();

	// --- Get parent node ----------------------------------------------------------
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); 
	int depth2WorkOn = parentNode.getLevel()-1;
	
	// --- Create the panel/node as needed as a copy of the current node ------------
	JPanel blindPanel = new JPanel();
	blindPanel.setLayout(null);
	DefaultMutableTreeNode newNode = null;
	
	if (isInnerClass==true) {
		newNode = this.createInnerElements(oscsd, clazz, depth2WorkOn+1, blindPanel, parentNode, true);
		if (oldPanel.isVisible()==false) {
			// --- Case special class: set invisible and small ------------ 
			this.setJPanelInvisibleAndSmall(newNode);
		}
		
	} else {
		newNode = this.createOuterElements(oscsd, depth2WorkOn, blindPanel, parentNode, true);
	}
	
	// --- Place the node at the right position in the tree -------------------------
	newNode.removeFromParent();
	int nodeIndexPos = parentNode.getIndex(node)+1;
	objectTree.insertNodeInto(newNode, parentNode, nodeIndexPos);
	
	// --- Set the size of the new Panel --------------------------------------------
	DynType dtNew = (DynType) newNode.getUserObject();
	JPanel newPanel = dtNew.getPanel();
	
	// --- Layout the new panel -----------------------------------------------------
	if (oldPanel.isVisible()==true) {
		// ----------------------------------------------------------------
		// --- The normal case for visible classes ------------------------
		// ----------------------------------------------------------------			
		this.setPanelBounds(newPanel);
		newPanel.setPreferredSize(newPanel.getSize());

		// --- Now place the new sub panel on the right super panel -------
		int movement = oldPanel.getHeight() + 2;
		int xPos = oldPanel.getX();
		int yPos = oldPanel.getY() + movement;
		newPanel.setBounds(xPos, yPos, newPanel.getWidth(), newPanel.getHeight());
		
		// --- Add to parent panel ----------------------------------------
		parentPanel.add(newPanel);
		parentPanel.validate();
		this.setPanelBounds(parentPanel);
		
		// --- Now move the rest of the elements on the form ----------------------------
		this.moveAfterAddOrRemove(movement, newNode);
		
	} else {
		// ----------------------------------------------------------------
		// --- The case for special classes, that have to be invisible ----
		// ----------------------------------------------------------------
		newPanel.setVisible(false);
		newPanel.setBounds(oldPanel.getBounds());
		
	}
	
	// --- refresh the GUI ----------------------------------------------------------
	this.adjustPreferredSize();
	
	return newNode;
}
 
Example 16
Project: TrabalhoFinalEDA2   File: mxEdgeHandler.java   View Source Code Vote up 4 votes
/**
 * 
 */
protected JComponent createPreview()
{
	JPanel preview = new JPanel()
	{
		/**
		 * 
		 */
		private static final long serialVersionUID = -894546588972313020L;

		public void paint(Graphics g)
		{
			super.paint(g);

			if (!isLabel(index) && p != null)
			{
				((Graphics2D) g).setStroke(mxSwingConstants.PREVIEW_STROKE);

				if (isSource(index) || isTarget(index))
				{
					if (marker.hasValidState()
							|| graphComponent.getGraph()
									.isAllowDanglingEdges())
					{
						g.setColor(mxSwingConstants.DEFAULT_VALID_COLOR);
					}
					else
					{
						g.setColor(mxSwingConstants.DEFAULT_INVALID_COLOR);
					}
				}
				else
				{
					g.setColor(Color.BLACK);
				}

				Point origin = getLocation();
				Point last = p[0];

				for (int i = 1; i < p.length; i++)
				{
					g.drawLine(last.x - origin.x, last.y - origin.y, p[i].x
							- origin.x, p[i].y - origin.y);
					last = p[i];
				}
			}
		}
	};

	if (isLabel(index))
	{
		preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
	}

	preview.setOpaque(false);
	preview.setVisible(false);

	return preview;
}
 
Example 17
Project: Tarski   File: mxEdgeHandler.java   View Source Code Vote up 4 votes
/**
 * 
 */
protected JComponent createPreview() {
  JPanel preview = new JPanel() {
    /**
     * 
     */
    private static final long serialVersionUID = -894546588972313020L;

    public void paint(Graphics g) {
      super.paint(g);

      if (!isLabel(index) && p != null) {
        ((Graphics2D) g).setStroke(mxSwingConstants.PREVIEW_STROKE);

        if (isSource(index) || isTarget(index)) {
          if (marker.hasValidState() || graphComponent.getGraph().isAllowDanglingEdges()) {
            g.setColor(mxSwingConstants.DEFAULT_VALID_COLOR);
          } else {
            g.setColor(mxSwingConstants.DEFAULT_INVALID_COLOR);
          }
        } else {
          g.setColor(Color.BLACK);
        }

        Point origin = getLocation();
        Point last = p[0];

        for (int i = 1; i < p.length; i++) {
          g.drawLine(last.x - origin.x, last.y - origin.y, p[i].x - origin.x, p[i].y - origin.y);
          last = p[i];
        }
      }
    }
  };

  if (isLabel(index)) {
    preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
  }

  preview.setOpaque(false);
  preview.setVisible(false);

  return preview;
}
 
Example 18
Project: JDigitalSimulator   File: Application.java   View Source Code Vote up 4 votes
private void configureGlassPane() {
	JPanel panel = (JPanel) getGlassPane();
	panel.setVisible(true);
	panel.setLayout(null);
}
 
Example 19
Project: AI-RRT-Motion-Planning   File: Visualiser.java   View Source Code Vote up 4 votes
private void createAnimationControls() {
	Font sliderFont = new Font("Arial", Font.PLAIN, 12);

	animationControls = new JPanel();
	animationControls.setLayout(new BoxLayout(animationControls,
			BoxLayout.PAGE_AXIS));

	JLabel manualLabel = new JLabel("Frame #");
	manualLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
	manualSlider = new JSlider(JSlider.HORIZONTAL);
	manualSlider.setPaintTicks(true);
	manualSlider.setPaintLabels(true);
	manualSlider.setFont(sliderFont);
	manualSlider.addChangeListener(manualSliderListener);
	manualSlider.addMouseListener(manualSliderClickListener);
	manualSlider.setMinorTickSpacing(1);
	manualSlider.addComponentListener(resizeListener);

	JLabel framerateLabel = new JLabel("Framerate");
	framerateLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
	framerateSlider = new JSlider(JSlider.HORIZONTAL, FRAMERATE_MIN,
			FRAMERATE_MAX, FRAMERATE_INIT);
	framerateSlider.setMajorTickSpacing(10);
	framerateSlider.setMinorTickSpacing(1);
	framerateSlider.setPaintTicks(true);
	framerateSlider.setPaintLabels(true);
	framerateSlider.setLabelTable(framerateSlider.createStandardLabels(10,
			10));
	framerateSlider.setFont(sliderFont);
	framerateSlider.addChangeListener(framerateListener);
	JPanel frameratePanel = new JPanel();
	frameratePanel.setLayout(new BoxLayout(frameratePanel,
			BoxLayout.PAGE_AXIS));
	frameratePanel.add(framerateLabel);
	frameratePanel.add(Box.createRigidArea(new Dimension(0, 2)));
	frameratePanel.add(framerateSlider);

	playPauseButton = new JButton(playIcon);
	playPauseButton.addActionListener(playPauseListener);
	stopButton = new JButton(stopIcon);
	stopButton.addActionListener(stopListener);

	animationControls.add(new JSeparator(JSeparator.HORIZONTAL));
	animationControls.add(Box.createRigidArea(new Dimension(0, 2)));
	animationControls.add(manualLabel);
	animationControls.add(Box.createRigidArea(new Dimension(0, 2)));
	animationControls.add(manualSlider);
	animationControls.add(Box.createRigidArea(new Dimension(0, 5)));
	JPanel p2 = new JPanel();
	p2.setLayout(new BoxLayout(p2, BoxLayout.LINE_AXIS));
	p2.add(playPauseButton);
	p2.add(Box.createRigidArea(new Dimension(10, 0)));
	p2.add(stopButton);
	p2.add(frameratePanel);
	animationControls.add(p2);
	animationControls.setVisible(false);
	animationControls.setBorder(BorderFactory.createEmptyBorder(0, 10, 5,
			10));
	container.add(animationControls, BorderLayout.SOUTH);
}
 
Example 20
Project: freecol   File: InfoPanel.java   View Source Code Vote up 4 votes
/**
 * Adds a panel to show information
 *
 * @param panel The panel to add.
 * @param internalTop The top position.
 * @param internalHeight The enclosing height.
 */
private void add(JPanel panel, int internalTop, int internalHeight) {
    panel.setVisible(false);
    panel.setLocation((getWidth() - panel.getWidth()) / 2, internalTop
            + (internalHeight - panel.getHeight()) / 2);
    add(panel);
}