コード例 #1
0
  private JPanel initServerChoice() {

    JPanel p = new JPanel();
    p.setLayout(new GridLayout(6, 1, 5, 2));
    p.add(new JLabel("Search At: "));

    chosenServer.setText(server.getHost().getHostName());
    p.add(chosenServer);
    chosenServer.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              InetAddress newHost = InetAddress.getByName(chosenServer.getText());
              Whois newServer = new Whois(newHost);
              server = newServer;
            } catch (Exception e) {
              // should use an error dialog here, but that
              // doesn't teach much about networking
              chosenServer.setText(server.getHost().getHostName());
            }
          }
        });

    return p;
  }
コード例 #2
0
  /** Creates the attribute choices. Override to add additional choices. */
  protected void createAttributeChoices(JPanel panel) {
    panel.add(new JLabel("Fill"));
    fFillColor = createColorChoice("FillColor");
    panel.add(fFillColor);

    panel.add(new JLabel("Text"));
    fTextColor = createColorChoice("TextColor");
    panel.add(fTextColor);

    panel.add(new JLabel("Pen"));
    fFrameColor = createColorChoice("FrameColor");
    panel.add(fFrameColor);

    panel.add(new JLabel("Arrow"));
    CommandChoice choice = new CommandChoice();
    fArrowChoice = choice;
    choice.addItem(
        new ChangeAttributeCommand(
            "none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), this));
    choice.addItem(
        new ChangeAttributeCommand(
            "at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), this));
    choice.addItem(
        new ChangeAttributeCommand(
            "at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), this));
    choice.addItem(
        new ChangeAttributeCommand(
            "at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), this));
    panel.add(fArrowChoice);

    panel.add(new JLabel("Font"));
    fFontChoice = createFontChoice();
    panel.add(fFontChoice);
  }
コード例 #3
0
 // 定义添加一行格式化文本框的方法
 private void addRow(String labelText, final JFormattedTextField field) {
   mainPanel.add(new JLabel(labelText));
   mainPanel.add(field);
   final JLabel valueLabel = new JLabel();
   mainPanel.add(valueLabel);
   // 为"确定"按钮添加事件监听器
   // 当用户单击“确定”按钮时,文本框后显示文本框内的值
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Object value = field.getValue();
           // 如果该值是数组,使用Arrays的toString方法输出数组
           if (value.getClass().isArray()) {
             StringBuilder builder = new StringBuilder();
             builder.append('{');
             for (int i = 0; i < Array.getLength(value); i++) {
               if (i > 0) builder.append(',');
               builder.append(Array.get(value, i).toString());
             }
             builder.append('}');
             valueLabel.setText(builder.toString());
           } else {
             // 输出格式化文本框的值
             valueLabel.setText(value.toString());
           }
         }
       });
 }
コード例 #4
0
ファイル: PostTest.java プロジェクト: hhz63857/TDJava
  public PostTestFrame() {
    setTitle("PostTest");

    northPanel = new JPanel();
    add(northPanel, BorderLayout.NORTH);
    northPanel.setLayout(new GridLayout(0, 2));
    northPanel.add(new JLabel("Host: ", SwingConstants.TRAILING));
    final JTextField hostField = new JTextField();
    northPanel.add(hostField);
    northPanel.add(new JLabel("Action: ", SwingConstants.TRAILING));
    final JTextField actionField = new JTextField();
    northPanel.add(actionField);
    for (int i = 1; i <= 8; i++) northPanel.add(new JTextField());

    final JTextArea result = new JTextArea(20, 40);
    add(new JScrollPane(result));

    JPanel southPanel = new JPanel();
    add(southPanel, BorderLayout.SOUTH);
    JButton addButton = new JButton("More");
    southPanel.add(addButton);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            northPanel.add(new JTextField());
            northPanel.add(new JTextField());
            pack();
          }
        });

    JButton getButton = new JButton("Get");
    southPanel.add(getButton);
    getButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            result.setText("");
            final Map<String, String> post = new HashMap<String, String>();
            for (int i = 4; i < northPanel.getComponentCount(); i += 2) {
              String name = ((JTextField) northPanel.getComponent(i)).getText();
              if (name.length() > 0) {
                String value = ((JTextField) northPanel.getComponent(i + 1)).getText();
                post.put(name, value);
              }
            }
            new SwingWorker<Void, Void>() {
              protected Void doInBackground() throws Exception {
                try {
                  String urlString = hostField.getText() + "/" + actionField.getText();
                  result.setText(doPost(urlString, post));
                } catch (IOException e) {
                  result.setText("" + e);
                }
                return null;
              }
            }.execute();
          }
        });

    pack();
  }
