Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 2.56 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.EventQueue;
  2.  
  3.  
  4. public class MainWindow {
  5.  
  6.         private JFrame frmWidgetShella;
  7.  
  8.         /**
  9.          * Launch the application.
  10.          */
  11.         public static void main(String[] args) {
  12.                 EventQueue.invokeLater(new Runnable() {
  13.                         public void run() {
  14.                                 try {
  15.                                         MainWindow window = new MainWindow();
  16.                                         window.frmWidgetShella.setVisible(true);
  17.                                 } catch (Exception e) {
  18.                                         e.printStackTrace();
  19.                                 }
  20.                         }
  21.                 });
  22.         }
  23.  
  24.         /**
  25.          * Create the application.
  26.          */
  27.         public MainWindow() {
  28.                 initialize();
  29.         }
  30.  
  31.         /**
  32.          * Initialize the contents of the frame.
  33.          */
  34.         private void initialize() {
  35.                 frmWidgetShella = new JFrame();
  36.                 frmWidgetShella.setIconImage(Toolkit.getDefaultToolkit().getImage(MainWindow.class.getResource("/icons/icon.ico")));
  37.                 frmWidgetShella.setSize(new Dimension(800, 600));
  38.                 frmWidgetShella.getContentPane().setBackground(Color.DARK_GRAY);
  39.                 frmWidgetShella.getContentPane().setLayout(new BorderLayout(0, 0));
  40.                
  41.                 JPanel panel = new JPanel();
  42.                 frmWidgetShella.getContentPane().add(panel, BorderLayout.SOUTH);
  43.                 frmWidgetShella.setFont(null);
  44.                 frmWidgetShella.setBackground(Color.WHITE);
  45.                 frmWidgetShella.setTitle("IMA Visual Editor v.0.1.a");
  46.                 frmWidgetShella.setBounds(100, 100, 533, 543);
  47.                
  48.                 JMenuBar menuBar = new JMenuBar();
  49.                 menuBar.setBackground(UIManager.getColor("CheckBox.darkShadow"));
  50.                 frmWidgetShella.setJMenuBar(menuBar);
  51.                
  52.                 JMenu mnFile = new JMenu("File");
  53.                 menuBar.add(mnFile);
  54.                
  55.                 JMenuItem mntmNew = new JMenuItem("New");
  56.                 mnFile.add(mntmNew);
  57.                
  58.                 JMenuItem mntmExit = new JMenuItem("Exit");
  59.                 mnFile.add(mntmExit);
  60.                
  61.                 JMenu mnEdit = new JMenu("Edit");
  62.                 menuBar.add(mnEdit);
  63.                
  64.                 JMenu mnView = new JMenu("View");
  65.                 menuBar.add(mnView);
  66.                
  67.                 JMenu mnTools = new JMenu("Tools");
  68.                 menuBar.add(mnTools);
  69.                
  70.                 JMenu mnOptions = new JMenu("Options");
  71.                 menuBar.add(mnOptions);
  72.                
  73.                 JMenu mnHelp = new JMenu("Help");
  74.                 menuBar.add(mnHelp);
  75.                
  76.                 Component horizontalGlue = Box.createHorizontalGlue();
  77.                 menuBar.add(horizontalGlue);
  78.                
  79.                 JProgressBar progressBar = new JProgressBar();
  80.                 progressBar.setValue(50);
  81.                 menuBar.add(progressBar);
  82.         }
  83.  
  84.         private static void addPopup(Component component, final JPopupMenu popup) {
  85.                 component.addMouseListener(new MouseAdapter() {
  86.                         public void mousePressed(MouseEvent e) {
  87.                                 if (e.isPopupTrigger()) {
  88.                                         showMenu(e);
  89.                                 }
  90.                         }
  91.                         public void mouseReleased(MouseEvent e) {
  92.                                 if (e.isPopupTrigger()) {
  93.                                         showMenu(e);
  94.                                 }
  95.                         }
  96.                         private void showMenu(MouseEvent e) {
  97.                                 popup.show(e.getComponent(), e.getX(), e.getY());
  98.                         }
  99.                 });
  100.         }
  101. }