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

The following are Jave code examples for showing how to use repaint() 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: NBANDROID-V2   File: AndroidSdkNode.java   View Source Code Vote up 6 votes
@Override
public void sdkValid() {
    fireIconChange();
    fireOpenedIconChange();
    setChildren(Children.create(new AndroidPlatformChildrenFactory(platform, holder), false));
    JPanel tmp = lastBrokenPanel.get();
    if (tmp != null) {
        tmp.removeAll();
        tmp.invalidate();
        tmp.repaint();
        tmp.setLayout(new java.awt.CardLayout());
        tmp.add(new AndroidSdkCustomizer(platform, holder));
        tmp.revalidate();
        tmp.repaint();
        tmp.requestFocus();
    }
}
 
Example 2
Project: NBANDROID-V2   File: AndroidSdkNode.java   View Source Code Vote up 6 votes
public void updateCustomizer() {
    if (valid != platform.isValid()) {
        valid = platform.isValid();
        setChildren(Children.create(new AndroidPlatformChildrenFactory(platform, holder), false));
        JPanel tmp = lastBrokenPanel.get();
        if (tmp != null) {
            tmp.removeAll();
            tmp.invalidate();
            tmp.repaint();
            tmp.setLayout(new java.awt.CardLayout());
            if (platform.isValid()) {
                tmp.add(new AndroidSdkCustomizer(platform, holder));
            } else {
                tmp.add(new BrokenPlatformCustomizer(platform, holder, this));
            }
            tmp.revalidate();
            tmp.repaint();
            tmp.requestFocus();
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: CustomCodeView.java   View Source Code Vote up 5 votes
private void contentChange(DocumentEvent e) {
            changed = true;

            Document doc = e.getDocument();
            CodeCategory category = getCategoryForDocument(doc);
            int eBlockIndex = getEditBlockIndex(category, e.getOffset());
            if (eBlockIndex < 0) {
                return;
            }

            List<EditableLine> lines = getEditInfos(category)[eBlockIndex].lines;
            int[] blockBounds = getEditBlockBounds(category, eBlockIndex);
            boolean repaint = false;

            Integer lastLineCount = lastDocLineCounts.get(doc);
            int lineCount = getLineCount(doc);
            if (lastLineCount == null || lastLineCount.intValue() != lineCount) {
                lastDocLineCounts.put(doc, Integer.valueOf(lineCount));
                updateLines(doc, blockBounds[0], blockBounds[1], lines,
                            codeData.getEditableBlock(category, eBlockIndex));
                repaint = true;
                // make sure our listener is invoked after position listeners update
                doc.removeDocumentListener(this);
                doc.addDocumentListener(this);
            }

            repaint |= updateGutterComponents(lines, doc, blockBounds[0], blockBounds[1]);

            if (repaint) {
                JPanel gutter = getGutter(doc);
                gutter.revalidate();
                gutter.repaint();
            }
//            ((BaseDocument)doc).resetUndoMerge();
        }
 
Example 4
Project: incubator-netbeans   File: MenuEditLayer.java   View Source Code Vote up 5 votes
private void rebuildOnScreenMenu(RADVisualContainer menuRAD) {
    if(menuRAD == null) return;
    if(hackedPopupFactory == null) return;
    JMenu menu = (JMenu) formDesigner.getComponent(menuRAD);
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel popupContainer = hackedPopupFactory.containerMap.get(menu);
        if(popupContainer == null) return;
        for(Component c : popupContainer.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent)c);
            }
        }
        popupContainer.removeAll();
        // rebuild it
        for(RADVisualComponent child : menuRAD.getSubComponents()) {
            if(child != null) {
                JComponent jchild = (JComponent) formDesigner.getComponent(child);
                if(!isConfigured(jchild)) {
                    if(jchild instanceof JMenu) {
                        configureMenu(menu, (JMenu)jchild);
                    } else {
                        configureMenuItem(menu,jchild);
                    }
                }
                popupContainer.add(jchild);
            }
        }
        
        // repack it
        popupContainer.setSize(popupContainer.getLayout().preferredLayoutSize(popupContainer));
        validate();
        popupContainer.repaint();
    }
}
 