コード例 #5
0
ファイル: Server.java プロジェクト: w4-pwr/studia
  Server() {
    setSize(500, 100);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    thread = new Thread(this);
    clientList = new ArrayList<ClientData>();
    sList = new ArrayList<ServerThread>();
    JPanel panel = new JPanel();
    panel.add(new JLabel("Port :"));
    portText = new JTextField(5);
    portText.setText("7777");
    panel.add(portText);
    startButton = new JButton("Start server");
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            try {
              port = Integer.parseInt(portText.getText());
              thread.start();
              startButton.setEnabled(false);
            } catch (NumberFormatException ex) {
              JOptionPane.showMessageDialog(null, "B³êdny format numeru portu");
              portText.setText("");
            }
          }
        });
    panel.add(startButton);
    l = new JLabel("Serwer jest nieaktywny");
    panel.add(l);
    add(panel, BorderLayout.NORTH);
  }
コード例 #6
0
ファイル: About.java プロジェクト: annsofi/kalken
  public About() {
    cl = ClassLoader.getSystemClassLoader();

    // ----------------------------------------CENTER--------------------------------//
    imgAbout = new ImageIcon(cl.getResource("om.png"));

    lblAbout = new JLabel(imgAbout);

    lblAbout.setBounds(0, 0, 450, 263);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(null);
    pnlCenter.add(lblAbout);

    btnOk = new JButton(new ImageIcon(cl.getResource("ok.png")));
    btnOk.setBounds(390, 215, 40, 30);
    pnlCenter.add(btnOk);
    btnOk.addActionListener(this);

    // -----------------------------------CONTAINER----------------------------------//
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(pnlCenter, BorderLayout.CENTER);
    setSize(450, 280);
    setVisible(true);
    setResizable(false);
    setLocation(580, 280);
    // setDefaultCloseOperation(EXIT_ON_CLOSE);

  }
コード例 #7
0
ファイル: MhFrame.java プロジェクト: jordibrus/proview
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
コード例 #8
0
  /** TabbedPaneDemo Constructor */
  public TabbedPaneDemo(SwingSet2 swingset) {
    // Set the title for this demo, and an icon used to represent this
    // demo inside the SwingSet2 app.
    super(swingset, "TabbedPaneDemo", "toolbar/JTabbedPane.gif");

    // create tab position controls
    JPanel tabControls = new JPanel();
    tabControls.add(new JLabel(getString("TabbedPaneDemo.label")));
    top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top")));
    left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left")));
    bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom")));
    right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right")));
    getDemoPanel().add(tabControls, BorderLayout.NORTH);

    group = new ButtonGroup();
    group.add(top);
    group.add(bottom);
    group.add(left);
    group.add(right);

    top.setSelected(true);

    top.addActionListener(this);
    bottom.addActionListener(this);
    left.addActionListener(this);
    right.addActionListener(this);

    // create tab
    tabbedpane = new JTabbedPane();
    getDemoPanel().add(tabbedpane, BorderLayout.CENTER);

    String name = getString("TabbedPaneDemo.laine");
    JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.ewan");
    pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.hania");
    pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.bounce");
    spin = new HeadSpin();
    tabbedpane.add(name, spin);

    tabbedpane
        .getModel()
        .addChangeListener(
            new ChangeListener() {
              public void stateChanged(ChangeEvent e) {
                SingleSelectionModel model = (SingleSelectionModel) e.getSource();
                if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) {
                  spin.go();
                }
              }
            });
  }
コード例 #9
0
 void addTextField(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextField field = new JTextField();
   field.setText(sketch.configFile.get(key));
   field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height));
   fields.put(key, field);
   panel.add(field);
 }
コード例 #10
0
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
コード例 #11
0
 void addTextArea(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextArea field = new JTextArea();
   field.setText(sketch.configFile.get(key));
   field.setLineWrap(true);
   field.setWrapStyleWord(true);
   fields.put(key, field);
   JScrollPane scroll = new JScrollPane(field);
   scroll.setAlignmentX(0.0f);
   panel.add(scroll);
 }
