List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:Main.java
public GridBagLayoutPanel() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); setLayout(gridbag);/*from ww w .j a v a2 s. com*/ constraints.weightx = constraints.weighty = 10.0; constraints.fill = constraints.NONE; constraints.ipadx = 30; constraints.ipady = 10; addButton("Press", constraints, gridbag); constraints.weightx = 5.0; constraints.fill = constraints.BOTH; constraints.ipadx = constraints.ipady = 0; constraints.insets = new Insets(10, 30, 10, 20); constraints.gridwidth = constraints.RELATIVE; constraints.gridheight = 2; addButton("GO", constraints, gridbag); constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx = 0; constraints.fill = constraints.NONE; constraints.ipadx = 30; constraints.ipady = 10; constraints.gridwidth = 1; constraints.gridheight = 1; addButton("Push", constraints, gridbag); }
From source file:Main.java
private void shakeButton() { final Point point = button.getLocation(); final Insets margin = button.getMargin(); final int delay = 75; Runnable r = new Runnable() { @Override// ww w .ja va 2s. co m public void run() { for (int i = 0; i < 30; i++) { try { setButtonMargin(new Insets(margin.top, margin.left + 3, margin.bottom, margin.right - 2)); Thread.sleep(delay); setButtonMargin(margin); Thread.sleep(delay); setButtonMargin(new Insets(margin.top, margin.left - 2, margin.bottom, margin.right + 3)); Thread.sleep(delay); setButtonMargin(margin); Thread.sleep(delay); } catch (InterruptedException ex) { ex.printStackTrace(); } } } }; Thread t = new Thread(r); t.start(); }
From source file:Main.java
/** * Gets the insets of the screen./* w ww .j a va2s . c o m*/ * <p> * <b>Attention: </b>Due to <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6899304">Java bug 6899304</a> * this method only returns correct insets values for the primary screen device. For other screen devices empty insets * will be returned. In Windows environments these circumstances (task bar on a none primary screen) will be very rare * and therefore ignored until the bug will be fixed in a future Java version. * </p> * * @param screenDevice * a screen thats {@link GraphicsConfiguration} will be used to determine the insets * @return the insets of this toolkit's screen, in pixels, if the given screen device is the primary screen, otherwise * empty insets * @see Toolkit#getScreenInsets(GraphicsConfiguration) */ public static Insets getScreenInsets(GraphicsDevice screenDevice) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); // <bko 2012-02-29> // "Fix" for Sun bug 6899304 ("java.awt.Toolkit.getScreenInsets(GraphicsConfiguration) returns incorrect values") // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6699851 if (screenDevice == ge.getDefaultScreenDevice()) { // only return Toolkit.getScreenInsets for primary screen device return Toolkit.getDefaultToolkit().getScreenInsets(screenDevice.getDefaultConfiguration()); } else { // return empty insets for other screen devices return new Insets(0, 0, 0, 0); } // </bko> }
From source file:ToolBarButton.java
private void initButton() { setRolloverEnabled(true);// ww w.j av a2s. c o m setRequestFocusEnabled(false); setMargin(new Insets(1, 1, 1, 1)); putClientProperty("JToolBar.isRollover", Boolean.TRUE); }
From source file:Main.java
ThreeDimensionalBorder(Color color, int transparency, int shadowWidth) { this.color = color; shadowPad = shadowWidth;//from w w w .j a v a 2 s . c om stroke = new BasicStroke(thickness); strokePad = thickness / 2; hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int pad = radius + strokePad; int bottomPad = pad + strokePad + shadowPad; int rightPad = pad + strokePad + shadowPad; insets = new Insets(pad, pad, bottomPad + shadowPad, rightPad); }
From source file:Main.java
protected void addFields(GridBagConstraints gbc) { JTextField field1 = new JTextField("0", 5); field1.setEnabled(false);/* w w w . j a v a 2 s . c o m*/ gbc.anchor = GridBagConstraints.CENTER; gbc.gridx++; add(field1, gbc); gbc.gridx++; gbc.insets = new Insets(0, 4, 0, 4); add(new JLabel("+"), gbc); JTextField field2 = new JTextField(5); gbc.gridx++; add(field2, gbc); }
From source file:ImageTest.java
public ImageButton(ImageIcon icon) { setIcon(icon);// ww w . j a v a 2 s . co m setMargin(new Insets(0, 0, 0, 0)); setIconTextGap(0); setBorderPainted(false); setBorder(null); setText(null); setSize(icon.getImage().getWidth(null), icon.getImage().getHeight(null)); }
From source file:dataform.components.WorkTimer.java
private void init() throws Exception { stopWatch = new StopWatch(); setEditable(false);//from w w w . java 2s . c o m setForeground(Color.RED); setHorizontalAlignment(JLabel.RIGHT); setMargin(new Insets(2, 2, 2, 4)); timer = new javax.swing.Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { timer_ActionPerformed(evt); } }); stopWatch.start(); timer.start(); }
From source file:Main.java
public static void addComponent(Container container, GridBagLayout gbl, Component c, int x, int y, int width, int height, double weightx, double weighty, int anchor, int ipadx, int ipady, int fill) { GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = fill;//from w ww . j a v a 2s .co m gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = width; gbc.gridheight = height; gbc.weightx = weightx; gbc.weighty = weighty; gbc.anchor = anchor; gbc.ipadx = ipadx; gbc.ipady = ipady; gbc.insets = new Insets(2, 2, 2, 2); gbl.setConstraints(c, gbc); container.add(c); }
From source file:FileChooserDemo2.java
public FileChooserDemo2() { super(new BorderLayout()); // Create the log first, because the action listener // needs to refer to it. log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false);/*from w w w .jav a 2 s .co m*/ JScrollPane logScrollPane = new JScrollPane(log); JButton sendButton = new JButton("Attach..."); sendButton.addActionListener(this); add(sendButton, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }