예제 #1
0
  public PasswordDialog(final JFrame owner) {
    super(owner, "Login", true);
    setSize(280, 150);
    user = new JTextField(10);
    user.addActionListener(this);
    password = new JPasswordField(10);
    password.addActionListener(this);
    JPanel center = new JPanel();
    center.setLayout(new GridLayout(3, 2));
    center.add(new JLabel("Enter UserName:"******"Enter Password: "******"Submit");
    submitButton.setActionCommand("SUBMIT");
    submitButton.addActionListener(this);

    JButton helpButton = new JButton("Help");
    south.add(submitButton);
    south.add(helpButton);
    helpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent aEvent) {
            JOptionPane.showMessageDialog(
                owner,
                "Your username and password are the same as those\n"
                    + "you use to access your O'Reilly School of Technology courses. \n");
          }
        });
    Container contentPane = getContentPane();
    contentPane.add(center, BorderLayout.CENTER);
    contentPane.add(south, BorderLayout.SOUTH);
  }
예제 #2
0
 /**
  * Add in a Layout depending on Java Virtual Machine
  *
  * @param ct Container
  * @param c Component
  * @param s String
  */
 protected static void makeAdd(Container ct, Component c, String s) {
   try {
     ct.add(c, s);
   } catch (Error e) {
     ct.add(s, c);
   }
 }
  private DKF_XemThongTinMonHoc() {
    setSize(320, 230);
    setTitle("XemThongTinMonHoc");
    setResizable(true);
    setMaximizable(true);
    setClosable(true);
    setIconifiable(true);

    contentPane = getContentPane();
    panel1 = new JPanel();
    panel2 = new JPanel();

    btnOK = new JButton("Dong Y");
    btnClear = new JButton("Clear");
    tefNhapTenMH = new JTextField(25);
    l1 = new JLabel("Xem Thong Tin Mon Hoc");
    l2 = new JLabel("Nhap Ten Mon Hoc Can Xem: ");

    btnOK.addActionListener(this);
    btnClear.addActionListener(this);

    contentPane.add(panel1, "North");
    contentPane.add(panel2, "Center");

    panel1.add(l1);
    panel2.add(l2);
    panel2.add(tefNhapTenMH);
    panel2.add(btnOK);
    panel2.add(btnClear);
  }
예제 #4
0
  /** Create a view of the given width and height. */
  public SimulatorView(int height, int width) {
    stats = new FieldStats();
    colors = new HashMap<Class, Color>();

    setTitle("Ocean Simulation");
    stepLabel = new JLabel(STEP_PREFIX, JLabel.CENTER);
    population = new JLabel(POPULATION_PREFIX, JLabel.LEFT);

    setLocation(100, 50);

    fieldView = new FieldView(height, width);

    Container contents = getContentPane();
    contents.add(stepLabel, BorderLayout.NORTH);
    contents.add(fieldView, BorderLayout.CENTER);
    contents.add(population, BorderLayout.SOUTH);

    // Make sure that closing the window ends the application
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            exitApp();
          }
        });

    pack();
    setVisible(true);
  }
예제 #5
0
  private void setUpGui() {
    area = JokemonDriver.Area.Stringville;
    mouse = new Point();
    int thingInt = 0;
    this.setTitle("Town Map");
    this.setSize(195, 239);
    this.setResizable(false);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setVisible(false);
    visible = false;
    this.setLocationRelativeTo(null);
    Container cp = this.getContentPane();

    JLabel map = new JLabel();
    map.setBounds(1, -5, 188, 176);
    map.setIcon(new ImageIcon(townMap.class.getResource("Logos/townmap.png")));

    closeWindow = new JButton();
    closeWindow.setText("Close Window");
    closeWindow.setBounds(0, 192, 188, 20);

    areaDisplay = new JLabel();
    areaDisplay.setText(area.toString().replace('_', ' '));
    areaDisplay.setHorizontalAlignment(JLabel.CENTER);
    areaDisplay.setBounds(0, 171, 188, 20);

    addMouseMotionListener(this);
    closeWindow.addActionListener(this);
    cp.add(map);
    cp.add(closeWindow);
    cp.add(areaDisplay);
  }