コード例 #12
0
 public void go() {
   JFrame frame = new JFrame("JFrame");
   JPanel mainPanel = new JPanel();
   outgoing = new JTextField(20);
   JButton sendButton = new JButton("send");
   sendButton.addActionListener(new SendButtonListener());
   mainPanel.add(outgoing);
   mainPanel.add(sendButton);
   frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
   setUpNetworking();
   frame.setSize(400, 500);
   frame.setVisible(true);
 }
コード例 #13
0
ファイル: DrawApplet.java プロジェクト: RoDaniel/featurehouse
 protected void createButtons(JPanel panel) {
   panel.add(new Filler(24, 20));
   JComboBox drawingChoice = new JComboBox();
   drawingChoice.addItem(fgUntitled);
   String param = getParameter("DRAWINGS");
   if (param == null) {
     param = "";
   }
   StringTokenizer st = new StringTokenizer(param);
   while (st.hasMoreTokens()) {
     drawingChoice.addItem(st.nextToken());
   }
   if (drawingChoice.getItemCount() > 1) {
     panel.add(drawingChoice);
   } else {
     panel.add(new JLabel(fgUntitled));
   }
   drawingChoice.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (e.getStateChange() == ItemEvent.SELECTED) {
             loadDrawing((String) e.getItem());
           }
         }
       });
   panel.add(new Filler(6, 20));
   JButton button;
   button = new CommandButton(new DeleteCommand("Delete", this));
   panel.add(button);
   button = new CommandButton(new DuplicateCommand("Duplicate", this));
   panel.add(button);
   button = new CommandButton(new GroupCommand("Group", this));
   panel.add(button);
   button = new CommandButton(new UngroupCommand("Ungroup", this));
   panel.add(button);
   button = new JButton("Help");
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           showHelp();
         }
       });
   panel.add(button);
   fUpdateButton = new JButton("Simple Update");
   fUpdateButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           if (fSimpleUpdate) {
             setBufferedDisplayUpdate();
           } else {
             setSimpleDisplayUpdate();
           }
         }
       });
 }
コード例 #14
0
 public MainPanel() {
   super(new BorderLayout());
   JEditorPane editor =
       new JEditorPane("text/html", String.format("<html><a href='%s'>%s</a>", MYSITE, MYSITE));
   editor.setOpaque(false);
   editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
   editor.setEditable(false);
   editor.addHyperlinkListener(
       new HyperlinkListener() {
         @Override
         public void hyperlinkUpdate(HyperlinkEvent e) {
           if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
               && Desktop.isDesktopSupported()) {
             try {
               Desktop.getDesktop().browse(new URI(MYSITE));
             } catch (IOException | URISyntaxException ex) {
               ex.printStackTrace();
             }
             textArea.setText(e.toString());
           }
         }
       });
   JPanel p = new JPanel();
   p.add(editor);
   p.setBorder(BorderFactory.createTitledBorder("Desktop.getDesktop().browse(URI)"));
   add(p, BorderLayout.NORTH);
   add(new JScrollPane(textArea));
   setPreferredSize(new Dimension(320, 240));
 }
コード例 #15
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  protected void addComp(JPanel panel, Component comp, GridBagConstraints gbc, int x, int y) {
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    panel.add(comp, gbc);
  }
コード例 #16
0
  private void initialise() {
    setSize(180, 120);
    setLocation(300, 200);
    setTitle("Working...");
    setVisible(false);
    setModal(true);
    setResizable(false);
    setDefaultCloseOperation(0);
    _stopped = false;
    getContentPane().setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());

    busyTextLabel = new JLabel("Busy - please wait");
    topPanel.add(busyTextLabel, "Center");

    busyIcon = FTAUtilities.loadImageIcon("busy.gif");
    busyIconLabel = new JLabel(busyIcon);
    topPanel.add(busyIconLabel, "West");

    progressBar = new JProgressBar();
    topPanel.add(progressBar, "South");

    getContentPane().add(topPanel);

    stopButton = new JButton("Stop");
    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // System.out.println("'Stop' button pressed");
            _stopped = true;
          }
        });
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            _stopped = true;
          }
        });

    // create panel to hold buttons
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(stopButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
  }
