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

The following examples show how to use javax.swing.JPanel#setVisible() . 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: ZooFrame.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public void setBackButtonActionListener(ActionListener a) {
	buttonPanel = new JPanel();
	buttonPanel.setLayout(new BorderLayout());
	buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

	backButton = new JButton("Back");
	backButton.setFont(new Font(Font.SERIF, Font.PLAIN, 24));
	buttonPanel.add(backButton, BorderLayout.WEST);

	this.add(buttonPanel, BorderLayout.NORTH);
	backButton.addActionListener(a);

	// Clock display
	clockPanel = new JPanel(); 
	clockPanel.setToolTipText("Click to change time settings.");
	
	clockLabel = new JLabel();
	clockLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
	clockPanel.add(clockLabel);
	
	clockPanel.setVisible(false);
	buttonPanel.add(clockPanel, BorderLayout.EAST);
}
 
Example 2
Source File: MesquiteTabbedPane.java    From MesquiteCore with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setSelectedIndex2(int i){

	 int current = getSelectedIndex();
	if (current>=0) {
		JPanel p2 = panel.getTabPanel(current);
		if (p2 != null)
			p2.setVisible(false);
	}

	super.setSelectedIndex(i);


	JPanel p = panel.getTabPanel(i);
	//	setVisible(true);
	if (p != null) {
		p.setVisible(true);
		Graphics g = p.getGraphics();
		if (g!=null)
			g.setClip(null);
		p.invalidate();
	}
	invalidate();
	//	try {Thread.sleep(20);} catch (Exception e) {}
//	super.setSelectedIndex(i);
}
 
Example 3
Source File: QOptionPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
protected void updateCustomComponent(QOptionPane optionPane) {
	JPanel customCompContainer = getCustomComponentContainer(optionPane);
	JComponent comp = optionPane.getCustomComponent();
	customCompContainer.removeAll();
	if (comp == null) {
		customCompContainer.setVisible(false);
	} else {
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.weightx = 1;
		gbc.weighty = 1;
		gbc.fill = GridBagConstraints.BOTH;
		customCompContainer.setLayout(new GridBagLayout());
		customCompContainer.add(comp, gbc);
		customCompContainer.setVisible(true);
	}
}
 
Example 4
Source File: UI.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
public static JPanel createQueryResultPanel(DefaultTableModel tblQueryResultModel) {
  JPanel queryPanel = new JPanel();
  queryPanel.setMaximumSize(new Dimension(1000, 200));
  queryPanel.setPreferredSize(new Dimension(1000, 200));
  queryPanel.setLayout(new BoxLayout(queryPanel, BoxLayout.Y_AXIS));
  queryPanel.setVisible(true);
  
  final JTable tblQueryResult = new JTable(tblQueryResultModel);
   /* tblQueryResult.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    
    @Override
    public void valueChanged(ListSelectionEvent e) {
      int row = tblQueryResult.getSelectedRow();
      Point g = (Point) tblQueryResultModel.getValueAt(row, 4);
      map.zoomTo(g);
    }
  });*/
    
    JScrollPane tblQueryScrollPane = new JScrollPane(tblQueryResult);
    //tblQueryScrollPane.getViewport().setBackground(UI.COLOR_PURPLE);
    queryPanel.add(tblQueryScrollPane);
    
  return queryPanel;
}
 
Example 5
Source File: CSSStylesSelectionPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a panel that allows forcing of pseudo-classes.
 * 
 * @param pseudoClassToggle toggle-button used to show the panel.
 * @return panel that allows forcing of pseudo-classes.
 */
private JPanel createPseudoClassPanel(JToggleButton pseudoClassToggle) {
    final JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2,2));
    ResourceBundle bundle = NbBundle.getBundle(CSSStylesSelectionPanel.class);
    panel.add(createPseudoCheckBox(
            CSS.PseudoClass.ACTIVE,
            bundle.getString("CSSStylesSelectionPanel.pseudoClass.active"))); // NOI18N
    panel.add(createPseudoCheckBox(
            CSS.PseudoClass.HOVER,
            bundle.getString("CSSStylesSelectionPanel.pseudoClass.hover"))); // NOI18N
    panel.add(createPseudoCheckBox(
            CSS.PseudoClass.FOCUS,
            bundle.getString("CSSStylesSelectionPanel.pseudoClass.focus"))); // NOI18N
    panel.add(createPseudoCheckBox(
            CSS.PseudoClass.VISITED,
            bundle.getString("CSSStylesSelectionPanel.pseudoClass.visited"))); // NOI18N
    panel.setVisible(false);
    pseudoClassToggle.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JToggleButton source = (JToggleButton)e.getSource();
            panel.setVisible(source.isSelected());
        }
    });
    return panel;
}
 
