/**
  * Returns the location where to dock the given {@code JToolBar}, at the given constraint
  * position. The constraint position must be one of the constants {@code BorderLayout.NORTH
  * NORTH}, {@code BorderLayout.EAST EAST}, {@code BorderLayout.SOUTH SOUTH}, or {@code
  * BorderLayout.WEST WEST}.
  *
  * <p><b>Note:</b> This method is accessed in the current executing thread. Such thread may or may
  * not be the event dispatch thread (EDT.) Client code must call this method from the EDT.
  *
  * @param toolBar the target {@code JToolBar}.
  * @param dock the container where to dock the {@code JToolBar} to.
  * @param constraint the constraint position.
  * @return the location where to dock the given {@code JToolBar}.
  * @throws IllegalArgumentException if the constraint has an invalid value.
  */
 @RunsInCurrentThread
 public @Nonnull Point dockLocation(
     @Nonnull JToolBar toolBar, @Nonnull Container dock, @Nonnull String constraint) {
   checkValid(constraint);
   Insets insets = dock.getInsets();
   // BasicToolBarUI prioritizes location N/E/W/S by proximity to the respective border. Close to
   // top border is N, even
   // if close to the left or right border.
   int offset = isHorizontal(toolBar) ? toolBar.getHeight() : toolBar.getWidth();
   Dimension dockSize = dock.getSize();
   if (NORTH.equals(constraint)) {
     return new Point(dockSize.width / 2, insets.top);
   }
   if (EAST.equals(constraint)) {
     return new Point(
         dockSize.width - insets.right - 1,
         verticalDockingYCoordinate(dockSize.height, insets, offset));
   }
   if (WEST.equals(constraint)) {
     return new Point(insets.left, verticalDockingYCoordinate(dockSize.height, insets, offset));
   }
   int x = dockSize.width / 2;
   // Make sure we don't get mistaken for EAST or WEST
   if (x < insets.left + offset) {
     x = insets.left + offset;
   } else if (x > dockSize.width - insets.right - offset - 1) {
     x = dockSize.width - insets.right - offset - 1;
   }
   return new Point(x, dockSize.height - insets.bottom - 1);
 }
