List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:com.tdclighthouse.prototype.servlets.JLatexServlet.java
private synchronized BufferedImage generateImage(String latex) { TeXFormula formula = new TeXFormula(latex); TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20); icon.setInsets(new Insets(5, 5, 5, 5)); BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); g2.setColor(Color.white);/*from w w w. j ava2 s .co m*/ g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); JLabel jl = new JLabel(); jl.setForeground(new Color(0, 0, 0)); icon.paintIcon(jl, g2, 0, 0); return image; }
From source file:fr.duminy.jbackup.swing.ProgressPanel.java
public void setTask(final Future<?> task) { this.task = task; if ((task != null) && (cancelButton == null)) { Utils.runInEventDispatchThread(new Runnable() { @Override// w w w . j ava 2s. c o m public void run() { ImageIcon icon = new ImageIcon(ProgressPanel.class.getResource("cancel.png")); cancelButton = new JButton(icon); cancelButton.setMargin(new Insets(0, 0, 0, 0)); cancelButton.setToolTipText(Bundle.getBundle(Messages.class).cancelTaskTooltip()); add(cancelButton, BorderLayout.EAST); revalidate(); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (task.cancel(false)) { removeFromParent(); } } }); } }); } }
From source file:components.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 . j a v a2s.c o m*/ JScrollPane logScrollPane = new JScrollPane(log); JButton sendButton = new JButton("Attach..."); sendButton.addActionListener(this); add(sendButton, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
From source file:layout.GridBagLayoutDemo.java
public static void addComponentsToPane(Container pane) { if (RIGHT_TO_LEFT) { pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }/*from w ww.ja v a 2s . c o m*/ JButton button; pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); if (shouldFill) { //natural height, maximum width c.fill = GridBagConstraints.HORIZONTAL; } button = new JButton("Button 1"); if (shouldWeightX) { c.weightx = 0.5; } c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; pane.add(button, c); button = new JButton("Button 2"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 0; pane.add(button, c); button = new JButton("Button 3"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 2; c.gridy = 0; pane.add(button, c); button = new JButton("Long-Named Button 4"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 40; //make this component tall c.weightx = 0.0; c.gridwidth = 3; c.gridx = 0; c.gridy = 1; pane.add(button, c); button = new JButton("5"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 0; //reset to default c.weighty = 1.0; //request any extra vertical space c.anchor = GridBagConstraints.PAGE_END; //bottom of space c.insets = new Insets(10, 0, 0, 0); //top padding c.gridx = 1; //aligned with button 2 c.gridwidth = 2; //2 columns wide c.gridy = 2; //third row pane.add(button, c); }
From source file:com.digitalgeneralists.assurance.ui.components.AboutPanel.java
protected void initializeComponent() { if (!this.initialized) { GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag);//from w w w. j a v a 2 s. c o m GridBagConstraints applicationIconConstraints = new GridBagConstraints(); applicationIconConstraints.anchor = 11; applicationIconConstraints.fill = 1; applicationIconConstraints.gridx = 0; applicationIconConstraints.gridy = 0; applicationIconConstraints.weightx = 1.0D; applicationIconConstraints.weighty = 0.8D; applicationIconConstraints.gridheight = 1; applicationIconConstraints.gridwidth = 1; applicationIconConstraints.insets = new Insets(5, 5, 5, 5); try { Image iconImage = ImageIO.read(getClass().getClassLoader().getResource("assurance.png")); iconImage = iconImage.getScaledInstance(48, 48, 0); JLabel applicationIcon = new JLabel(new ImageIcon(iconImage)); add(applicationIcon, applicationIconConstraints); } catch (IOException e) { this.logger.warn(e); } GridBagConstraints applicationNameLabelConstraints = new GridBagConstraints(); applicationNameLabelConstraints.anchor = 11; applicationNameLabelConstraints.fill = 1; applicationNameLabelConstraints.gridx = 0; applicationNameLabelConstraints.gridy = 1; applicationNameLabelConstraints.weightx = 1.0D; applicationNameLabelConstraints.weighty = 0.1D; applicationNameLabelConstraints.gridheight = 1; applicationNameLabelConstraints.gridwidth = 1; applicationNameLabelConstraints.insets = new Insets(5, 5, 5, 5); JLabel applicationNameLabel = new JLabel(Application.applicationName, 0); add(applicationNameLabel, applicationNameLabelConstraints); GridBagConstraints applicationVersionLabelConstraints = new GridBagConstraints(); applicationVersionLabelConstraints.anchor = 11; applicationVersionLabelConstraints.fill = 1; applicationVersionLabelConstraints.gridx = 0; applicationVersionLabelConstraints.gridy = 2; applicationVersionLabelConstraints.weightx = 1.0D; applicationVersionLabelConstraints.weighty = 0.1D; applicationVersionLabelConstraints.gridheight = 1; applicationVersionLabelConstraints.gridwidth = 1; applicationVersionLabelConstraints.insets = new Insets(5, 5, 5, 5); StringBuilder labelText = new StringBuilder(128); JLabel applicationVersionLabel = new JLabel(labelText.append(Application.applicationVersion) .append(" (").append(Application.applicationBuildNumber).append(")").toString(), 0); labelText.setLength(0); add(applicationVersionLabel, applicationVersionLabelConstraints); this.initialized = true; } }
From source file:rhinova.gui.dataentry.link.LinkDataEditPannel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license label1 = new JLabel(); label2 = new JLabel(); lblId = new JLabel(); label3 = new JLabel(); txtName = new JTextField(); label8 = new JLabel(); txtCapacity = new JTextField(); label4 = new JLabel(); txtSurvivalRate = new JTextField(); label5 = new JLabel(); comboReserve1 = new JComboBox<>(); label6 = new JLabel(); comboReserve2 = new JComboBox<>(); //======== this ======== setLayout(new GridBagLayout()); ((GridBagLayout) getLayout()).columnWidths = new int[] { 54, 0, 0 }; ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; //---- label1 ---- label1.setText("Link Properties"); label1.setFont(new Font("Tahoma", Font.PLAIN, 16)); add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label2 ---- label2.setText("id"); add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(lblId, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label3 ---- label3.setText("name"); add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtName, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label8 ---- label8.setText("capacity"); add(label8, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtCapacity, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label4 ---- label4.setText("survival rate"); add(label4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtSurvivalRate, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label5 ---- label5.setText("reserve 1"); add(label5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(comboReserve1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label6 ---- label6.setText("reserve 2"); add(label6, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 15), 0, 0)); add(comboReserve2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:TwoStopsGradient.java
/** Creates a new instance of TwoStopsGradient */ public TwoStopsGradient() { super("Two Stops Gradient"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridBagLayout()); JButton button;/*from ww w .j av a 2s .c o m*/ panel.add(button = new DepthButton("New"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false); panel.add(button = new DepthButton("Open"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false); panel.add(button = new DepthButton("Save"), new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false); add(panel); setSize(320, 240); }
From source file:net.sf.texprinter.utils.UIUtils.java
/** * Formats a JButton as a JLabel. In some cases, I just want the a * JButton component to act as a JLabel, so this method does this * for me./*from w w w .j a v a2s . co m*/ * * @param button The button. Some makeup is made to the button, so * it will look as a good old JLabel component. */ public static void formatButtonAsLabel(JButton button) { // disable focus paint button.setFocusPainted(false); // redefine margins button.setMargin(new Insets(0, 0, 0, 0)); // disable content area fill button.setContentAreaFilled(false); // disable border paint button.setBorderPainted(false); // disable property button.setOpaque(false); }
From source file:com.haulmont.cuba.desktop.sys.vcl.CollapsiblePanel.java
public CollapsiblePanel(JComponent composition) { this.composition = composition; titleBtn = new JButton(); titleBtn.setBorder(BorderFactory.createEmptyBorder(0, 3, 5, 3)); titleBtn.setVerticalTextPosition(AbstractButton.CENTER); titleBtn.setHorizontalTextPosition(AbstractButton.RIGHT); titleBtn.setMargin(new Insets(0, 0, 3, 0)); titleBtn.setFont(getTitleFont());/*w ww . ja v a 2 s .c o m*/ titleBtn.setFocusable(false); titleBtn.setContentAreaFilled(false); titleBtn.setVisible(false); titleBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isCollapsable()) setExpanded(!isExpanded()); } }); // Add icons loadIcons(); refreshTitleIcon(); setLayout(new BorderLayout()); add(titleBtn, BorderLayout.CENTER); add(composition, BorderLayout.CENTER); setBorder(createBorderImplementation()); preferredSize = getPreferredSize(); placeTitleComponent(); }
From source file:flow.visibility.tapping.OpenDayLightUtils.java
/** Creating the Pane for Flow Entry */ public OpenDayLightUtils() { super("Installed Flow"); FlowtextArea = new JTextArea(50, 10); FlowtextArea.setEditable(false);//from ww w . j ava 2 s . co m FlowtextArea.setFont(new Font("Courier New", Font.BOLD, 12)); PrintStream FlowprintStream = new PrintStream(new CustomOutputStream(FlowtextArea)); // re-assigns standard output stream and error output stream System.setOut(FlowprintStream); System.setErr(FlowprintStream); // creates the GUI setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(10, 10, 10, 10); constraints.anchor = GridBagConstraints.WEST; constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 2; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.weighty = 1.0; /** Adding the Pane into Frame */ scrollPane = new JScrollPane(FlowtextArea); this.add(scrollPane, constraints); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(400, 600); setLocationRelativeTo(null); // centers on screen }