Beispiel #1
1
 @Override
 public void paintChildren(Graphics g) {
   super.paintChildren(g);
   if (exitAfterFirstPaint) {
     System.exit(0);
   }
 }
Beispiel #2
0
  /** 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);
  }
 // 定义添加一行格式化文本框的方法
 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());
           }
         }
       });
 }
Beispiel #4
0
  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);
  }
Beispiel #5
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);
  }
Beispiel #6
0
  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);

  }
Beispiel #7
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;
  }
Beispiel #8
0
  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();
  }
 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));
 }
Beispiel #10
0
  // 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);
  }
  /**
   * 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);
  }
  /** methode creatWidget dimmensionne panelConnect et panelInit */
  public void createWidget() {

    panConn = createPanelConnect();
    panConn.setSize(new Dimension(350, 100));
    panInit = createPanelInit();
    panInit.setPreferredSize(new Dimension(1200, 300));
    panParty = createPanelPlay();

    setContentPane(panConn);
  }
 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);
 }
 /** 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());
   }
 }
 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);
 }
 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);
 }
 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();
 }
Beispiel #18
0
 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();
           }
         }
       });
 }
Beispiel #19
0
 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);
 }
Beispiel #20
0
  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);
  }
Beispiel #21
0
  @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());
  }
Beispiel #22
0
    public void paintComponent(Graphics page) {
      super.paintComponent(page);

      Image icon = this.getToolkit().getImage("chess1.jpg");
      page.drawImage(icon, -40, 20, this);

      setOpaque(false);
    }
 @Override
 public void paintComponent(Graphics g) {
   if (selected) {
     g.setColor(selColor);
     g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10);
     label.setForeground(Color.YELLOW);
   } else label.setForeground(Color.WHITE);
   super.paintComponent(g);
 }
Beispiel #24
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
  }
  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();
    }
  }
  /**
   * 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);
  }
  /** 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();
                }
              }
            });
  }
Beispiel #28
0
  // draws the current snapshot
  public void paintComponent(Graphics g) {

    // System.out.println("In paint in draw");
    super.paintComponent(g);
    my_width = getSize().width;
    my_height = getSize().height;
    if (my_image != null) g.drawImage(my_image, 0, 0, my_width, my_height, this);

    setBackground(new Color(1.0f, 1.0f, 1.0f));
    //         g.setColor(Color.black);
    //         g.drawRect(0,0,my_width-1,my_height-1);

  }
 /** Applet initialization */
 public void init() {
   // Get the port to be used
   String port_str = getParameter("port");
   if (port_str != null) {
     port = Integer.parseInt(port_str);
   }
   // Try to use the system look and feel
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   // Create main panel to hold notebook
   main_panel = new JPanel();
   main_panel.setBackground(Color.white);
   main_panel.setLayout(new BorderLayout());
   setContentPane(main_panel);
   // Create the notebook
   tabbed_pane = new JTabbedPane(JTabbedPane.TOP);
   main_panel.add(tabbed_pane, BorderLayout.CENTER);
   // Add notebook page for default host connection
   pages = new Vector();
   addPage(new SOAPMonitorPage(getCodeBase().getHost()));
 }
  public void init() {
    // 添加按钮
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);

    mainPanel.setLayout(new GridLayout(0, 3));
    mainWin.add(mainPanel, BorderLayout.CENTER);

    JFormattedTextField intField0 =
        new JFormattedTextField(
            new InternationalFormatter(NumberFormat.getIntegerInstance()) {
              protected DocumentFilter getDocumentFilter() {
                return new NumberFilter();
              }
            });
    intField0.setValue(100);
    addRow("只接受数字的文本框", intField0);

    JFormattedTextField intField1 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField1.setValue(new Integer(100));
    // 添加输入校验器
    intField1.setInputVerifier(new FormattedTextFieldVerifier());
    addRow("带输入校验器的文本框", intField1);

    // 创建自定义格式器对象
    IPAddressFormatter ipFormatter = new IPAddressFormatter();
    ipFormatter.setOverwriteMode(false);
    // 以自定义格式器对象创建格式化文本框
    JFormattedTextField ipField = new JFormattedTextField(ipFormatter);
    ipField.setValue(new byte[] {(byte) 192, (byte) 168, 4, 1});
    addRow("IP地址格式", ipField);

    mainWin.add(buttonPanel, BorderLayout.SOUTH);
    mainWin.pack();
    mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainWin.setVisible(true);
  }