Example #2
0
  public AboutPanel() {
    setTitle("About Panel");
    ImageIcon img = new ImageIcon("icons/preferences.jpg");
    setIconImage(img.getImage());
    Container contentPane = getContentPane();
    contentPane.setLayout(new MigLayout());

    setBackground(Color.GRAY);

    int style1 = Font.CENTER_BASELINE;
    Font font = new Font("Arial", style1, 13);

    about = new JLabel();
    about.setFont(font);
    String key = userPrefs.getRegistrationKey();
    if (key == null || key.length() == 0) {
      userPrefs.setRegistrationKey("Community Edition");
    }
    about.setText("<html>WattzAp Community Edition<br/><br/>Version 2.5.1<br/>19th August 2015");
    add(about, "alignx right, span");

    debug = new JCheckBox("Enable Debugging");
    if (userPrefs.isDebug()) {
      debug.setSelected(true);
    } else {
      debug.setSelected(false);
    }
    debug.addActionListener(this);
    add(debug);

    Dimension d = new Dimension(550, 300);
    this.setPreferredSize(d);
    pack();
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
    public void actionPerformed(ActionEvent e) {
      int selIndexBefore = getSelectedIndex();
      myDefaultAction.actionPerformed(e);
      int selIndexCurrent = getSelectedIndex();
      if (selIndexBefore != selIndexCurrent) {
        return;
      }
      if (myFocusNext && selIndexCurrent == 0) {
        return;
      }

      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      Container container = kfm.getCurrentFocusCycleRoot();
      FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
      if (policy == null) {
        policy = kfm.getDefaultFocusTraversalPolicy();
      }
      Component next =
          myFocusNext
              ? policy.getComponentAfter(container, PaletteItemsComponent.this)
              : policy.getComponentBefore(container, PaletteItemsComponent.this);
      if (next instanceof PaletteGroupComponent) {
        clearSelection();
        next.requestFocus();
        ((PaletteGroupComponent) next).scrollRectToVisible(next.getBounds());
      }
    }
Example #5
0
  public static JInternalFrame create(ActionContext actionContext) {
    // 变量
    Thing self = (Thing) actionContext.get("self");
    Container parent = (Container) actionContext.get("parent");

    // 创建
    JInternalFrame comp = new JInternalFrame();
    if (parent != null) {
      parent.add(comp);
    }

    // 初始化
    init(comp, self, parent, actionContext);

    // 创建子节点
    try {
      actionContext.push().put("parent", comp);
      for (Thing child : self.getChilds()) {
        child.doAction("create", actionContext);
      }
    } finally {
      actionContext.pop();
    }

    // 放置和返回变量
    actionContext.getScope(0).put(self.getMetadata().getName(), comp);
    return comp;
  }
Example #6
0
  public void run(DataLayer pnmlData) {
    // Build interface
    JDialog guiDialog = new JDialog(CreateGui.getApp(), MODULE_NAME, true);

    // 1 Set layout
    Container contentPane = guiDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    // 2 Add file browser
    contentPane.add(sourceFilePanel = new PetriNetChooserPanel("Source net", pnmlData));

    // 3 Add results pane
    contentPane.add(results = new ResultsHTMLPane(pnmlData.getURI()));

    // 4 Add button
    contentPane.add(new ButtonBar("Analyse", analyseButtonClick));

    // 5 Make window fit contents' preferred size
    guiDialog.pack();

    // 6 Move window to the middle of the screen
    guiDialog.setLocationRelativeTo(null);

    guiDialog.setVisible(true);

    //    warnUser(pnmlData.getURI(), guiFrame);
    //    StateSpace stateSpace = new StateSpace(pnmlData);
  }
  private void loadGUI() {
    setTitle("Chroma Key Sample");

    panelBottom = new JPanel();

    ButtonHandler l_buttonHandler = new ButtonHandler();
    buttonCaptureBackground = new JButton("Capture Background");
    buttonStart = new JButton("Start");
    buttonStart.setEnabled(false);
    buttonCaptureBackground.addActionListener(l_buttonHandler);
    buttonStart.addActionListener(l_buttonHandler);

    sliderColorRange = new JSlider(JSlider.HORIZONTAL, 0, 50, 30);
    sliderColorRange.setMinorTickSpacing(1);
    sliderColorRange.setPaintTicks(true);
    sliderColorRange.addChangeListener(new SliderHandler());

    labelColorRange = new JLabel("Color Range");

    panelSlider = new JPanel();
    panelSlider.add(labelColorRange);
    panelSlider.add(sliderColorRange);

    panelBottom.add(buttonCaptureBackground);
    panelBottom.add(buttonStart);

    Container l_container = getContentPane();
    l_container.setLayout(new BorderLayout());
    l_container.add(videoPanel, BorderLayout.NORTH);
    l_container.add(panelSlider, BorderLayout.CENTER);
    l_container.add(panelBottom, BorderLayout.SOUTH);

    setSize(videoInterface.getImageWidth(), videoInterface.getImageHeight() + 100);
    setVisible(true);
  }
Example #8
0
 public static void addComponent(
     Container container,
     Component component,
     int gridx,
     int gridy,
     int gridwidth,
     int gridheight,
     int fill,
     int anchor,
     Insets insets,
     int ipadx,
     int ipady,
     double weightx,
     double weighty) {
   java.awt.LayoutManager lm = container.getLayout();
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbc.gridwidth = gridwidth;
   gbc.gridheight = gridheight;
   gbc.fill = fill;
   gbc.anchor = anchor;
   gbc.insets = insets;
   gbc.ipadx = ipadx;
   gbc.ipady = ipady;
   gbc.weightx = weightx;
   gbc.weighty = weighty;
   ((GridBagLayout) lm).setConstraints(component, gbc);
   container.add(component);
 }
Example #9
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
  }
Example #10
0
  /**
   * Checks the component and all children to ensure that everything is pure Swing. We can only draw
   * lightweights.
   *
   * <p>We'll also set PopupMenus to heavyweight and fix JViewport blitting.
   */
  protected void verifyHierarchy(Component comp) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    if (comp instanceof JComponent) {
      ((JComponent) comp).setDoubleBuffered(false);
    }

    if (!(comp instanceof JComponent)) {
      Logger.getLogger(GLG2DCanvas.class.getName())
          .warning(
              "Drawable component and children should be pure Swing: "
                  + comp
                  + " does not inherit JComponent");
    }

    if (comp instanceof JViewport) {
      ((JViewport) comp).setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
    }

    if (comp instanceof Container) {
      Container cont = (Container) comp;
      for (int i = 0; i < cont.getComponentCount(); i++) {
        verifyHierarchy(cont.getComponent(i));
      }
    }
  }