コード例 #17
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
コード例 #18
0
  private JPanel initSearchFields() {

    JPanel p = new JPanel();
    p.setLayout(new GridLayout(6, 1, 5, 2));
    p.add(new JLabel("Search In: "));

    JRadioButton all = new JRadioButton("All", true);
    all.setActionCommand("All");
    searchIn.add(all);
    p.add(all);

    p.add(this.makeSearchInRadioButton("Name"));
    p.add(this.makeSearchInRadioButton("Mailbox"));
    p.add(this.makeSearchInRadioButton("Handle"));

    return p;
  }
コード例 #19
0
ファイル: TCPChat.java プロジェクト: Martin36/martin
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
コード例 #20
0
  /**
   * Constructor for the RingFoilPosController object
   *
   * @param updatingController_in The Parameter
   */
  public RingFoilPosController(UpdatingEventController updatingController_in) {

    updatingController = updatingController_in;

    ringFoilPosCorr = new RingFoilPosCorrector("HORIZONTAL Ring Beam Position at Foil");
    ringFoilPosCorr.setMessageText(getMessageText());

    ringFoilPosMainPanel.setLayout(new BorderLayout());
    ringFoilPosMainPanel.add(ringFoilPosCorr.getPanel(), BorderLayout.CENTER);
  }
コード例 #21
0
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }
コード例 #22
0
 public static void main(String[] args) {
   MojamComponent mc = new MojamComponent();
   JFrame frame = new JFrame();
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(mc);
   frame.setContentPane(panel);
   frame.pack();
   frame.setResizable(false);
   frame.setLocationRelativeTo(null);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
   mc.start();
 }
コード例 #23
0
ファイル: JSplashWindow.java プロジェクト: chenyuguxing/utils
 public JSplashWindow() {
   setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   JPanel splash = new JPanel(new BorderLayout());
   // 获得图片资源的绝对路径
   URL url = getClass().getResource("/images/tu.gif");
   if (url != null) { // 图片嵌入JLabel中显示
     splash.add(new JLabel(new ImageIcon(url)), BorderLayout.CENTER);
   }
   setContentPane(splash); // 给启动窗口设置内容窗格
   Dimension screen = getToolkit().getScreenSize(); // 获得屏幕的大小
   pack();
   // 设定启动窗口在屏幕中的位置
   setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
 }
コード例 #24
0
  public MainPanel() {
    super(new BorderLayout());
    l1.setToolTipText("Test1");
    l2.setToolTipText("Test2");
    l3.setToolTipText("<html><img src='" + url + "'>Test3</html>");

    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createTitledBorder("javax.swing.Timer"));
    p1.add(l1);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(BorderFactory.createTitledBorder("Animated Gif"));
    p2.add(l2, BorderLayout.NORTH);
    p2.add(l3, BorderLayout.SOUTH);

    Box box = Box.createVerticalBox();
    box.add(p1);
    box.add(Box.createVerticalStrut(20));
    box.add(p2);
    box.add(Box.createVerticalGlue());
    add(box);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
コード例 #25
0
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
コード例 #26
0
ファイル: Cliente.java プロジェクト: RuLNi/Chat-gr-fico-v.1.0
  public void hacerInterfaz() {
    ventana_chat = new JFrame("Cliente");
    btn_enviar = new JButton("Enviar");
    txt_mensaje = new JTextField(4);
    area_chat = new JTextArea(10, 17);
    scroll = new JScrollPane(area_chat);
    contenedor_areachat = new JPanel();
    contenedor_areachat.setLayout(new GridLayout(1, 1));
    contenedor_areachat.add(scroll);
    contenedor_btntxt = new JPanel();
    contenedor_btntxt.setLayout(new GridLayout(1, 2));
    contenedor_btntxt.add(txt_mensaje);
    contenedor_btntxt.add(btn_enviar);
    ventana_chat.setLayout(new BorderLayout());
    ventana_chat.add(contenedor_areachat, BorderLayout.NORTH);
    ventana_chat.add(contenedor_btntxt, BorderLayout.SOUTH);
    ventana_chat.setSize(300, 220);
    ventana_chat.setVisible(true);
    ventana_chat.setResizable(false);
    ventana_chat.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Thread principal =
        new Thread(
            new Runnable() {
              public void run() {
                try {
                  socket = new Socket("localhost", 8000);
                  leer();
                  escribir();
                } catch (Exception ex) {
                  ex.printStackTrace();
                }
              }
            });
    principal.start();
  }