예제 #6
0
 /**
  * Introduce the Scout449 program!
  *
  * @param stat the Scout449 responsible for this object
  */
 public Intro(Scout449 stat) {
   super("Loading Scout449");
   setVisible(false);
   setUndecorated(true);
   setIconImage(stat.getImage("winicon"));
   loadImage();
   getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
   setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
   Container c = getContentPane();
   c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
   c.add(Box.createVerticalGlue());
   Loading load = new Loading();
   load.setOpaque(true);
   load.setAlignmentX(JComponent.CENTER_ALIGNMENT);
   c.add(load);
   setCursor(Constants.WAIT);
   c.add(Box.createVerticalGlue());
   // center the window
   Dimension ss = AppLib.winInfo.getScreenSize();
   setBounds(
       (ss.width - Constants.INTRO_WIDTH) / 2,
       (ss.height - Constants.INTRO_HEIGHT) / 2,
       Constants.INTRO_WIDTH,
       Constants.INTRO_HEIGHT);
   setVisible(true);
 }
예제 #7
0
  public DirTreeModified() {
    Container c = getContentPane();
    // *** Build the tree and a mouse listener to handle clicks
    root = readNode();
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);

    MouseListener ml =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (box.isSelected()) {
              showDetails(tree.getPathForLocation(e.getX(), e.getY()));
            }
          }
        };
    tree.addMouseListener(ml);
    // *** panel the JFrame to hold controls and the tree
    controls = new JPanel();
    box = new JCheckBox(showString);
    init(); // ** set colors, fonts, etc. and add buttons
    c.add(controls, BorderLayout.NORTH);
    c.add(tree, BorderLayout.CENTER);
    setVisible(true); // ** display the framed window
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // ** kills process on exit.
  }
예제 #8
0
  public MixingColors() {
    super("Selecting a color");
    contents = getContentPane();
    contents.setLayout(new FlowLayout());

    red = new JCheckBox("red");
    green = new JCheckBox("green");
    blue = new JCheckBox("blue");

    label = new JLabel("Watch my background");
    label.setOpaque(true);
    label.setForeground(Color.GRAY);
    label.setBackground(new Color(0, 0, 0));

    contents.add(red);
    contents.add(green);
    contents.add(blue);
    contents.add(label);

    // create CheckBoxHandler event handler
    // and register it on the checkboxes
    CheckBoxHandler cbh = new CheckBoxHandler();
    red.addItemListener(cbh);
    green.addItemListener(cbh);
    blue.addItemListener(cbh);

    setSize(225, 200);
    setVisible(true);
  }
예제 #9
0
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    jScrollPane1 = new JScrollPane();
    txtReport = new JTextPane();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    // ======== this ========
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            thisWindowClosing(e);
          }
        });
    Container contentPane = getContentPane();
    contentPane.setLayout(
        new FormLayout(
            "default, $lcgap, default:grow, $lcgap, default",
            "2*(default, $lgap), fill:default:grow, $lgap, fill:default, $lgap, default"));

    // ======== jScrollPane1 ========
    {
      jScrollPane1.setViewportView(txtReport);
    }
    contentPane.add(jScrollPane1, CC.xy(3, 5));

    // ======== panel1 ========
    {
      panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

      // ---- btnCancel ----
      btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
      btnCancel.setText(null);
      btnCancel.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              btnCancelActionPerformed(e);
            }
          });
      panel1.add(btnCancel);

      // ---- btnSave ----
      btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
      btnSave.setText(null);
      btnSave.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              btnSaveActionPerformed(e);
            }
          });
      panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(3, 7, CC.RIGHT, CC.DEFAULT));
    setSize(462, 379);
    setLocationRelativeTo(null);
  } // </editor-fold>//GEN-END:initComponents
  public static void addToPane(Container pane) {
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridy = 0;
    pane.add(input, c);
    c.gridy = 1;
    pane.add(output, c);
    c.gridy = 2;
    analyze.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            table = new HashTable();
            String toAnalyze = input.getText();
            Scanner in = new Scanner(toAnalyze);
            in.useDelimiter("[^\\p{Alpha}']+");
            while (in.hasNext()) {
              table.add(in.next().toLowerCase());
            }

            output.setText(table.toString());
            // output.setText("" + table.uniqueWords);
          }
        });
    pane.add(analyze, c);
  }
