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);
}
}
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)));
}
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;
}
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);
}
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;
}
Aggregations