コード例 #27
0
 /**
  * Adds a row to the main panel.
  *
  * @param labelText the label of the field
  * @param field the sample field
  */
 public void addRow(String labelText, final JFormattedTextField field) {
   mainPanel.add(new JLabel(labelText));
   mainPanel.add(field);
   final JLabel valueLabel = new JLabel();
   mainPanel.add(valueLabel);
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Object value = field.getValue();
           Class<?> cl = value.getClass();
           String text = null;
           if (cl.isArray()) {
             if (cl.getComponentType().isPrimitive()) {
               try {
                 text = Arrays.class.getMethod("toString", cl).invoke(null, value).toString();
               } catch (ReflectiveOperationException ex) {
                 // ignore reflection exceptions
               }
             } else text = Arrays.toString((Object[]) value);
           } else text = value.toString();
           valueLabel.setText(text);
         }
       });
 }
コード例 #28
0
  private void buildInterface() {

    // Panel p to hold the label and text field
    JPanel panelInput = new JPanel();
    panelInput.setLayout(new BorderLayout());
    panelInput.add(buttonSelect, BorderLayout.EAST);
    panelInput.add(textFolder, BorderLayout.CENTER);
    textFolder.setEditable(false);
    textFolder.setText(System.getProperty("user.home") + "\\"); // Set default save location

    setLayout(new BorderLayout());
    add(panelInput, BorderLayout.NORTH);
    add(new JScrollPane(textArea), BorderLayout.CENTER);
    textArea.setEditable(false);

    buttonSelect.setToolTipText(TOOL_TIP_SELECT_FOLDER);
    buttonSelect.addActionListener(new ButtonListener()); // Register listener
  }
コード例 #29
0
  public void initUI() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      JPopupMenu.setDefaultLightWeightPopupEnabled(false);
      frame = new JFrame("Project Benelux | 317 | Fullscreen - Resizeable");
      frame.setLayout(new BorderLayout());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gamePanel = new JPanel();
      new AutoUpdater().run();
      webclient = false;
      gamePanel.setLayout(new BorderLayout());
      gamePanel.add(this);
      JMenu fileMenu = new JMenu("File");

      String[] mainButtons = new String[] {"-", "Exit", "-"};

      for (String name : mainButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) {
          fileMenu.addSeparator();
        } else {
          menuItem.addActionListener(this);
          fileMenu.add(menuItem);
        }
      }

      JMenuBar menuBar = new JMenuBar();
      JMenuBar jmenubar = new JMenuBar();
      Dimension dimension1 = new Dimension(765 + 16, 503 + 59);
      frame.setMinimumSize(dimension1);
      frame.add(jmenubar);
      menuBar.add(fileMenu);
      frame.getContentPane().add(menuBar, BorderLayout.NORTH);
      frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
      frame.pack();

      frame.setVisible(true); // can see the client
      frame.setResizable(true); // resizeable frame
      init();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #30
0
  /**
   * The GPropertiesDialog class constructor.
   *
   * @param gui the GUI class
   */
  public GPropertiesDialog(GUI gui) {
    // superclass constructor
    super(gui, "Properties", false);
    objects = new ObjectContainer();

    // gui
    this.gui = gui;

    // set the fixed size
    setSize(260, 350);
    setResizable(false);
    setLayout(null);

    // set up panels for stuff
    pane = new JTabbedPane();

    // add the tabbed panel
    tabbedPanePanel = new JPanel();
    tabbedPanePanel.add(pane);
    tabbedPanePanel.setLayout(null);
    this.getContentPane().add(tabbedPanePanel);
    tabbedPanePanel.setBounds(0, 0, this.getWidth(), 280);
    pane.setBounds(0, 0, tabbedPanePanel.getWidth(), tabbedPanePanel.getHeight());

    // set up buttons
    apply = new JButton("Apply");
    apply.setBounds(150, 290, 80, 26);
    this.getContentPane().add(apply);

    close = new JButton("Close");
    close.setBounds(50, 290, 80, 26);
    this.getContentPane().add(close);

    addPanel(new GPropertiesPanelCustomObject(gui.getGMap()), "Object");

    // add listeners
    addMouseListener(this);
    apply.addItemListener(this);
    apply.addActionListener(this);
    close.addItemListener(this);
    close.addActionListener(this);
  }