Search in sources :

Example 16 with Dimension

use of java.awt.Dimension in project screenbird by adamhub.

the class RecorderPanel method showUploadMessage.

/*
     * Upload methods 
     */
/**
     * Displays a message on the upload form, formatted with a text color.
     * @param message
     * @param type 
     */
public void showUploadMessage(String message, Color type) {
    int start = 0;
    int end = 0;
    Component focusedComponent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (focusedComponent instanceof JTextComponent) {
        end = ((JTextComponent) focusedComponent).getSelectionEnd();
        start = ((JTextComponent) focusedComponent).getSelectionStart();
    }
    Dimension size = new Dimension(160, 14);
    this.lblUploadMessage.setPreferredSize(size);
    this.lblUploadMessage.setMinimumSize(size);
    this.lblUploadMessage.setMaximumSize(size);
    this.lblUploadMessage.setSize(size);
    this.pbEncoding.setVisible(true);
    this.pbEncoding.setForeground(type);
    this.lblUploadMessage.validate();
    this.lblUploadMessage.setText(message);
    this.lblUploadMessage.setVisible(true);
    this.lblUploadMessage.setForeground(type);
    ((JFrame) this.getParent().getParent().getParent().getParent()).pack();
    this.redrawWindow();
    if (focusedComponent instanceof JTextComponent) {
        ((JTextComponent) focusedComponent).grabFocus();
        ((JTextComponent) focusedComponent).setSelectionStart(start);
        ((JTextComponent) focusedComponent).setSelectionEnd(end);
    }
}
Also used : JFrame(javax.swing.JFrame) JTextComponent(javax.swing.text.JTextComponent) Dimension(java.awt.Dimension) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Example 17 with Dimension

use of java.awt.Dimension in project screenbird by adamhub.

the class Frame method addFrame.

/** Adds an image to this animation.
     * <P>All images must be the same dimensions; if this image is
     * a different size from previously added images an exception is thrown.
     * <P>Note this method is untested.  But I really think it has
     * a good chance of working.
     * 
     * @param duration the duration (in seconds) this frame should
     * show.  (This value is converted to a timescale of 600.)
     * @param image the JPEG to add.  (An exception is thrown if this is not
     * a valid JPEG file.)
     * @throws IOException
     */
public void addFrame(float duration, File image) throws IOException {
    Dimension d = getJPEGBounds(image);
    if (w == -1 && h == -1) {
        w = d.width;
        h = d.height;
    } else {
        if (w != d.width || h != d.height) {
            throw new IllegalArgumentException("Each frame must have the same dimension.  This frame (" + d.width + "x" + d.height + ") is not the same dimensions as previous frames (" + w + "x" + h + ").");
        }
    }
    frames.add(new Frame(duration, write(out, image)));
}
Also used : Dimension(java.awt.Dimension)

Example 18 with Dimension

use of java.awt.Dimension in project qi4j-sdk by Qi4j.

the class StackedLayout method getItemMinSize.

private Dimension getItemMinSize(NodeItem node, Dimension minSize) {
    if (minSize == null) {
        minSize = new Dimension(0, 0);
    }
    String label = node.getString("name");
    FontMetrics fm = Renderer.DEFAULT_GRAPHICS.getFontMetrics(StackedGraphDisplay.FONT);
    int width = fm.stringWidth(label);
    int height = fm.getHeight();
    minSize.setSize(width + INSET + INSET, height + INSET + INSET);
    //System.out.println(fm.getAscent());
    return minSize;
}
Also used : FontMetrics(java.awt.FontMetrics) Dimension(java.awt.Dimension)

Example 19 with Dimension

use of java.awt.Dimension in project hackpad by dropbox.

the class RunProxy method update.

/**
     * Updates the gutter.
     */
public void update() {
    FileTextArea textArea = fileWindow.textArea;
    Font font = textArea.getFont();
    setFont(font);
    FontMetrics metrics = getFontMetrics(font);
    int h = metrics.getHeight();
    int lineCount = textArea.getLineCount() + 1;
    String dummy = Integer.toString(lineCount);
    if (dummy.length() < 2) {
        dummy = "99";
    }
    Dimension d = new Dimension();
    d.width = metrics.stringWidth(dummy) + 16;
    d.height = lineCount * h + 100;
    setPreferredSize(d);
    setSize(d);
}
Also used : FontMetrics(java.awt.FontMetrics) Dimension(java.awt.Dimension) Font(java.awt.Font) Point(java.awt.Point)

Example 20 with Dimension

use of java.awt.Dimension in project hackpad by dropbox.

the class RunProxy method resetTree.

/**
     * Initializes a tree for this tree table.
     */
public JTree resetTree(TreeTableModel treeTableModel) {
    tree = new TreeTableCellRenderer(treeTableModel);
    // Install a tableModel representing the visible rows in the tree.
    super.setModel(new TreeTableModelAdapter(treeTableModel, tree));
    // Force the JTable and JTree to share their row selection models.
    ListToTreeSelectionModelWrapper selectionWrapper = new ListToTreeSelectionModelWrapper();
    tree.setSelectionModel(selectionWrapper);
    setSelectionModel(selectionWrapper.getListSelectionModel());
    // Make the tree and table row heights the same.
    if (tree.getRowHeight() < 1) {
        // Metal looks better like this.
        setRowHeight(18);
    }
    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
    setShowGrid(true);
    setIntercellSpacing(new Dimension(1, 1));
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    DefaultTreeCellRenderer r = (DefaultTreeCellRenderer) tree.getCellRenderer();
    r.setOpenIcon(null);
    r.setClosedIcon(null);
    r.setLeafIcon(null);
    return tree;
}
Also used : Dimension(java.awt.Dimension) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) TreeTableModelAdapter(org.mozilla.javascript.tools.debugger.treetable.TreeTableModelAdapter)

Aggregations

Dimension (java.awt.Dimension)3966 JPanel (javax.swing.JPanel)1083 JLabel (javax.swing.JLabel)737 Point (java.awt.Point)676 JButton (javax.swing.JButton)667 ActionEvent (java.awt.event.ActionEvent)642 ActionListener (java.awt.event.ActionListener)581 JScrollPane (javax.swing.JScrollPane)554 BorderLayout (java.awt.BorderLayout)490 Insets (java.awt.Insets)403 BoxLayout (javax.swing.BoxLayout)333 GridBagLayout (java.awt.GridBagLayout)308 GridBagConstraints (java.awt.GridBagConstraints)262 FlowLayout (java.awt.FlowLayout)240 JTextField (javax.swing.JTextField)231 ImageIcon (javax.swing.ImageIcon)216 Component (java.awt.Component)214 Color (java.awt.Color)202 ChangeEvent (javax.swing.event.ChangeEvent)200 ChangeListener (javax.swing.event.ChangeListener)198