本文整理了Java中javax.swing.JFrame.remove()
方法的一些代码示例,展示了JFrame.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.remove()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:remove
暂无
代码示例来源:origin: 4thline/cling
public void toggleLogPanel() {
if (!logPanelVisible) {
getView().add(getLogPanel(), BorderLayout.CENTER);
getLogController().getLogTableModel().setPaused(false);
logPanelVisible = true;
} else {
getView().remove(getLogPanel());
getLogController().getLogTableModel().setPaused(true);
logPanelVisible = false;
}
getView().pack();
}
代码示例来源:origin: stackoverflow.com
//This is the only way i didn't get errors xD
public void panelSwap(JFrame z, JPanel x, JPanel y) {
z.remove(x);
z.add(y);
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
JPanel panel = new JPanel();
frame.add(panel);
frame.remove(panel);
代码示例来源:origin: com.metsci.glimpse/glimpse-core-examples
@Override
public void windowClosing( WindowEvent e )
{
// dispose of resources associated with the canvas
canvas.disposeAttached( );
// remove the canvas from the frame
frame.remove( canvas );
}
} );
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame("test");
final JPanel panel = new JPanel();
//add the panel at the start
frame.add(panel);
// when the buttons clicked
button.addActionListener(new ActionListener() {
@Override
public void ActionPerformed(ActionEvent e) {
frame.remove(panel);
frame.repaint();
};
});
代码示例来源:origin: stackoverflow.com
private void frame1(){
JFrame Introframe = new JFrame();
IntroText introtext = new IntroText(); // your panel
Introframe.add(introtext); // add panel
Introframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Introframe.setLocation(600,100);
Introframe.pack();
Introframe.setVisible(true);
Introframe.remove(introtext); // remove it now
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
final JFrame f = new JFrame("experiment");
final JPanel pn = new JPanel();
final JButton bt = new JButton("click me");
f.setSize(500, 500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(pn);
pn.add(bt);
final JTextArea tx = new JTextArea();
f.getContentPane().add(tx, BorderLayout.CENTER);
f.getContentPane().add(pn, BorderLayout.SOUTH);
tx.setText("hello");
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
pn.remove(bt);
f.remove(pn);
}
});
}
代码示例来源:origin: com.metsci.glimpse/glimpse-core-examples
@Override
public void actionPerformed( ActionEvent e )
{
if ( toc )
{
frame.remove( canvas );
frame2.add( canvas );
}
else
{
frame2.remove( canvas );
frame.add( canvas );
}
frame2.validate( );
frame.validate( );
toc = !toc;
}
} ).start( );
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame();
frame.setSize(200, 200);
final JPanel panelA = new JPanel();
final JPanel panelB = new JPanel();
JButton button = new JButton("Switch");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.remove(panelA);
frame.add(panelB);
frame.show();
}
});
JLabel label = new JLabel("This is panel B. Panel A is gone!");
panelB.add(label);
panelA.add(button);
frame.add(panelB);
frame.add(panelA);
frame.show();
代码示例来源:origin: edu.illinois.cs.cogcomp/DatalessClassification
@Override
public void actionPerformed(ActionEvent actionEvent) {
window.remove(panel1);
window.setContentPane(myPanel);
window.validate();
window.repaint();
}
};
代码示例来源:origin: edu.illinois.cs.cogcomp/DatalessClassification
public void actionPerformed(ActionEvent e) {
window.remove(panel2);
window.setContentPane(myPanel);
window.validate();
window.repaint();
}
});
代码示例来源:origin: stackoverflow.com
public JFrame frame = new JFrame();
public JPanel pan = new JPanel();
public void replace() {
frame.remove(pan);
pan = new JPanel();
GridLayout grid = new GridLayout(8,8);
pan.setLayout(grid);
pan.setVisible(true);
frame.add(pan);
frame.invalidate();
frame.revalidate();
frame.repaint();
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
final JFrame frame = new JFrame("Gears AWT");
final JPanel intro = new JPanel();
Action action = new AbstractAction("Start Gears") {
@Override
public void actionPerformed(ActionEvent e) {
GearsApplet gears = new GearsApplet();
gears.init();
frame.remove(intro);
frame.add(gears);
frame.getRootPane().revalidate();
}
};
JButton button = new JButton(action);
intro.add(button);
frame.add(intro); //.display_parent);
frame.setSize(200, 200);
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
public Game() {
model = new Model();
model.add(new Tile(Tile.randomLetter(), Color.WHITE));
model.add(new Tile(Tile.randomLetter(), Color.RED));
model.add(new Tile(Tile.randomLetter(), Color.GREEN));
model.add(new Tile(Tile.randomLetter(), Color.YELLOW));
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new GridLayout(4, 1));
frame.setSize(500, 800);
frame.setVisible(true);
for (Tile tile : model.getTiles()) {
frame.add(tile);
}
model.addModelListener(new ModelListener() {
@Override
public void tileWasRemoved(Tile tile) {
frame.remove(tile);
frame.revalidate();
frame.repaint();
}
});
frame.getContentPane().addKeyListener(this);
frame.getContentPane().setFocusable(true);
frame.getContentPane().requestFocusInWindow();
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
final JPanel origPanel = new JPanel();
frame.add(origPanel, BorderLayout.CENTER);
MouseListener ml = new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
// Mouse clicked on panel so remove existing panel and add a new one.
frame.remove(origPanel);
frame.add(createNewPanel(), BorderLayout.CENTER);
// Revalidate frame to cause it to layout the new panel correctly.
frame.revalidate();
// Stop listening to origPanel (prevent dangling reference).
origPanel.removeMouseListener(this);
}
}
origPanel.addMouseListener(ml);
代码示例来源:origin: edu.illinois.cs.cogcomp/DatalessClassification
public void display_esa(List<ConceptData> cDoc){
panel1 = new JPanel();
final JTextArea textArea = new JTextArea(5, 30);
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new Dimension(500, 400));
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
for (ConceptData key : cDoc) {
textArea.append(key.concept + ", \t" + String.format("%.4f", key.score)+"\n");
}
textArea.setCaretPosition(textArea.getDocument().getLength());
//window.setLayout(new FlowLayout());
JButton back=new JButton("Go Back");
back.setBounds(30,50,550,430);
back.addActionListener(back());
panel1.add(back);
scrollPane.setLocation(30, 150);
panel1.add(scrollPane);
window.remove(myPanel);
window.setContentPane(panel1);
window.validate();
window.repaint();
}
代码示例来源:origin: stackoverflow.com
jpAnnotation.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JFrame myInternalFrame= (JFrame)SwingUtilities.getWindowAncestor(this);
myInternalFrame.remove(PDFJPanel.this);
myInternalFrame.invalidate();
myInternalFrame.validate();
myInternalFrame.repaint();
}
});
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
final JFrame frame = new JFrame("Test");
frame.setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final Canvas canvas1 = new Canvas();
final Canvas canvas2 = new Canvas();
canvas1.setBackground(Color.RED);
canvas2.setBackground(Color.BLUE);
canvas1.addMouseListener(new MouseAdapter() {
@Override public void mouseClicked(MouseEvent e) {
frame.remove(canvas1);
frame.add(canvas2, BorderLayout.CENTER);
System.out.println("Canvas switched to Canvas2");
frame.revalidate();
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
frame.add(canvas1);
frame.setSize(640, 480);
frame.setVisible(true);
}
});
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void hide(View p) {
if (p.isShowing()) {
JFrame f = (JFrame) SwingUtilities.getWindowAncestor(p.getComponent());
if (getActiveView() == p) {
setActiveView(null);
}
f.setVisible(false);
removeWindow(f);
f.remove(p.getComponent());
f.dispose();
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void hide(View p) {
if (p.isShowing()) {
if (getActiveView()==p) {
setActiveView(null);
}
p.setShowing(false);
JFrame f = (JFrame) SwingUtilities.getWindowAncestor(p.getComponent());
f.setVisible(false);
f.remove(p.getComponent());
f.dispose();
}
}
内容来源于网络,如有侵权,请联系作者删除!