예제 #11
0
  /**
   * Set the value of content
   *
   * @param newVar the new value of content
   */
  private void setContent(final counts a, final connections cnc_a) {
    // Creates a new container
    content = frame.getContentPane();
    // sets the layout
    content.setLayout(new BorderLayout());

    this.setTaskbar(); // sets the taskbar
    // adding the taskbar to the bottom-part
    content.add(taskbar, BorderLayout.SOUTH);

    this.setDraw_pad(a, cnc_a, this.getTaskbar()); // sets the drawPad
    JScrollPane Padscroller = new JScrollPane();
    Padscroller.setWheelScrollingEnabled(true);
    Padscroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    Padscroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    Padscroller.setPreferredSize(new Dimension(200, 100));
    // Padscroller.setMinimumSize(new Dimension(200, 100));
    // Padscroller.setMaximumSize(new Dimension(200, 100));
    Padscroller.setViewportView(drawPad);
    content.add(Padscroller, BorderLayout.CENTER);

    this.setPanel(a, cnc_a); // sets the panel
    JScrollPane scroller = new JScrollPane(panel);
    scroller.setWheelScrollingEnabled(true);
    scroller.setPreferredSize(new Dimension(125, 80));
    scroller.setMinimumSize(new Dimension(125, 80));
    scroller.setMaximumSize(new Dimension(125, 80));
    // sets the scroller to the west portion
    content.add(scroller, BorderLayout.WEST);
    // content.add(panel, BorderLayout.WEST);
  }
예제 #12
0
  UserInputValidationErrorBox(Frame parent, YWorkItem item, YDataStateException e) {
    super(parent, "Problem with your input data");
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel p = new JPanel(new BorderLayout());
    p.setBackground(YAdminGUI._apiColour);
    p.add(createTopPanel(item), BorderLayout.NORTH);
    p.add(createCentrePanel(e), BorderLayout.CENTER);
    c.add(p, BorderLayout.CENTER);
    c.add(createBottomPanel(), BorderLayout.SOUTH);
    c.setBackground(YAdminGUI._apiColour);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            storeData();
            this_windowClosing();
          }
        });

    Double screenWidth =
        new Double(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth());
    Double screenHeight =
        new Double(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight());
    setSize(new Double(screenWidth * 0.8).intValue(), new Double(screenHeight * 0.8).intValue());

    Dimension labelSize = this.getSize();
    setLocation(
        screenWidth.intValue() / 2 - (labelSize.width / 2),
        screenHeight.intValue() / 2 - (labelSize.height / 2));
    show();
  }
예제 #13
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
예제 #14
0
  public SwingTest() {
    Container contentPane = getContentPane();

    pnTop.setBackground(Color.pink);
    pnCenter.setBackground(Color.YELLOW);
    pnBottom.setBackground(Color.BLUE);

    this.setLayout(new GridLayout(4, 1));

    pnTop.add(lbName);
    pnTop.setLayout(new FlowLayout());

    contentPane.add(pnTop);

    pnCenter.add(lbAge);
    contentPane.add(pnCenter);

    pnBottom.add(lbAddress);
    contentPane.add(pnBottom);

    pnResult.add(lbResult);
    contentPane.add(pnResult);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

    int nXpos = (int) (screen.getWidth() / 2 - super.getWidth() / 2);
    int nYpos = (int) (screen.getHeight() / 2 - super.getHeight() / 2);
    setSize(nXpos, nYpos);
    setVisible(true);
  }
예제 #15
0
파일: Run.java 프로젝트: kidaak/Examples
  public Run(int width, int height) {
    this.WIDTH = width;
    this.HEIGHT = height;
    Container contentPane = getContentPane();

    JButton startButton = new JButton("Draw");
    final JPanel panel = new JPanel();

    contentPane.add(panel, BorderLayout.CENTER);
    contentPane.add(startButton, BorderLayout.SOUTH);
    setSize(WIDTH, HEIGHT);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Graphics g = panel.getGraphics();
            for (int i = 0; i < 20; ++i) {
              Shape shape = ShapeFactory.getShape(getRandomShape());
              shape.draw(
                  g,
                  getRandomX(),
                  getRandomY(),
                  getRandomWidth(),
                  getRandomHeight(),
                  getRandomColor());
            }
          }
        });
  }
