public void openInBox() { JInternalFrame doc = new MetalworksInBox(); desktop.add(doc, DOCLAYER); try { doc.setVisible(true); doc.setSelected(true); } catch (java.beans.PropertyVetoException e2) { } }
public void openHelpWindow() { JInternalFrame help = new MetalworksHelp(); desktop.add(help, HELPLAYER); try { help.setVisible(true); help.setSelected(true); } catch (java.beans.PropertyVetoException e2) { } }
public void paintComponent(Graphics g) { super.paintComponent(g); File f = new File("Data.txt"); try { textArea.setText(""); reader = new BufferedReader(new FileReader(f)); String str = ""; while (!(str = reader.readLine()).equals("")) { textArea.append(str + "\n"); } reader.close(); } catch (Exception e) { System.out.println(e); } repaint(); }
public SceneLayoutApp() { super(); new Pair(); final JFrame frame = new JFrame("Scene Layout"); final JPanel panel = new JPanel(new BorderLayout()); frame.setContentPane(panel); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setMaximumSize(screenSize); frame.setSize(screenSize); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JMenuBar mb = new JMenuBar(); frame.setJMenuBar(mb); final JMenu jMenu = new JMenu("File"); mb.add(jMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Help")); JMenu menu = new JMenu("Look and Feel"); // // Get all the available look and feel that we are going to use for // creating the JMenuItem and assign the action listener to handle // the selection of menu item to change the look and feel. // UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lookAndFeelInfos.length; i++) { final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i]; JMenuItem item = new JMenuItem(lookAndFeelInfo.getName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { // // Set the look and feel for the frame and update the UI // to use a new selected look and feel. // UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } }); menu.add(item); } mb.add(menu); jMenu.add(new JMenuItem(new scene.action.QuitAction())); panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER); final JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); final JComboBox comboNewWindow = new JComboBox( new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"}); comboNewWindow.addActionListener(new CreateSceneWindowAction()); comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window")); bar.add(comboNewWindow); bar.add( new AbstractAction("Progress Bars") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new ProgressBarAnimator(); } }); bar.add( new AbstractAction("Sliders") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new SliderBarAnimator(); } }); final JCheckBox permaViz = new JCheckBox(); permaViz.setText("Show the dump window"); permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); dumpWindow = new JInternalFrame("perma dump window"); dumpWindow.setContentPane(new JScrollPane(permText)); permaViz.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dumpWindow.setVisible(permaViz.isSelected()); } }); comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize()); permaViz.setSelected(false); bar.add(new CreateWebViewV1Action()); bar.add(new CreateWebViewV2Action()); bar.add(permaViz); desktopPane.add(dumpWindow); dumpWindow.setSize(400, 400); dumpWindow.setResizable(true); dumpWindow.setClosable(false); dumpWindow.setIconifiable(false); final JMenuBar m = new JMenuBar(); final JMenu cmenu = new JMenu("Create"); m.add(cmenu); final JMenuItem menuItem = new JMenuItem( new AbstractAction("new") { @Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { Object[] in = (Object[]) XSTREAM.fromXML(permText.getText()); final JInternalFrame ff = new JInternalFrame(); final ScenePanel c = new ScenePanel(); ff.setContentPane(c); desktopPane.add(ff); final Dimension d = (Dimension) in[0]; c.setMaximumSize(d); c.setPreferredSize(d); ff.setSize(d.width + 50, d.height + 50); ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]); c.invalidate(); c.repaint(); ff.pack(); ff.setClosable(true); ff.setMaximizable(false); ff.setIconifiable(false); ff.setResizable(false); ff.show(); } }; SwingUtilities.invokeLater(runnable); } }); cmenu.add(menuItem); // JMenuBar menuBar = new JMenuBar(); // getContentPane().add(menuBar); dumpWindow.setJMenuBar(m); frame.setVisible(true); }
/** The graphic handling and deployment. */ private void initComponents() { jDesktopPane1 = new javax.swing.JDesktopPane(); jInternalFrame1 = new javax.swing.JInternalFrame(); tf = new javax.swing.JTextField(); b1 = new javax.swing.JButton(); jInternalFrame3 = new javax.swing.JInternalFrame(); ta = new javax.swing.JTextArea(); jsp_ta = new javax.swing.JScrollPane(ta); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); jMenuItem4 = new javax.swing.JMenuItem(); jInternalFrame1 .getContentPane() .setLayout( new javax.swing.BoxLayout( jInternalFrame1.getContentPane(), javax.swing.BoxLayout.X_AXIS)); jInternalFrame1.setIconifiable(true); jInternalFrame1.setMaximizable(true); jInternalFrame1.setResizable(true); jInternalFrame1.setTitle("Message editor"); jInternalFrame1.setToolTipText( "Move and resize all of these to make the chat room appearance match your preferences."); jInternalFrame1.setVisible(true); tf.setFont(new java.awt.Font("Lucida Sans", 0, 12)); jInternalFrame1.getContentPane().add(tf); b1.setText("Send Message"); jInternalFrame1.getContentPane().add(b1); jInternalFrame1.setBounds(10, 10, 440, 60); jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER); jInternalFrame3.setIconifiable(true); jInternalFrame3.setMaximizable(true); jInternalFrame3.setResizable(true); jInternalFrame3.setTitle("Messages"); jInternalFrame3.setToolTipText( "Move and resize all of these to make the chat room appearance match your preferences."); jInternalFrame3.setVisible(true); ta.setBackground(new Color(255, 255, 255)); ta.setEditable(false); ta.setFont(new java.awt.Font("Lucida Sans", 0, 12)); // jsp_ta.setAutoscrolls(true); jsp_ta.setDoubleBuffered(true); jInternalFrame3.getContentPane().add(jsp_ta, java.awt.BorderLayout.CENTER); jInternalFrame3.setBounds(10, 80, 420, 240); jDesktopPane1.add(jInternalFrame3, javax.swing.JLayeredPane.DEFAULT_LAYER); getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER); jMenu1.setText("Private room options"); jMenu1.setMnemonic(KeyEvent.VK_O); jMenu1.setToolTipText("Choose some options."); jMenuItem3.setText("Save conversation"); jMenuItem3.setMnemonic(KeyEvent.VK_S); jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); jMenu1.add(jMenuItem3); jMenu1.add(jSeparator1); jMenuItem4.setText("Exit"); jMenuItem4.setMnemonic(KeyEvent.VK_E); jMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK)); jMenu1.add(jMenuItem4); jMenuBar1.add(jMenu1); setJMenuBar(jMenuBar1); this.pack(); b1.addActionListener(this); tf.addActionListener(this); jMenuItem3.addActionListener(this); jMenuItem4.addActionListener(this); posx = (int) Math.random() * 640; posy = (int) Math.random() * 480; this.pack(); this.setSize(dimx, dimy); this.setLocation(posx, posy); this.show(); }