Example 6
Source File: DerivationTreeFrame.java    From joshua with Apache License 2.0 5 votes vote down vote up
/**
 * The default constructor.
 */
public DerivationTreeFrame(int index, JList mainList) {
  super("Joshua Derivation Tree");
  this.mainList = mainList;
  setLayout(new BorderLayout());
  setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
  controlPanel = new JPanel(new BorderLayout());
  informationPanel = new JPanel(new GridLayout(3, 1));

  sourceLabel = new JLabel("source sentence");
  referenceLabel = new JLabel("reference translation");
  oneBestLabel = new JLabel("one best translation");

  informationPanel.add(sourceLabel);
  informationPanel.add(referenceLabel);
  informationPanel.add(oneBestLabel);
  informationPanel.setVisible(false);

  controlPanel.add(informationPanel, BorderLayout.SOUTH);

  initializeButtons();
  layoutControl();

  viewPanel = new JPanel(new BorderLayout());
  dv = null;

  dataSetIndex = index;
  targetColor = Browser.dataSetColors[dataSetIndex % Browser.dataSetColors.length];

  getContentPane().add(viewPanel, BorderLayout.CENTER);
  getContentPane().add(controlPanel, BorderLayout.SOUTH);
  // drawGraph();
  setVisible(true);
}
 
Example 7
Source File: VideoReceiver.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
 * ControllerListener for the Players.
 */
public synchronized void controllerUpdate(ControllerEvent ce) {

    Player p = (Player) ce.getSourceController();

    if (p == null)
        return;

    // Get this when the internal players are realized.
    if (ce instanceof RealizeCompleteEvent) {
        p.start();
        
        Component vc = p.getVisualComponent();
        System.out.println("Start1.1" + vc);
        if ( null != vc )
        {
            System.out.println("### visual component is " + vc);

            JFrame aFrame = new JFrame("Video Frame");
            JPanel aPanel = new JPanel();
            aPanel.setBounds(0, 0, 176, 144);
            aPanel.add(vc);
            aFrame.add(aPanel);

            aPanel.setBackground(Color.gray);

            vc.setVisible(true);
            aPanel.setVisible(true);
            aFrame.setVisible(true);
            aFrame.pack();
        }
    }

    if (ce instanceof ControllerErrorEvent) {
        p.removeControllerListener(this);
        System.err.println("Receiver internal error: " + ce);
    }

}
 
Example 8
Source File: SimpleXYChartUtils.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public static void setLegendVisible(JComponent chartUI, boolean visible) {
    JPanel legendPanel = (JPanel)chartUI.getClientProperty("legendPanel"); // NOI18N
    legendPanel.setVisible(visible);
    
    chartUI.doLayout();
    chartUI.repaint();
}
 
Example 9
Source File: AddAndMoveGraphicsApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a content pane.
 * 
 * @return a content pane.
 */
private static JPanel createContentPane() {
  JPanel contentPane = new JPanel();
  contentPane.setLayout(new BorderLayout());
  contentPane.setVisible(true);
  return contentPane;
}
 
Example 10
Source File: BinaryPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public BinaryPanel(final MainPanel mainPanel) {
    super(new BorderLayout());
    this.mainPanel = mainPanel;

    add(new JScrollPane(hexEditor), BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    JPanel buttonsPanel = new JPanel(new FlowLayout());
    bottomPanel.add(buttonsPanel, BorderLayout.EAST);
    add(bottomPanel, BorderLayout.SOUTH);

    // todo: honfika: dynamically resize the hex data
    /*addComponentListener(new ComponentAdapter() {

     @Override
     public void componentResized(ComponentEvent e) {
     setBinaryData(binaryDataTag);
     }
     });*/
    swfInsidePanel = new JPanel();
    swfInsidePanel.setBackground(new Color(253, 205, 137));
    swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    swfInsidePanel.add(new JLabel(AppStrings.translate("binarydata.swfInside")));
    swfInsidePanel.setFocusable(true);
    swfInsidePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    swfInsidePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            mainPanel.loadFromBinaryTag(binaryDataTag);
            swfInsidePanel.setVisible(false);
        }

    });
    add(swfInsidePanel, BorderLayout.NORTH);
    swfInsidePanel.setVisible(false);
}
 