예제 #16
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Add");
    frame.setLocation(500, 400);
    //		frame.setPreferredSize(new Dimension(250, 100));
    Container contentPane = frame.getContentPane();

    FlowLayout layout = new FlowLayout();
    contentPane.setLayout(layout);
    JPanel panel = new JPanel();
    panel.add(new JTextField(6));
    panel.add(new JLabel("+"));
    panel.add(new JTextField(6));
    panel.add(new JLabel("="));
    panel.add(new JTextField(6));

    contentPane.add(panel, BorderLayout.CENTER);

    JPanel panel2 = new JPanel();
    panel2.add(new JButton("확인"));
    panel2.add(new JButton("취소"));
    contentPane.add(panel2, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
예제 #17
0
 private void createMarginBox(Container c, Component comp) {
   c.add(Box.createVerticalStrut(10));
   Box lrMargins = Box.createHorizontalBox();
   lrMargins.add(Box.createHorizontalStrut(10));
   lrMargins.add(comp);
   lrMargins.add(Box.createHorizontalStrut(10));
   c.add(lrMargins);
   c.add(Box.createVerticalStrut(10));
 }
예제 #18
0
  public DistributedTextEditor() {
    area1.setFont(new Font("Monospaced", Font.PLAIN, 12));

    area2.setFont(new Font("Monospaced", Font.PLAIN, 12));
    ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec);
    area2.setEditable(false);

    Container content = getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    JScrollPane scroll1 =
        new JScrollPane(
            area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll1, BorderLayout.CENTER);

    JScrollPane scroll2 =
        new JScrollPane(
            area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll2, BorderLayout.CENTER);

    content.add(ipaddress, BorderLayout.CENTER);
    content.add(portNumber, BorderLayout.CENTER);

    JMenuBar JMB = new JMenuBar();
    setJMenuBar(JMB);
    JMenu file = new JMenu("File");
    JMenu edit = new JMenu("Edit");
    JMB.add(file);
    JMB.add(edit);

    file.add(Listen);
    file.add(Connect);
    file.add(Disconnect);
    file.addSeparator();
    file.add(Save);
    file.add(SaveAs);
    file.add(Quit);

    edit.add(Copy);
    edit.add(Paste);
    edit.getItem(0).setText("Copy");
    edit.getItem(1).setText("Paste");

    Save.setEnabled(false);
    SaveAs.setEnabled(false);
    Disconnect.setEnabled(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    area1.addKeyListener(k1);
    area1.addMouseListener(m1);
    setTitle("Disconnected");
    setVisible(true);
    area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0);

    this.addWindowListener(w1);
  }
예제 #19
0
파일: Button2.java 프로젝트: ktw14/vitoex
 public void init() {
   b1.addActionListener(bl);
   b2.addActionListener(bl);
   Container cp = getContentPane();
   cp.setLayout(new FlowLayout());
   cp.add(b1);
   cp.add(b2);
   cp.add(txt);
 }
예제 #20
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
예제 #21
0
 public AllProperties() {
   super("Properties", true, false, true, true);
   Container contentPane = getContentPane();
   contentPane.setLayout(new GridLayout(2, 1, 10, 10));
   contentPane.add(new PropertyPanel("System Properties", System.getProperties()));
   contentPane.add(new PropertyPanel("Aleph Properties", Aleph.getProperties()));
   setPreferredSize(preferred);
   setBounds(0, 0, preferred.width, preferred.height);
 }
예제 #22
0
  /**
   * Cr�e une nouvelle instance de CreeTrans
   *
   * @param mf fenetre principale de l'application
   * @param zg Zone graphique
   * @param auto automate
   * @param be barre d'�tat
   */
  public TransCreator(MainFrame mf, GraphicZone g, Automate auto, StateBar be) {

    super(JOptionPane.getFrameForComponent(mf), "Creating interaction", true);

    this.setResizable(false);

    this.gz = g;
    this.auto = auto;
    this.bar = be;
    this.mf = mf;

    be.displayInfo("Creating interaction");

    tfJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel1.setBackground(Color.lightGray);
    tfJPanel1.add(new JLabel("Type  : "));
    groupe = new CheckboxGroup();
    plus = new Checkbox("activator", groupe, true);
    tfJPanel1.add(plus);
    minus = new Checkbox("inhibitor", groupe, false);
    tfJPanel1.add(minus);

    tfJPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel2.setBackground(Color.lightGray);
    tfJPanel2.add(new JLabel("Threshold  = "));
    tf = new JTextField(auto.nbrCharTransLabel);
    tf.setText("1");
    tfJPanel2.add(tf);

    btJPanel = new JPanel(new GridLayout(1, 2, 0, 0));
    btJPanel.setBackground(Color.lightGray);
    ok = new Button("Ok");
    ok.setBackground(Color.lightGray);
    ok.addActionListener(this);
    cancel = new Button("Cancel");
    cancel.setBackground(Color.lightGray);
    cancel.addActionListener(this);
    btJPanel.add(ok);
    btJPanel.add(cancel);

    content = this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBackground(Color.lightGray);
    content.add(tfJPanel1, BorderLayout.NORTH);
    content.add(tfJPanel2, BorderLayout.CENTER);
    content.add(btJPanel, BorderLayout.SOUTH);

    this.pack();
    this.setLocationRelativeTo(this.mf);

    tf.requestFocusInWindow();

    // rendre la fenetre visible
    setVisible(true);
  }