Example #11
0
    public void layoutContainer(Container parent) {
      Dimension size = parent.getSize();
      Insets insets = parent.getInsets();
      int itop = insets.top;
      int ileft = insets.left;
      int ibottom = insets.bottom;
      int iright = insets.right;

      int rightWidth = right.getPreferredSize().width;
      int bottomHeight = bottom.getPreferredSize().height;
      int centerWidth = size.width - rightWidth - ileft - iright;
      int centerHeight = size.height - bottomHeight - itop - ibottom;

      center.setBounds(ileft, itop, centerWidth, centerHeight);

      right.setBounds(ileft + centerWidth, itop, rightWidth, centerHeight);

      // Lay out all status components, in order
      Enumeration status = leftOfScrollBar.elements();
      while (status.hasMoreElements()) {
        Component comp = (Component) status.nextElement();
        Dimension dim = comp.getPreferredSize();
        comp.setBounds(ileft, itop + centerHeight, dim.width, bottomHeight);
        ileft += dim.width;
      }

      bottom.setBounds(
          ileft, itop + centerHeight, size.width - rightWidth - ileft - iright, bottomHeight);
    }
Example #12
0
 @Override
 public void init(InstrumentPanel window) {
   Container container = window.contentPane();
   container.setLayout(new FlowLayout());
   _watchMeButton = createButton(container, "Watch Me!");
   createWatchMeButtonListener();
 }
  public ScrollingThread() {
    super();
    Container container = getContentPane();

    canvas = new AnimationCanvas();
    container.add(canvas);
  }
Example #14
0
  /**
   * Creates a new AWT <tt>Container</tt> which can display a single <tt>Component</tt> at a time
   * (supposedly, one which represents video) and, in the absence of such a <tt>Component</tt>,
   * displays a predefined default <tt>Component</tt> (in accord with the previous supposition, one
   * which is the default when there is no video). The returned <tt>Container</tt> will track the
   * <tt>Components</tt>s added to and removed from it in order to make sure that
   * <tt>noVideoContainer</tt> is displayed as described.
   *
   * @param noVideoComponent the predefined default <tt>Component</tt> to be displayed in the
   *     returned <tt>Container</tt> when there is no other <tt>Component</tt> in it
   * @return a new <tt>Container</tt> which can display a single <tt>Component</tt> at a time and,
   *     in the absence of such a <tt>Component</tt>, displays <tt>noVideoComponent</tt>
   */
  private VideoContainer createVideoContainer(Component noVideoComponent) {
    Container oldParent = noVideoComponent.getParent();

    if (oldParent != null) oldParent.remove(noVideoComponent);

    return new VideoContainer(noVideoComponent, false);
  }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFInternetSchemaObj schemaObj = swingSchema.getSchema();
   ICFInternetMajorVersionObj obj =
       (ICFInternetMajorVersionObj) schemaObj.getMajorVersionTableObj().newInstance();
   JInternalFrame frame = swingSchema.getMajorVersionFactory().newViewEditJInternalFrame(obj);
   frame.addInternalFrameListener(getViewEditInternalFrameListener());
   ICFInternetMajorVersionEditObj edit = (ICFInternetMajorVersionEditObj) (obj.beginEdit());
   if (edit == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "edit");
   }
   ICFSecurityTenantObj secTenant = schemaObj.getSecTenant();
   edit.setRequiredOwnerTenant(secTenant);
   ICFInternetRealProjectObj container = (ICFInternetRealProjectObj) (getSwingContainer());
   if (container == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "SwingContainer");
   }
   edit.setRequiredContainerParent(container);
   ICFInternetSwingMajorVersionJPanelCommon jpanelCommon =
       (ICFInternetSwingMajorVersionJPanelCommon) frame;
   jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add);
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
  private void initComponents() {
    this.addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent we) {
            System.exit(0);
          }
        });

    java.awt.Container contentPane = this.getContentPane();

    // Setup the empty module panel
    modulePanel.setLayout(new CardLayout());
    contentPane.add(modulePanel);

    // Setup the button panel
    JPanel buttonPanel = new JPanel();

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    buttonPanel.add(cancelButton);

    backButton.addActionListener(this);
    backButton.setEnabled(false);
    buttonPanel.add(backButton);

    nextButton.addActionListener(this);
    nextButton.setEnabled(false);
    buttonPanel.add(nextButton);

    finishButton.addActionListener(this);
    finishButton.setEnabled(false);
    buttonPanel.add(finishButton);

    contentPane.add(buttonPanel, "South");
  }