Example 11
Source File: ParameterSetupDialogWithEmptyPreview.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  // initialize panels
  pnlPreview = new JPanel(new BorderLayout());
  pnlPreviewButtons = new JPanel(new FlowLayout());
  pnlParameters = new JPanel(new BorderLayout());
  newMainPanel = new JPanel(new BorderLayout());
  pnScroll = new JScrollPane();
  pnScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);


  // reorganize panels
  getContentPane().remove(mainPanel);
  mainPanel.remove(super.pnlButtons);
  pnScroll.setViewportView(mainPanel);
  mainPanel.setMinimumSize(new Dimension(400, 400));
  pnlParameters.add(pnScroll, BorderLayout.CENTER);
  pnlParameters.add(super.pnlButtons, BorderLayout.SOUTH);
  pnlPreview.add(pnlPreviewButtons, BorderLayout.SOUTH);
  newMainPanel.add(pnlParameters, BorderLayout.WEST);
  newMainPanel.add(pnlPreview, BorderLayout.CENTER);
  getContentPane().add(newMainPanel, BorderLayout.CENTER);

  pnlPreview.setVisible(false);

  // later add your preview via pnlPreview.add(YOUR_PANEL, BorderLayout.CENTER);
  // and your buttons to control the preview via pnlPreviewButtons.add(YOUR_BUTTON);
  updateMinimumSize();
  pack();
}
 
Example 12
Source File: MenuEditLayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 13
Source File: ScrollingPanel.java    From javamelody with Apache License 2.0 5 votes vote down vote up
private void addCurrentRequests() {
	addParagraphTitle(getString("Requetes_en_cours"), "hourglass.png");

	final Map<JavaInformations, List<CounterRequestContext>> currentRequests = getRemoteCollector()
			.getCurrentRequests();
	if (currentRequests.isEmpty()) {
		add(new JLabel(' ' + getString("Aucune_requete_en_cours")));
	} else {
		for (final Map.Entry<JavaInformations, List<CounterRequestContext>> entry : currentRequests
				.entrySet()) {
			final JavaInformations javaInformations = entry.getKey();
			final List<CounterRequestContext> contexts = entry.getValue();
			final CounterRequestContextPanel firstContextPanel = new CounterRequestContextPanel(
					getRemoteCollector(), contexts.subList(0, 1), javaInformations);
			add(firstContextPanel);
			final MButton detailsButton = new MButton(getString(DETAILS_KEY), PLUS_ICON);
			final JPanel detailsPanel = firstContextPanel.createDetailsPanel(contexts,
					detailsButton);

			detailsButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					detailsPanel.setVisible(!detailsPanel.isVisible());
					detailsPanel.validate();
					changePlusMinusIcon(detailsButton);
				}
			});
			detailsPanel.setVisible(false);

			add(detailsPanel);
		}
	}
}
 
Example 14
Source File: VisualDesignerPopupFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 15
Source File: mxVertexHandler.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected JComponent createPreview()
{
	JPanel preview = new JPanel();
	preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
	preview.setOpaque(false);
	preview.setVisible(false);

	return preview;
}
 
Example 16
Source File: MaterialFrame.java    From swing-material with MIT License 5 votes vote down vote up
public MaterialFrame() {
    contentPane = new JPanel();
    contentPane.setLayout(null);
    super.getContentPane().add(contentPane);
    wrapper = new MaterialFrameWrapper(this);
    wrapper.wrapAround(contentPane);
    contentPane.setVisible(true);
    light();
}
 
Example 17
Source File: CommitPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void hideSection(JPanel sectionPanel) {
    sectionPanel.setVisible(false);
}
 
Example 18
Source File: VCSCommitPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void showProgress() {
    JPanel p = getProgressPanel();
    p.setVisible(true);
}
 
Example 19
Source File: GameOfLifeEntity.java    From qupla with Apache License 2.0 4 votes vote down vote up
public GameOfLifeEntity()
{
  super(0);

  final Dispatcher dispatcher = Dispatcher.getInstance();
  golGen = dispatcher.getEnvironment("GolGen", null);
  golHash = dispatcher.getEnvironment("GolHash", null);
  golIds = dispatcher.getEnvironment("GolIds", null);
  golSend = dispatcher.getEnvironment("GolSend", null);
  golView = dispatcher.getEnvironment("GolView", null);
  join(golView);

  gridImage = new BufferedImage(GRID_SIZE, GRID_SIZE, BufferedImage.TYPE_3BYTE_BGR);

  gridView = new JPanel();
  gridView.setPreferredSize(new Dimension(200, 200));
  gridView.setVisible(true);
  final MouseInputAdapter mouseAdapter = getMouseInputAdapter();
  gridView.addMouseListener(mouseAdapter);
  gridView.addMouseMotionListener(mouseAdapter);

  final JLabel label = new JLabel();
  label.setText("GoL ID:");

  entry = new JTextField();
  addChangeListener();

  final JPanel idPanel = new JPanel();
  idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS));
  idPanel.add(label);
  idPanel.add(entry);

  frame = new JFrame("Game of Life");
  frame.addWindowListener(ViewEntity.windowAdapter);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(idPanel, BorderLayout.PAGE_START);
  frame.add(gridView, BorderLayout.CENTER);
  frame.addComponentListener(new ComponentAdapter()
  {
    public void componentResized(ComponentEvent evt)
    {
      drawGridImage();
    }
  });
  frame.setVisible(true);
  frame.setSize(400, 400);
}
 