예제 #23
0
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
예제 #24
0
파일: SineWave.java 프로젝트: haomen/refs
 public void init() {
   Container cp = getContentPane();
   cp.add(sines);
   cycles.addChangeListener(
       new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
           sines.setCycles(((JSlider) e.getSource()).getValue());
         }
       });
   cp.add(BorderLayout.SOUTH, cycles);
 }
  // Create an editor.
  public SimpleEditor() {
    super("Swing Editor");
    textComp = createTextComponent();
    makeActionsPretty();

    Container content = getContentPane();
    content.add(textComp, BorderLayout.CENTER);
    content.add(createToolBar(), BorderLayout.NORTH);
    setJMenuBar(createMenuBar());
    setSize(320, 240);
  }
예제 #26
0
  public void start() {
    frame = new JFrame("Multiple Components");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new BorderLayout());

    // Label for instructions
    label = new JLabel("Use the buttons to control the layout of text");
    contentPane.add(label, BorderLayout.NORTH);

    // West panel
    westpanel = new JPanel();
    westpanel.setLayout(new BoxLayout(westpanel, BoxLayout.Y_AXIS));

    buttonwrap = new JButton("Wrap Text       ");
    buttonwrap.addActionListener(this);
    westpanel.add(buttonwrap);
    buttonDoNotWrap = new JButton("Do Not Wrap Text");
    buttonDoNotWrap.addActionListener(this);
    westpanel.add(buttonDoNotWrap);
    buttonBlank = new JButton("                ");
    buttonBlank.addActionListener(this);
    westpanel.add(buttonBlank);
    buttonClearText = new JButton("Clear Text     ");
    buttonClearText.addActionListener(this);
    westpanel.add(buttonClearText);
    contentPane.add(westpanel, BorderLayout.WEST);

    // Text area
    textArea = new JTextArea(10, 25);
    scrollArea = new JScrollPane(textArea);
    contentPane.add(scrollArea, BorderLayout.CENTER);

    // East panel to control scroll bars
    eastpanel = new JPanel();
    eastpanel.setLayout(new BoxLayout(eastpanel, BoxLayout.Y_AXIS));

    buttonScrollV = new JButton("Scroll Vertically");
    buttonScrollV.addActionListener(this);
    eastpanel.add(buttonScrollV);
    buttonScrollH = new JButton("Scroll Horizontally");
    buttonScrollH.addActionListener(this);
    eastpanel.add(buttonScrollH);
    buttonScrollBothWays = new JButton("Scroll Both Ways");
    buttonScrollBothWays.addActionListener(this);
    eastpanel.add(buttonScrollBothWays);
    buttonDoNotScroll = new JButton("Do Not Scroll");
    buttonDoNotScroll.addActionListener(this);
    eastpanel.add(buttonDoNotScroll);
    contentPane.add(eastpanel, BorderLayout.EAST);

    frame.pack();
    frame.setVisible(true);
  }
예제 #27
0
 MyDesktop() {
   // fr1 = new JInternalFrame("FlowLayout", true, true);
   fr1.setBounds(10, 10, 150, 150);
   Container c = fr1.getContentPane();
   c.setLayout(new FlowLayout());
   c.add(new JButton("1"));
   c.add(new JButton("2"));
   c.add(new JButton("3"));
   c.add(new JButton("4"));
   add(fr1, 0);
 }
 public AutoAnalize() {
   Container vidus = getContentPane();
   vidus.setLayout(new BoxLayout(vidus, BoxLayout.Y_AXIS));
   vidus.add(panAutoSąr);
   vidus.add(panDuomenys);
   jbReg.addActionListener(this);
   //        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   išdėstymas();
   kosmetika();
   setVisible(true);
   pack();
 }
예제 #29
0
  SimpleJFrame() {
    // user interface
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("SimpleJFrame");
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());

    cp.add(new JButton("Press"));
    cp.add(new JTextField(8));
    pack();
    show();
  }
예제 #30
0
파일: Robots.java 프로젝트: yuan51/CS180
 public void add() {
   mainFrame.setDefaultCloseOperation(mainFrame.EXIT_ON_CLOSE);
   statusPanel.add(jl);
   menuBar.add(menu);
   menu.add(menuItem);
   menuItem.addActionListener(this);
   container.setLayout(new BorderLayout());
   container.add(menuBar, BorderLayout.NORTH);
   container.add(jl, BorderLayout.SOUTH);
   mainFrame.pack();
   mainFrame.setVisible(true);
 }