Example 5
Project: incubator-netbeans   File: StringTableCellEditor.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, final int column) {
    final JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row, column);      
    
    this.tableModel = table.getModel();
    this.columnName = table.getColumnName(column);
    this.modelRow = table.convertRowIndexToModel(row);
    this.modelColumn = table.convertColumnIndexToModel(column);  
    this.tc = c instanceof JTextComponent ? (JTextComponent) c : null;

    JPanel panel = new JPanel(new BorderLayout()) {
        @Override
        public void addNotify() {
            super.addNotify();
            c.requestFocus();
        }
    };
    panel.add(c);
    if (suppressEditorBorder) {
        c.setBorder(BorderFactory.createEmptyBorder());
    }
    panel.add(customEditorButton, BorderLayout.EAST);
    panel.revalidate();
    panel.repaint();

    return panel;
}
 
Example 6
Project: Equella   File: Wizard.java   View Source Code Vote up 5 votes
public void replacePage(JPanel parent, JPanel child)
{
	parent.removeAll();
	parent.add(child);
	parent.revalidate();
	parent.repaint();
}
 
Example 7
Project: geomapapp   File: MapApp.java   View Source Code Vote up 5 votes
public void addDevPasswordField() {
	inputDevPasswordPanel = new JPanel();
	inputDevPasswordLabel = new JLabel("Password:");
	inputDevPasswordText = new JTextField(10);
	inputDevPasswordPanel.add(inputDevPasswordLabel);
	inputDevPasswordPanel.add(inputDevPasswordText);
	serverPanel.add(inputDevPasswordPanel, BorderLayout.SOUTH );
	inputDevPasswordPanel.repaint();
	serverPanel.repaint();
	option.pack();
	option.show();
}
 
Example 8
Project: jOthelloT   File: Results.java   View Source Code Vote up 5 votes
public void saveFinal(JPanel panel, String jogoNro) {
    try {
        panel.validate();
        panel.repaint();
        panel.validate();
        panel.repaint();
        Container c = panel;
        BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
        c.paint(im.getGraphics());
        ImageIO.write(im, "PNG", new File(PATH + File.separator + "jogo" + jogoNro + ".png"));
    } catch (IOException ex) {
        Logger.getLogger(OthelloTournament.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 9
Project: rapidminer   File: AttributeStatisticsPanel.java   View Source Code Vote up 4 votes
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

			private static final long serialVersionUID = -6953213567063104487L;

			@Override
			public Dimension getPreferredSize() {
				return DIMENSION_CHART_PANEL_ENLARGED;
			}
		};
		chartPanel.setPopupMenu(null);
		chartPanel.setBackground(COLOR_TRANSPARENT);
		chartPanel.setOpaque(false);
		chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		panel.add(chartPanel, BorderLayout.CENTER);

		JPanel openChartPanel = new JPanel(new GridBagLayout());
		openChartPanel.setOpaque(false);

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;

		JButton openChartButton = new JButton(OPEN_CHART_ACTION);
		openChartButton.setOpaque(false);
		openChartButton.setContentAreaFilled(false);
		openChartButton.setBorderPainted(false);
		openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
		openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
		openChartButton.setIcon(null);
		Font font = openChartButton.getFont();
		Map attributes = font.getAttributes();
		attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
		openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

		openChartPanel.add(openChartButton, gbc);

		panel.add(openChartPanel, BorderLayout.SOUTH);
		panel.revalidate();
		panel.repaint();
	}
}
 