Example 20
Source File: UwExperimentTab.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public UwExperimentTab(FoxSpacecraft sat, int displayType)  {
	super();
	fox = sat;
	foxId = fox.foxId;
	NAME = fox.toString() + " CAN PACKETS";
	
	int j = 0;
	layout = new BitArrayLayout[ids.length];
	 for (int canid : ids)
		 layout[j++] = Config.satManager.getLayoutByCanId(6, canid);

	splitPaneHeight = Config.loadGraphIntValue(fox.getIdString(), GraphFrame.SAVED_PLOT, FoxFramePart.TYPE_REAL_TIME, UWTAB, "splitPaneHeight");
	
	lblName = new JLabel(NAME);
	lblName.setMaximumSize(new Dimension(1600, 20));
	lblName.setMinimumSize(new Dimension(1600, 20));
	lblName.setFont(new Font("SansSerif", Font.BOLD, 14));
	topPanel.add(lblName);
	
	lblFramesDecoded = new JLabel(DECODED + CAN_DECODED);
	lblFramesDecoded.setFont(new Font("SansSerif", Font.BOLD, 14));
	lblFramesDecoded.setBorder(new EmptyBorder(5, 2, 5, 5) );
	topPanel.add(lblFramesDecoded);

	healthPanel = new JPanel();
	
	healthPanel.setLayout(new BoxLayout(healthPanel, BoxLayout.Y_AXIS));
	healthPanel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
	healthPanel.setBackground(Color.DARK_GRAY);
	
	topHalfPackets = new JPanel(); 
	topHalfPackets.setBackground(Color.DARK_GRAY);
	bottomHalfPackets = new JPanel(); //new ImagePanel("C:/Users/chris.e.thompson/Desktop/workspace/SALVAGE/data/stars5.png");
	bottomHalfPackets.setBackground(Color.DARK_GRAY);
	healthPanel.add(topHalfPackets);
	healthPanel.add(bottomHalfPackets);

	initDisplayHalves(healthPanel);
	
	centerPanel = new JPanel();
	centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));

	addModules();
	
	splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
			healthPanel, centerPanel);
	splitPane.setOneTouchExpandable(true);
	splitPane.setContinuousLayout(true); // repaint as we resize, otherwise we can not see the moved line against the dark background
	if (splitPaneHeight != 0) 
		splitPane.setDividerLocation(splitPaneHeight);
	else
		splitPane.setDividerLocation(DEFAULT_DIVIDER_LOCATION);
	
	SplitPaneUI spui = splitPane.getUI();
    if (spui instanceof BasicSplitPaneUI) {
      // Setting a mouse listener directly on split pane does not work, because no events are being received.
      ((BasicSplitPaneUI) spui).getDivider().addMouseListener(new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
        	  splitPaneHeight = splitPane.getDividerLocation();
        	  Log.println("SplitPane: " + splitPaneHeight);
      		Config.saveGraphIntParam(fox.getIdString(), GraphFrame.SAVED_PLOT, FoxFramePart.TYPE_REAL_TIME, UWTAB, "splitPaneHeight", splitPaneHeight);
          }
      });
    }
	//Provide minimum sizes for the two components in the split pane
	Dimension minimumSize = new Dimension(100, 50);
	healthPanel.setMinimumSize(minimumSize);
	centerPanel.setMinimumSize(minimumSize);
	add(splitPane, BorderLayout.CENTER);
			
	showRawBytes = new JCheckBox("Show Raw Bytes", Config.displayRawRadData);
	bottomPanel.add(showRawBytes );
	showRawBytes.addItemListener(this);
	

	addBottomFilter();
	
	radTableModel = new CanPacketRawTableModel();
	radPacketTableModel = new CanPacketTableModel();
	addTables(radTableModel,radPacketTableModel);

	addPacketModules();
	topHalfPackets.setVisible(false);
	bottomHalfPackets.setVisible(false);
	
	// initial populate
	parseRadiationFrames();
}