Example #17
0
  public ASTFrame(String lab, CommonTree t) {
    super(lab);

    JTree tree = new JTree(new ASTtoTreeModelAdapter(t));

    JScrollPane scrollPane = new JScrollPane(tree);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(scrollPane);

    Container content = getContentPane();
    content.add(panel, BorderLayout.CENTER);

    setSize(100, 200);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            Frame f = (Frame) e.getSource();
            f.setVisible(false);
            f.dispose();
            // System.exit(0);
          }
        });
  }
 public void actionPerformed(ActionEvent e) {
   KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
   Container container = kfm.getCurrentFocusCycleRoot();
   FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
   if (null == policy) policy = kfm.getDefaultFocusTraversalPolicy();
   Component next =
       moveDown
           ? policy.getComponentAfter(container, PaletteGroupHeader.this)
           : policy.getComponentBefore(container, PaletteGroupHeader.this);
   if (null != next && next instanceof PaletteComponentList) {
     final PaletteComponentList list = (PaletteComponentList) next;
     if (list.getModel().getSize() != 0) {
       list.takeFocusFrom(PaletteGroupHeader.this, list == myComponentList ? 0 : -1);
       return;
     } else {
       next =
           moveDown
               ? policy.getComponentAfter(container, next)
               : policy.getComponentBefore(container, next);
     }
   }
   if (null != next && next instanceof PaletteGroupHeader) {
     next.requestFocus();
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingISOCurrencyJPanelCommon) {
       ICFSecuritySwingISOCurrencyJPanelCommon jpanelCommon =
           (ICFSecuritySwingISOCurrencyJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown);
       ICFSecurityISOCurrencyEditObj editObj =
           (ICFSecurityISOCurrencyEditObj) jpanelCommon.getSwingFocusAsISOCurrency().getEdit();
       if (editObj != null) {
         editObj.endEdit();
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingISOCurrencyJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
Example #20
0
 @Override
 public Container scrollable() {
   Container contentPanel = viewAdapter.createImageView();
   JScrollPane scrollPane = new JScrollPane();
   contentPanel.add(scrollPane, BorderLayout.CENTER);
   return scrollPane;
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFInternetDomainBaseObj focus = getSwingFocusAsDomainBase();
   if (focus != null) {
     ICFInternetDomainBaseEditObj editObj = (ICFBamDomainBaseEditObj) focus.getEdit();
     if (editObj != null) {
       focus = editObj;
     }
     JInternalFrame frame = null;
     Container cont;
     JDesktopPane desktop;
     ICFBamTenantObj referencedObj =
         (ICFBamTenantObj) focus.getRequiredOwnerTenant(swingIsInitializing);
     if (referencedObj != null) {
       String classCode = referencedObj.getClassCode();
       if ("TENT".equals(classCode)) {
         frame = swingSchema.getTenantFactory().newViewEditJInternalFrame(referencedObj);
         cont = getParent();
         while ((cont != null) && (!(cont instanceof JInternalFrame))) {
           cont = cont.getParent();
         }
         if (cont != null) {
           JInternalFrame myInternalFrame = (JInternalFrame) cont;
           myInternalFrame.getDesktopPane().add(frame);
           frame.setVisible(true);
           frame.show();
         }
       } else {
         throw CFLib.getDefaultExceptionFactory()
             .newUnsupportedClassException(
                 getClass(), S_ProcName, "swingFocus", focus, "ICFBamTenantObj");
       }
     }
   }
 }
Example #22
0
 public void setApplicationPanel(MainPanel mp) {
   if (mainPanel != null) {
     Container parent = mainPanel.getParent();
     if (parent != null) parent.remove(mainPanel);
   }
   mainPanel = mp;
 }
Example #23
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);

  }
  public void initialize(int xSize, int ySize) {
    _root = getContentPane();
    _root.removeAll();

    int height = getHeight();
    // int width = getWidth();

    Insets inset = new Insets(0, 0, 0, 0);
    int bySize = height / (ySize + 1);
    int bxSize = bySize; // getWidth() / xSize;

    int pan_sx = 150; // (width-bxSize*8)/2;

    JPanel toRoot = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JPanel[] Sides = new JPanel[2];
    for (int i = 0; i < Sides.length; i++) {
      Sides[i] = new JPanel(new BorderLayout(0, 0));
      Sides[i].setMinimumSize(new Dimension(pan_sx, 0));
      Sides[i].setPreferredSize(new Dimension(150, 150));
      Sides[0].setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    }

    _buttons = new PositionableButton[xSize][ySize];
    JPanel board = new JPanel(new GridLayout(XSize, YSize, 0, 0));
    for (int i = 0; i < _buttons.length; i++) {
      for (int j = 0; j < _buttons[i].length; j++) {
        _buttons[i][j] = new PositionableButton();
        _buttons[i][j].addActionListener(new ButtonClickedListener());
        _buttons[i][j].setPosition(new Position(j, i));
        _buttons[i][j].setVisible(true);
        _buttons[i][j].setPreferredSize(new Dimension(bxSize, bySize));
        _buttons[i][j].setMargin(inset);
        board.add(_buttons[i][j]);
      }
    }

    if (_thread == null) {
      _thread = new RedrawThread(_buttons);
      _thread.start();
    }

    _slimg = new StateableLabel(StateableLabel.Type.Image);
    _slimg.setPreferredSize(new Dimension(100, 100));
    _slimg.setSize(new Dimension(100, 100));
    _slimg.setMaximumSize(new Dimension(100, 100));
    _slimg.setMinimumSize(new Dimension(100, 100));
    _slnam = new StateableLabel(StateableLabel.Type.Name);
    _sltxt = new StateableLabel();

    Sides[0].add(_slimg, BorderLayout.NORTH);
    Sides[0].add(_slnam, BorderLayout.CENTER);
    Sides[0].add(_sltxt, BorderLayout.SOUTH);

    toRoot.add(Sides[0], BorderLayout.WEST);
    toRoot.add(board, BorderLayout.CENTER);
    toRoot.add(Sides[1], BorderLayout.EAST);

    _root.add(toRoot);
  }
  /**
   * Calculates the preferred size dimensions for the specified panel given the components in the
   * specified parent container.
   *
   * @param target The component to be laid out.
   * @return A size deemed suitable for laying out the container.
   * @see #minimumLayoutSize
   */
  public Dimension preferredLayoutSize(Container target) {
    int count;
    Component component;
    Dimension dimension;
    Insets insets;
    Dimension ret;

    synchronized (target.getTreeLock()) {
      // get the the total height and maximum width component
      ret = new Dimension(0, 0);
      count = target.getComponentCount();
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getPreferredSize();
          ret.width = Math.max(ret.width, dimension.width);
          ret.height += dimension.height;
        }
      }
      insets = target.getInsets();
      ret.width += insets.left + insets.right;
      ret.height += insets.top + insets.bottom;
    }

    return (ret);
  }
  protected void initialize() {
    this.panel = new JPanel();
    this.buttonPanel = new JPanel();
    this.okButton = new JButton(this.okCaption);
    this.cancelButton = new JButton(this.cancelCaption);

    Container c = this.getContentPane();
    c.setLayout(new BorderLayout());
    c.add(this.panel, BorderLayout.CENTER);
    c.add(this.buttonPanel, BorderLayout.SOUTH);

    this.okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            OkCancelDialog.this.okAction(e);
          }
        });

    this.cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            OkCancelDialog.this.cancelAction();
          }
        });
  }