Example 10
Project: Hotel-Properties-Management-System   File: Main_UpperToolbar.java   View Source Code Vote up 4 votes
public ActionListener UpperToolbarActionListener(final JPanel mainPanel) {

        ActionListener actionListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                if (e.getSource() == roomsBtn) {

                    theRooms = new Main_AllRooms();
                    infoColorTable = new ColorInfoTable();

                    // Set the usage of room into info table
                    infoColorTable.setCleanLabelCount(theRooms.cleanCounter);
                    infoColorTable.setDirtyLabelCount(theRooms.dirtyCounter);
                    infoColorTable.setDndLabelCount(theRooms.dndCounter);

                    mainPanel.removeAll();
                    mainPanel.add(theRooms.getWindow(), BorderLayout.WEST);
                    mainPanel.add(infoColorTable, BorderLayout.EAST);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == guestsBtn) {

                    customersFrame = new Main_CustomersFrame();
                    mainPanel.removeAll();
                    mainPanel.add(customersFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == rezervationBtn) {

                    rezervFrame = new Main_Reservations();
                    mainPanel.removeAll();
                    rezervFrame.populateMainTable();
                    mainPanel.add(rezervFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == blockadeBtn) {

                    blockadeFrame = new Main_Blockade();
                    mainPanel.removeAll();
                    mainPanel.add(blockadeFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == roomCleaningBtn) {

                    cleaningFrame = new Main_RoomCleaning();
                    mainPanel.removeAll();
                    mainPanel.add(cleaningFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == cashBtn) {

                    cashdesk = new Main_CashDesk();
                    mainPanel.removeAll();
                    mainPanel.add(cashdesk, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == auditBtn) {

                    audit = new Main_Audit();
                    audit.initializeAuditPane();
                    mainPanel.removeAll();
                    mainPanel.add(audit, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == refreshBtn) {
                    mainPanel.removeAll();
                    mainPanel.revalidate();
                    mainPanel.repaint();
                }
            }
        };
        return actionListener;
    }
 
Example 11
Project: Equella   File: InternalDataSourceTab.java   View Source Code Vote up 4 votes
private void attemptToShowFullUi()
{
	if( tree != null )
	{
		return;
	}

	GlassSwingWorker<?> worker = new GlassSwingWorker<Boolean>()
	{
		private Map<String, Pair<String, String>> predefinedTermDataKeys;

		@Override
		public Boolean construct() throws Exception
		{
			boolean valid = taxonomy != null
				&& clientService.getService(RemoteTaxonomyService.class).identifyByUuid(taxonomy.getUuid()) != 0;
			if( valid )
			{
				predefinedTermDataKeys = new HashMap<String, Pair<String, String>>();
				for( Extension ext : pluginService.getConnectedExtensions("com.tle.admin.taxonomy.tool",
					"predefinedTermDataKey") )
				{
					final String key = ext.getParameter("key").valueAsString();
					final String name = CurrentLocale.get(ext.getParameter("name").valueAsString());
					final String desc = CurrentLocale.get(ext.getParameter("description").valueAsString());

					predefinedTermDataKeys.put(key, new Pair<String, String>(name, desc));
				}
			}
			return valid;
		}

		@Override
		public void finished()
		{
			if( !get() )
			{
				return;
			}

			final JPanel p = InternalDataSourceTab.this;

			// Remove this listener and clear the panel
			p.removeComponentListener(ensureTaxonomySavedListener);
			p.removeAll();

			final RemoteTermService termService = clientService.getService(RemoteTermService.class);

			tree = new AbstractTreeEditor<TermTreeNode>()
			{
				@Override
				protected AbstractTreeEditorTree<TermTreeNode> createTree()
				{
					return new TermTree(taxonomy, true, termService);
				}

				@Override
				protected AbstractTreeNodeEditor createEditor(TermTreeNode node)
				{
					return new TermEditor(termService, predefinedTermDataKeys, taxonomy, node);
				}
			};

			p.setLayout(new MigLayout("wrap 1, fill"));
			p.add(new JLabel("<html>" + s("immediatechanges")));
			p.add(tree, "push, grow");

			p.revalidate();
			p.repaint();
		}
	};
	worker.setComponent(InternalDataSourceTab.this);
	worker.start();
}
 
Example 12
Project: FaceAnnotationTool   File: TestFrame.java   View Source Code Vote up 4 votes
/**
	 * Create the frame.
	 */
	public TestFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		contentPane.add(new JComponent() {
            public void paintComponent(Graphics g) {
            	Graphics2D g2d = (Graphics2D) g;
            	for(int i=0;i<200;i++){
            		g2d.fill(UniversalTool.getPointOval(0, 10*i, 5));
            		g2d.fill(UniversalTool.getPointOval(10*i, 0, 5));
            	}
            	
            	Ellipse e = UniversalTool.getTestEllipse(10);
            	Ellipse2D.Double ed = e.getErectedEllipse2D();
            		
        			//save old transform
        			AffineTransform old = g2d.getTransform();
        			for (Point_ p : e.getKeyPoints()){
        				g2d.fill(UniversalTool.getPointOval(p, 5));
        			}
//        			for(int i=0;i<12;i++){
//        				g2d.setTransform(old);
//        				trf.rotate(Math.toRadians(30*i),e.x,e.y);
//        				g2d.setTransform(trf);
//        				g2d.draw(ed);
//        			}
        			g2d.rotate(e.angle,e.x,e.y);
        			//draw elps
        			g2d.setColor(Color.GREEN);
        			
        			g2d.draw(ed);
        			//draw pts
        			g2d.setColor(Color.RED);
        			
        			//revert transform
        			g2d.setTransform(old);
//                g2d.setStroke(new BasicStroke(10));
//                g2d.draw(new Line2D.Float(30, 20, 80, 90));
            }
        });
		contentPane.repaint();
	}
 
Example 13
Project: sbc-qsystem   File: FWelcome.java   View Source Code Vote up 4 votes
public void clearPanel(JPanel panel) {
    panel.removeAll();
    panel.repaint();
}