final JInternalFrame frame = new JInternalFrame(title, true, true, true, true); frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); frame.addInternalFrameListener(InternalWindowListener.wrap(listener)); ((JDesktopPane) owner).add(frame); frame.getContentPane().add(panel); frame.pack(); return frame; dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.addWindowListener(listener); dialog.getContentPane().add(panel); dialog.pack(); return dialog; dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.addWindowListener(listener); dialog.getContentPane().add(panel); dialog.pack(); return dialog; owner = owner.getParent(); final JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(listener); frame.getContentPane().add(panel); frame.pack();
panel.add(new JLabel(name, JLabel.LEFT)); panel.add(jtf); list.add(jtf); panel.setLayout(new GridLayout(0, 1)); addField("First Name:"); addField("Last Name:"); sp.validate(); Dimension d = sp.getPreferredSize(); d.setSize(d.width, d.height / 2); sp.setPreferredSize(d); JInternalFrame internaFrame = new JInternalFrame(); internaFrame.add(sp); internaFrame.pack(); internaFrame.setVisible(true); JDesktopPane desktopPane = new JDesktopPane(); desktopPane.add(internaFrame); if (focused != null && SwingUtilities.isDescendingFrom(focused, parent)) { parent.scrollRectToVisible(focused.getBounds());
public void actionPerformed(final ActionEvent e) { final JInternalFrame[] frames = gcViewer.getDesktopPane().getAllFrames(); final DesktopManager desktopManager = gcViewer.getDesktopPane().getDesktopManager(); for (int i=0; i<frames.length; i++) { final JInternalFrame frame = frames[i]; desktopManager.deiconifyFrame(frame); try { frame.setMaximum(false); } catch (PropertyVetoException e1) { e1.printStackTrace(); } final int height = gcViewer.getDesktopPane().getHeight()/frames.length; desktopManager.setBoundsForFrame(frame, 0, height * i, gcViewer.getDesktopPane().getWidth(), height); } } }
public static void main(String args[]) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); DesktopManager dm = new MageDesktopManager(); desktopPane.setDesktopManager(dm); JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true); internalFrame.setSize(200, 150); internalFrame.setVisible(true); desktopPane.add(internalFrame); frame.add(desktopPane, BorderLayout.CENTER); frame.setSize(800, 600); frame.setVisible(true); }); } }
private final JDesktopPane desktop = new JDesktopPane(); public JComponent makeUI() { JButton button = new JButton(new AbstractAction("open") { panelMenu.setBackground(Color.YELLOW); panelMenu.add(button); panelMenu.setBounds(0, 0, 100, 100); JInternalFrame panelTable = new JInternalFrame("Table"); panelTable.add(new JScrollPane(new JTable(30, 3))); panelTable.setBounds(100, 0, 200, 100); desktop.add(panelMenu); desktop.add(panelTable); panelMenu.setVisible(true); panelTable.setVisible(true); JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(new InternalMessageDialogTest().makeUI()); f.setSize(320, 240); f.setLocationRelativeTo(null); f.setVisible(true);
import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; import net.miginfocom.swing.MigLayout; public class MainClass { public static void main(String[] args) { JFrame frame = new JFrame (); frame.setVisible(true); frame.setAlwaysOnTop(true); final JDesktopPane desktopPane = new JDesktopPane(); desktopPane.setLayout(new MigLayout("center panel", "[100px:100px:1366px,grow,shrink 50,center]", "[100px:100px:768px,grow,shrink 50,center]")); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JInternalFrame form = new JInternalFrame(); form.setResizable(true); form.setVisible(true); desktopPane.add(form); frame.add(desktopPane); } }
import javax.swing.*; public class JInternalFrameDemo implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new JInternalFrameDemo()); } public void run() { JInternalFrame iFrame = new JInternalFrame("Test 1", false, false, false, false); iFrame.setTitle("Test 2"); iFrame.setSize(200, 150); iFrame.setLocation(10, 10); iFrame.setVisible(true); JDesktopPane desktop = new JDesktopPane(); desktop.setOpaque(true); desktop.add(iFrame); JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setContentPane(desktop); frame.setVisible(true); } }
super.iconifyFrame(f); JInternalFrame.JDesktopIcon icon = f.getDesktopIcon(); Dimension prefSize = icon.getPreferredSize(); icon.setBounds(f.getX(), f.getY(), prefSize.width, prefSize.height); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); DesktopManager dm = new CustomDesktopManager(); desktopPane.setDesktopManager(dm); JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true); internalFrame.setSize(200, 150); internalFrame.setVisible(true); desktopPane.add(internalFrame); frame.add(desktopPane, BorderLayout.CENTER); frame.setSize(800, 600); frame.setVisible(true);
public void run() { JDesktopPane desktopPane = new JDesktopPane(); JInternalFrame intFrame = new JInternalFrame( "JInternalFrame demo"); intFrame.setMaximizable(true); intFrame.setIconifiable(true); intFrame.setResizable(true); intFrame.setClosable(true); intFrame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); intFrame.setSize(320, 240); // intFrame.pack(); intFrame.setVisible(true); desktopPane.add(intFrame); JFrame frame = new JFrame(); frame.add(desktopPane); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setSize(640, 480); // frame.pack(); frame.setVisible(true); } });
public void frameInit(){ super.frameInit(); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(0,0,500,500); this.selfInitialize(); contentPane = new JDesktopPane(); child = new JInternalFrame("Centered Child"); child.setClosable(true); child.setVisible(true); child.setSize(300,200); child.setLocation((getWidth() - child.getWidth())/2, (getHeight() - child.getHeight())/2); contentPane.add(child); this.setContentPane(contentPane); addComponentListener(new ResizeEventHandler()); Component invoker = e.getComponent(); child.reshape((invoker.getWidth() - child.getWidth())/2, (invoker.getHeight() - child.getHeight())/2,300,200);
JDesktopPane pane = new JDesktopPane(); JInternalFrame inFrame = new JInternalFrame("No Hands", true, true, true, true); inFrame.setBounds(10, 10, 100, 100); inFrame.setVisible(true); pane.add(inFrame); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(pane); frame.setSize(400, 400); frame.setLocationRelativeTo(null); frame.setVisible(true);
public static void main(final String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); desktop.setUI(new DesktopPaneUI() { @Override public void installUI(JComponent c) { JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); desktop.add(internalFrame); internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true);
JFrame window = new JFrame(); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setBounds(30, 30, 300, 300); window.setVisible(true); window.setSize(600, 400); JDesktopPane desktopPane = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame(); JPanel mainPanel = new JPanel(); mainPanel.add(desktopPane); mainPanel.add(internalFrame); window.add(mainPanel);
JFrame jFrame = new JFrame(); jFrame.setLocationRelativeTo(null); JDesktopPane jDesktopPane = new JDesktopPane(); jDesktopPane.setPreferredSize(new Dimension(600, 600)); JInternalFrame jInternalFrame = new JInternalFrame(); jInternalFrame.setBackground(Color.BLUE); jInternalFrame.setResizable(true); jInternalFrame.setSize(new Dimension(300, 300)); jInternalFrame.setLocation(100, 100); jInternalFrame.setVisible(true); jInternalFrame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(final ComponentEvent e) { jDesktopPane.add(jInternalFrame); jFrame.setContentPane(jDesktopPane); jFrame.pack(); jFrame.setVisible(true);
JFrame f = new JFrame("InternalPie"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChartPanel cp = new ChartPanel(chart); JInternalFrame jif = new JInternalFrame( "Chart", true, true, true, true); jif.add(cp); jif.pack(); jif.setVisible(true); JDesktopPane dtp = new JDesktopPane(); dtp.add(jif); f.add(dtp); f.pack(); f.setSize(700, 500); f.setLocationRelativeTo(null); f.setVisible(true);
import java.awt.Dimension; import javax.swing.*; public class satorreProgram2main{ public static void main(String[]args){ satorreProgram2sub satorre = new satorreProgram2sub(); satorre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); satorre.setSize(200,150); satorre.setVisible(true); satorre.setResizable(false); JFrame frame = new JFrame(); JDesktopPane desktop = new JDesktopPane(); desktop.add(satorre); frame.setContentPane(desktop); frame.setPreferredSize(new Dimension(800, 600)); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }
JFrame frame = new JFrame(); JDesktopPane desktopPane = new JDesktopPane(); desktopPane.setPreferredSize(new Dimension(1920, 1080)); JInternalFrame internalFrame = new JInternalFrame("Testing"); internalFrame.setVisible(true); internalFrame.setBounds(100, 100, 500, 500); desktopPane.add(internalFrame); frame.add(desktopPane); frame.pack(); desktopPane.printAll(g2d); g2d.dispose(); frame.dispose();
private JDesktopPane pane = new JDesktopPane(); private JInternalFrame i = new JInternalFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1024,768); frame.setVisible(true); setLayout(new BorderLayout()); i.setClosable(true); i.setIconifiable(true); i.setMaximizable(true); i.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); i.setSize(320,240); i.setVisible(true); pane.setPreferredSize(new Dimension(1024,320)); pane.setBackground(Color.GRAY); pane.add(i); panel.setBackground(Color.YELLOW); add(pane,BorderLayout.SOUTH); add(panel,BorderLayout.CENTER);
public Demo() { JFrame frame = new JFrame(); frame.setSize(300,300); JDesktopPane df = new JDesktopPane(); DesktopManager dm = df.getDesktopManager(); df.setDesktopManager(new DefaultDesktopManager(){ public void dragFrame(JComponent f, int newX, int newY) { super.dragFrame(f, newX, 5); } }); JInternalFrame jif = new JInternalFrame("test "); jif.setLocation(5, 5); jif.setSize(150,100); jif.setVisible(true); df.add(jif); frame.setContentPane(df); frame.setVisible(true); }