You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainFrame.java 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package org.ownage.dmdirc.ui;
  23. import org.ownage.dmdirc.*;
  24. import java.awt.event.ActionEvent;
  25. import java.awt.event.ActionListener;
  26. import javax.swing.JInternalFrame;
  27. /**
  28. * The main application frame
  29. * @author chris
  30. */
  31. public class MainFrame extends javax.swing.JFrame {
  32. /**
  33. * Singleton instance of MainFrame
  34. */
  35. private static MainFrame me;
  36. /**
  37. * Returns the singleton instance of MainFrame
  38. * @return MainFrame instance
  39. */
  40. public static MainFrame getMainFrame() {
  41. if (me == null) {
  42. me = new MainFrame();
  43. }
  44. return me;
  45. }
  46. /** Creates new form MainFrame */
  47. public MainFrame() {
  48. initComponents();
  49. setVisible(true);
  50. miAddServer.addActionListener(new ActionListener() {
  51. public void actionPerformed(ActionEvent actionEvent) {
  52. NewServerDialog.showNewServerDialog();
  53. }
  54. });
  55. }
  56. /**
  57. * Adds the specified InternalFrame as a child of the main frame
  58. * @param frame the frame to be added
  59. */
  60. public void addChild(JInternalFrame frame) {
  61. desktopPane.add(frame);
  62. }
  63. /** This method is called from within the constructor to
  64. * initialize the form.
  65. * WARNING: Do NOT modify this code. The content of this method is
  66. * always regenerated by the Form Editor.
  67. */
  68. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  69. private void initComponents() {
  70. desktopPane = new javax.swing.JDesktopPane();
  71. pnSwitchbar = new javax.swing.JPanel();
  72. jMenuBar1 = new javax.swing.JMenuBar();
  73. jMenu1 = new javax.swing.JMenu();
  74. miAddServer = new javax.swing.JMenuItem();
  75. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  76. setTitle("DMDirc");
  77. pnSwitchbar.setMaximumSize(new java.awt.Dimension(150, 32767));
  78. org.jdesktop.layout.GroupLayout pnSwitchbarLayout = new org.jdesktop.layout.GroupLayout(pnSwitchbar);
  79. pnSwitchbar.setLayout(pnSwitchbarLayout);
  80. pnSwitchbarLayout.setHorizontalGroup(
  81. pnSwitchbarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  82. .add(0, 108, Short.MAX_VALUE)
  83. );
  84. pnSwitchbarLayout.setVerticalGroup(
  85. pnSwitchbarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  86. .add(0, 399, Short.MAX_VALUE)
  87. );
  88. jMenu1.setMnemonic('f');
  89. jMenu1.setText("File");
  90. miAddServer.setText("New Server...");
  91. jMenu1.add(miAddServer);
  92. jMenuBar1.add(jMenu1);
  93. setJMenuBar(jMenuBar1);
  94. org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
  95. getContentPane().setLayout(layout);
  96. layout.setHorizontalGroup(
  97. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  98. .add(layout.createSequentialGroup()
  99. .add(pnSwitchbar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  100. .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  101. .add(desktopPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE))
  102. );
  103. layout.setVerticalGroup(
  104. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  105. .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
  106. .add(pnSwitchbar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  107. .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  108. .add(org.jdesktop.layout.GroupLayout.TRAILING, desktopPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
  109. );
  110. pack();
  111. }// </editor-fold>//GEN-END:initComponents
  112. // Variables declaration - do not modify//GEN-BEGIN:variables
  113. private javax.swing.JDesktopPane desktopPane;
  114. private javax.swing.JMenu jMenu1;
  115. private javax.swing.JMenuBar jMenuBar1;
  116. private javax.swing.JMenuItem miAddServer;
  117. private javax.swing.JPanel pnSwitchbar;
  118. // End of variables declaration//GEN-END:variables
  119. }