Example #27
0
 public static void addComponent(
     Container container,
     Component component,
     int gridx,
     int gridy,
     int gridwidth,
     int gridheight,
     int fill,
     int anchor)
     throws AWTException {
   LayoutManager lm = container.getLayout();
   if (!(lm instanceof GridBagLayout)) {
     throw new AWTException("Invalid layout" + lm);
   } else {
     GridBagConstraints gbc = new GridBagConstraints();
     gbc.gridx = gridx;
     gbc.gridy = gridy;
     gbc.gridwidth = gridwidth;
     gbc.gridheight = gridheight;
     gbc.fill = fill;
     gbc.anchor = anchor;
     ((GridBagLayout) lm).setConstraints(component, gbc);
     container.add(component);
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingSecGroupFormJPanelCommon) {
       ICFSecuritySwingSecGroupFormJPanelCommon jpanelCommon =
           (ICFSecuritySwingSecGroupFormJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete);
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingSecGroupFormJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
Example #30
0
  public EventDemo3() {
    JFrame f = new JFrame("EventDemo3");
    Container contentPane = f.getContentPane();
    JButton b = new JButton("按我有声音");

    b.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Toolkit.getDefaultToolkit().beep();
          }
        });

    contentPane.add(b);
    f.pack();
    f.setVisible(true);

    f.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }