Refine search
@Override public void run() { errorWindow.getContentPane().removeAll(); JTextArea textArea = new JTextArea(); textArea.setEditable(false); StringBuilder text = new StringBuilder(); text.append("An exceptional error occurred!\nYou can try to continue or exit the application.\n\n"); text.append("Please tell us about this here:\nhttp://www.4thline.org/projects/mailinglists-cling.html\n\n"); text.append("-------------------------------------------------------------------------------------------------------------\n\n"); Writer stackTrace = new StringWriter(); throwable.printStackTrace(new PrintWriter(stackTrace)); text.append(stackTrace.toString()); textArea.setText(text.toString()); JScrollPane pane = new JScrollPane(textArea); errorWindow.getContentPane().add(pane, BorderLayout.CENTER); JButton exitButton = new JButton("Exit Application"); exitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(1); } }); errorWindow.getContentPane().add(exitButton, BorderLayout.SOUTH); errorWindow.pack(); Application.center(errorWindow); textArea.setCaretPosition(0); errorWindow.setVisible(true); } });
p.add(f); frame.add(p); frame.setVisible(true); lastFocusableIndex = 0; sl.setFocused(false); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); typedWord = getCurrentlyTypedWord(); suggestionsPanel.removeAll();//remove previos words/jlabels that were added suggestionsPanel.add(suggestionLabel);
String defaults = JadxSettingsAdapter.makeString(JadxSettings.makeDefault()); JadxSettingsAdapter.fill(settings, defaults); getContentPane().removeAll(); initUI(); pack(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); getRootPane().setDefaultButton(saveBtn);
JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(this); f.pack(); f.setVisible(true); timer.start(); this.removeAll(); for (JLabel label : list) add(label); this.validate();
getContentPane().removeAll(); String newTitle = ""; if (chartPanelViews.size() > 0) { constraints.weightx = 2; getContentPane().add(chartPanelView.getViewBar(), constraints); row++; modelChart.setPreferredSize(new Dimension(800, 600)); modelChartAndDetails.setVisible(!chartPanelView.isMinimized()); getContentPane().add(modelChartAndDetails, constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.SOUTH; getContentPane().add(modelMetricsPanel, constraints); modelMetricsPanel.setVisible(showModelMetricsPanel && (!chartPanelView.isMinimized()));
import java.util.*; import java.awt.*; import javax.swing.*; public class Testing extends JPanel { JLabel jl; ImageIcon icon; Point pointer; public static void main(String[] args) { JFrame jf = new JFrame(); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp1 = new JPanel(); JPanel jp2 = new JPanel(); JLabel jl1 = new JLabel("Hey1"); JLabel jl2 = new JLabel("Hey2"); jp1.add(jl1); jp2.add(jl2); jf.add(jp1); jf.pack(); jf.setVisible(true); Scanner myScanner = new Scanner(System.in); int x = myScanner.nextInt(); // the line causes the code to not work , jf.getContentPane().removeAll(); jf.add(jp2); jf.validate(); } }
import javax.swing.*; public class Test extends JFrame { private JPanel nPanel; private JLabel label; Test() { setSize(300,300); nPanel = new JPanel(); label = new JLabel("Hello!"); nPanel.add(label); add(nPanel); } public void clear(JPanel panel) { panel.removeAll(); panel.repaint(); } public static void main(String[] args) { Test t = new Test(); t.setVisible(true); t.clear(t.nPanel); //if you comment this line, you will see label said "Hello" to you! } }
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); m_frame.setSize(600, 400); m_frame.setVisible(true); ChordEditor ce = new ChordEditor(); m_frame.getContentPane().removeAll(); m_frame.add(ce); m_frame.getContentPane().repaint(); m_frame.validate();
public class PanelTest extends JFrame { Container contentPane; public PanelTest() { super("Changing JPanel inside a JFrame"); contentPane=getContentPane(); } public void createChangePanel() { contentPane.removeAll(); JPanel newPanel=new JPanel(); contentPane.add(newPanel); System.out.println("new panel created");//for debugging purposes validate(); setVisible(true); } }
add(b1, BorderLayout.CENTER); repaint(); revalidate(); removeAll(); repaint(); revalidate(); frame.add(new Animation()); frame.setVisible(true); frame.setSize(1000, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try { TestFilechooser frame = new TestFilechooser(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); jc = new MyFileChooser(); JButton btnOpen = new JButton("open"); contentPane.add(btnOpen, BorderLayout.NORTH); panel2.removeAll(); panel2.add(comboBox); panel2.add(c1);//optional used to add the buttons after combobox panel2.add(c2);//optional used to add the buttons after combobox
panel.setPreferredSize(new Dimension(500,400)); button.addActionListener(this); add(panel,BorderLayout.CENTER); add(button, BorderLayout.SOUTH); aitor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); aitor.pack(); aitor.setVisible(true); panel.removeAll(); table =new JTable(data,columns); panel.add(new JScrollPane(table),BorderLayout.CENTER); repaint(); revalidate();