List of usage examples for javax.swing SwingConstants LEFT
int LEFT
To view the source code for javax.swing SwingConstants LEFT.
Click Source Link
From source file:CelsiusConverter.java
private void addWidgets() { // Create widgets. tempCelsius = new JTextField(2); celsiusLabel = new JLabel("Celsius", SwingConstants.LEFT); convertTemp = new JButton("Convert..."); fahrenheitLabel = new JLabel("Fahrenheit", SwingConstants.LEFT); // Listen to events from Convert button. convertTemp.addActionListener(this); // Add widgets to container. converterPanel.add(tempCelsius);/*from ww w . j a v a 2s . c o m*/ converterPanel.add(celsiusLabel); converterPanel.add(convertTemp); converterPanel.add(fahrenheitLabel); celsiusLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); fahrenheitLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:CelsiusConverter2.java
private void addWidgets() { // Create widgets. ImageIcon icon = new ImageIcon("images/convert.gif", "Convert temperature"); tempCelsius = new JTextField(2); celsiusLabel = new JLabel("Celsius", SwingConstants.LEFT); convertTemp = new JButton(icon); fahrenheitLabel = new JLabel("Fahrenheit", SwingConstants.LEFT); celsiusLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); fahrenheitLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // Listen to events from Convert button. convertTemp.addActionListener(this); // Add widgets to container. converterPanel.add(tempCelsius);// w w w .j a va 2 s .c om converterPanel.add(celsiusLabel); converterPanel.add(convertTemp); converterPanel.add(fahrenheitLabel); }
From source file:com.ibm.watson.WatsonVRTraining.util.images.PhotoCaptureFrame.java
PhotoCaptureFrame() { jp = new JPanel(); jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); JScrollPane scrollPane = new JScrollPane(jp); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); scrollPane.setPreferredSize(new Dimension(dim.width / 2 - 40, dim.height - 117)); JButton btn = new JButton("Upload Image"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(System.getenv("user.home")); fc.setFileFilter(new JPEGImageFileFilter()); int res = fc.showOpenDialog(null); // We have an image! try { if (res == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //SharedResources.sharedCache.getCapturedImageList().add(file); File tmpf_name = File.createTempFile("tmp", "." + FilenameUtils.getExtension(file.getName())); System.out.println("cp " + file.getPath() + " " + AppConstants.vr_process_img_dir_path + File.separator + tmpf_name.getName()); new CommandsUtils().executeCommand("bash", "-c", "cp " + file.getPath() + " " + AppConstants.vr_process_img_dir_path + File.separator + tmpf_name.getName()); }//from w ww . j av a 2s . c o m } catch (Exception iOException) { } } }); ImageRemainingProcessingLabel = new JLabel("REMAINIG IMAGES:0"); ImageRemainingProcessingLabel.setHorizontalAlignment(SwingConstants.LEFT); ImageRemainingProcessingLabel.setFont(new Font("Arial", Font.BOLD, 13)); ImagebeingProcessedLabel = new JLabel(" PROCESSING IMAGES:0"); ImagebeingProcessedLabel.setHorizontalAlignment(SwingConstants.LEFT); ImagebeingProcessedLabel.setFont(new Font("Arial", Font.BOLD, 13)); appIDLabel = new JLabel("APP-ID:" + AppConstants.unique_app_id); appIDLabel.setHorizontalAlignment(SwingConstants.LEFT); appIDLabel.setFont(new Font("Arial", Font.BOLD, 13)); headerPanel = new JPanel(new FlowLayout()); headerPanel.add(ImageRemainingProcessingLabel); headerPanel.add(ImagebeingProcessedLabel); headerPanel.add(btn); headerPanel.add(appIDLabel); headerPanel.setSize(new Dimension(getWidth(), 10)); JPanel contentPane = new JPanel(); contentPane.add(headerPanel); contentPane.add(scrollPane); f = new JFrame("IBM Watson Visual Prediction Window"); f.setContentPane(contentPane); f.setSize(dim.width / 2 - 30, dim.height - 40); f.setLocation(dim.width / 2, 0); f.setResizable(false); f.setPreferredSize(new Dimension(dim.width / 2 - 30, dim.height - 60)); f.setVisible(true); }
From source file:com.googlecode.vfsjfilechooser2.accessories.DefaultAccessoriesPanel.java
private void initComponents() { buttonsPanel = new JPanel(); buttonsPanel.setLayout(new GridLayout(0, 1, 3, 3)); Action action;// w ww. j a v a 2s . c o m action = new ManageBookmarksAction(VFSResources.getMessage("VFSJFileChooser.bookmarksLabelText"), getIcon("book.png")); bookmarksButton = new JButton(action); bookmarksButton.setHorizontalAlignment(SwingConstants.LEFT); action = new ConnectionWizardAction(VFSResources.getMessage("VFSJFileChooser.connectionButtonText"), getIcon("connect.png")); connectionsButton = new JButton(action); connectionsButton.setHorizontalAlignment(SwingConstants.LEFT); action = new LocalFilesAction(VFSResources.getMessage("VFSJFileChooser.localFilesButtonText"), getIcon("drive.png")); localFSButton = new JButton(action); localFSButton.setHorizontalAlignment(SwingConstants.LEFT); buttonsPanel.add(bookmarksButton); buttonsPanel.add(Box.createVerticalStrut(20)); buttonsPanel.add(connectionsButton); buttonsPanel.add(Box.createVerticalStrut(20)); buttonsPanel.add(localFSButton); add(buttonsPanel, BorderLayout.NORTH); add(new JPanel(), BorderLayout.CENTER); final Frame c = (Frame) SwingUtilities.getWindowAncestor(fileChooser); bookmarksDialog = new BookmarksDialog(c, fileChooser); connectionDialog = new ConnectionDialog(c, bookmarksDialog, fileChooser); }
From source file:com.aw.core.format.FillerFormat.java
public static String fillFormat(String source, char fillerCharacter, int length, int aligment, boolean fillInclusiveEmptyString) { if (StringUtils.isEmpty(source)) return source; if (source.length() > length) return source.substring(0, length); //throw new AWBusinessException("No se puede llenar '"+source+"' pues tamao excede "+length); source = source.trim();/*from ww w. j a va 2 s . c o m*/ if (source.length() == length) return source; if (!fillInclusiveEmptyString && source.length() == 0) return source; if (source.length() > length) return source.substring(0, length); StringBuffer buf = new StringBuffer(length); if (aligment == SwingConstants.CENTER) { int left = (length - source.length()) / 2; int right = length - (source.length() + left); fill(buf, fillerCharacter, left); buf.append(source); fill(buf, fillerCharacter, right); } else { if (aligment == SwingConstants.LEFT) buf.append(source); fill(buf, fillerCharacter, length - source.length()); if (aligment == SwingConstants.RIGHT) buf.append(source); } return buf.toString(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.ResourceStatusComponent.java
@Override protected JPanel createPanel() { final JPanel result = new JPanel(); table.setFillsViewportHeight(true);//from www. j a va 2 s .co m table.setRowSorter(model.getRowSorter()); FixedBooleanTableCellRenderer.attach(table); table.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (!(value instanceof Integer)) { return this; } if (column == 0) { setHorizontalAlignment(SwingConstants.LEFT); } else { setHorizontalAlignment(SwingConstants.RIGHT); } Integer amount = (Integer) value; if (amount.intValue() < 0) { if (!isSelected) { setBackground(Color.RED); } else { setBackground(table.getSelectionBackground()); } } else { setBackground(table.getBackground()); } return this; } }); addToShoppingListButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final List<ItemWithQuantity> items = model.getSelectedItems(); if (items.isEmpty()) { return; } final ShoppingListEditorComponent comp = new ShoppingListEditorComponent(title, "", items); comp.setModal(true); ComponentWrapper.wrapComponent(comp).setVisible(true); if (!comp.wasCancelled() && !comp.getShoppingList().isEmpty()) { shoppingListManager.addShoppingList(comp.getShoppingList()); getComponentCallback().dispose(ResourceStatusComponent.this); } } }); new GridLayoutBuilder() .add(new GridLayoutBuilder.VerticalGroup(new GridLayoutBuilder.Cell(new JScrollPane(table)), new GridLayoutBuilder.FixedCell(addToShoppingListButton))) .addTo(result); return result; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRInputController.java
@Override protected void initDRInputPanel() { dRInputPanel = new DRInputPanel(); conditionsList = new ArrayList<>(); // control opaque property of bottom table dRInputPanel.getSlopesTableScrollPane().getViewport().setBackground(Color.white); slopesTable = dRInputPanel.getSlopesTable(); slopesTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); slopesTable.getTableHeader().setReorderingAllowed(false); slopesTable.setFillsViewportHeight(true); slopesTable.setModel(new NonEditableTableModel()); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup experimentTypeRadioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected experimentTypeRadioButtonGroup.add(dRInputPanel.getStimulationRadioButton()); experimentTypeRadioButtonGroup.add(dRInputPanel.getInhibitionRadioButton()); //select as default first button (Stimulation) dRInputPanel.getStimulationRadioButton().setSelected(true); /*// ww w . j av a 2 s.c o m * Action listeners for buttons */ dRInputPanel.getAddConditionButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add selected condition to analysis addToDRAnalysis(); } }); dRInputPanel.getRemoveConditionButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // remove condition from analysis removeFromDRAnalysis(); } }); /** * Choosing stimulation or inhibition type experiment defines standard * hillslope parameter */ dRInputPanel.getStimulationRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doseResponseController.setStandardHillslope(1); } }); dRInputPanel.getInhibitionRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doseResponseController.setStandardHillslope(-1); } }); }
From source file:com.aw.core.format.FillerFormat.java
public static String fillSpaces(int length) { return fill("", ' ', length, SwingConstants.LEFT); }
From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java
@Override public JComponent createContentPanel() { // TODO use here nicer layout, maybe with an icon JPanel panel = new JPanel(new BorderLayout(10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(20, 40, 40, 40)); JLabel label = new JLabel("<html>An error occured!<br/>" + exception.toString() + "</html>"); label.setHorizontalAlignment(SwingConstants.LEFT); panel.add(label, BorderLayout.CENTER); panel.add(new JLabel(Icons.IC_DIALOG_ERROR_LARGE), BorderLayout.WEST); setSize(panel.getPreferredSize());/* www . jav a 2 s . co m*/ return panel; }
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
/** * @param p/*from ww w . j a v a 2 s .c om*/ * @param f * @param font * @param y * @param all */ public void build(final PanelBuilder p, final DBFieldInfo f, final Font font, final int y, boolean all) { String typ = StringUtils.substringAfterLast(f.getType(), "."); if (StringUtils.isEmpty(typ)) { typ = f.getType(); } String lenStr = f.getLength() > 0 && f.getLength() < 65000 ? Integer.toString(f.getLength()) : ""; CellConstraints cc = new CellConstraints(); p.add(ERDVisualizer.mkLabel(font, f.getTitle(), SwingConstants.LEFT), cc.xy(1, y)); p.add(ERDVisualizer.mkLabel(font, typ, SwingConstants.CENTER), cc.xy(3, y)); p.add(ERDVisualizer.mkLabel(font, lenStr, SwingConstants.CENTER), cc.xy(5, y)); if (all) { p.add(ERDVisualizer.mkLabel(font, f.isRequired() ? yesStr : "", SwingConstants.CENTER), cc.xy(7, y)); p.add(ERDVisualizer.mkLabel(font, f.isRequired() ? yesStr : "", SwingConstants.CENTER), cc.xy(9, y)); } }