コード例 #1
0
 /**
  * Adds the specified component to the container.
  *
  * @param c The component to add.
  */
 private void addComponent(JComponent c) {
   Container container = window.getContentPane();
   Component[] comps = container.getComponents();
   boolean in = false;
   for (int i = 0; i < comps.length; i++) {
     if (comps[i].equals(c)) {
       in = true;
       break;
     }
   }
   if (!in) {
     container.add(c, BorderLayout.CENTER);
     window.repaint();
   }
 }
コード例 #2
0
 /** Creates and sets the window and its content's borders. */
 void makeBorders(int increment) {
   JRootPane rootPane = window.getRootPane();
   rootPane.setBorder(BorderFactory.createLineBorder(BORDER_COLOR, BORDER_THICKNESS + increment));
   if (canvas != null) {
     canvas.setBorder(
         BorderFactory.createBevelBorder(
             BevelBorder.LOWERED, INNER_BORDER_HIGHLIGHT, INNER_BORDER_SHADOW));
   }
 }
コード例 #3
0
 /**
  * Sets the image to paint if the canvas is an instance of <code>ThumbnailCanvas</code>.
  *
  * @param image The image to paint.
  */
 void setImage(BufferedImage image) {
   if (canvas instanceof ThumbnailCanvas) {
     makeComponentsSize(image.getWidth(), image.getHeight());
     ((ThumbnailCanvas) canvas).setImage(image);
     // window.getContentPane().removeAll();
     // buildUI();
     window.pack();
   }
 }
コード例 #4
0
 /** Repaints the window according to whether the window is currently collapsed or expanded. */
 void updateCollapsedState() {
   SizeButton button = (SizeButton) titleBar.getButton(TitleBar.SIZE_BUTTON);
   if (window.isCollapsed()) {
     removeComponent(canvas);
     Dimension d = new Dimension(window.getWidth(), TitleBar.HEIGHT + 2 * BORDER_THICKNESS);
     titleBar.setPreferredSize(d);
     button.setActionType(SizeButton.EXPAND);
     window.setSize(d.width, d.height);
   } else {
     addComponent(canvas);
     button.setActionType(SizeButton.COLLAPSE);
     Dimension dT = titleBar.getPreferredSize();
     Dimension dW = window.getRestoreSize();
     window.setSize(dT.width, dW.height);
   }
   window.validate();
   window.repaint();
 }
コード例 #5
0
 /**
  * Sets the node's decoration.
  *
  * @param l The collection of <code>component</code>s to add to the <code>TitleBar</code>.
  */
 void setDecoration(List l) {
   if (titleBar == null) return;
   titleBar.setDecoration(l, window.getButtonIndex());
 }
コード例 #6
0
 /** Hides and disposes depending on the state of the window. */
 void updateClosedState() {
   if (window.isClosed()) {
     window.setVisible(false);
     window.dispose();
   }
 }
コード例 #7
0
 /** Updates and repaints the title bar. */
 void updateTitleBar() {
   titleBar.update(window.getTitle());
 }
コード例 #8
0
 /**
  * Sets the window and initializes the title bar.
  *
  * @param window The window to set.
  */
 private void initialize(TinyDialog window) {
   if (window == null) throw new NullPointerException("No window.");
   this.window = window;
   titleBar = new TitleBar(window.getTitle(), window.getButtonIndex());
 }
コード例 #9
0
 /**
  * Removes the specified component from the container.
  *
  * @param c The component to remove.
  */
 private void removeComponent(JComponent c) {
   window.getContentPane().remove(c);
 }
コード例 #10
0
 /** Builds and lays out the UI. */
 private void buildUI() {
   Container container = window.getContentPane();
   container.add(titleBar, BorderLayout.NORTH);
   if (canvas != null) container.add(canvas, BorderLayout.CENTER);
 }