List of usage examples for javax.swing SwingConstants CENTER
int CENTER
To view the source code for javax.swing SwingConstants CENTER.
Click Source Link
From source file:com.att.aro.main.GraphPanelPlotLabels.java
/** * Initializes a new instance of the GraphPanelPlotLabels class using the * specified label, chart plot object, and weight. * /* ww w . ja v a 2 s . c o m*/ * @param label * The label for the plot on the graph, such as "GPS" , or * "Radio". * * @param plot * The plot object to be displayed in the Diagnostic chart. * * @param weight * An int that is the weight of the plot. */ public GraphPanelPlotLabels(String label, XYPlot plot, int weight) { this.label = new JLabel(label); this.label.setHorizontalAlignment(SwingConstants.CENTER); this.label.setVerticalAlignment(SwingConstants.CENTER); this.plot = plot; this.weight = weight; }
From source file:org.jfree.chart.demo.RightPanel.java
public RightPanel(int x, int y, int width, int height, String baude[], String name[]) { setBackground(new Color(176, 199, 246)); this.width = width; this.height = height; Data[0] = "8"; Data[1] = "9"; Name = name;// w ww . j a va2s . co m Baude = baude; setLayout(new GridLayout(8, 1, 0, 0)); lblName = new JLabel("Name"); lblName.setHorizontalAlignment(SwingConstants.CENTER); lblName.setFont(new Font("Arial", 15, 16)); add(lblName); comboBox = new JComboBox(Name); comboBox.setFont(new Font("Arial", 15, 16)); add(comboBox); JLabel lblBaude = new JLabel("Baude"); lblBaude.setFont(new Font("Arial", 15, 16)); lblBaude.setHorizontalAlignment(SwingConstants.CENTER); add(lblBaude); final JComboBox comboBox_1 = new JComboBox(Baude); comboBox_1.setFont(new Font("Arial", 15, 16)); add(comboBox_1); JLabel lblDataSize = new JLabel("Data size"); lblDataSize.setHorizontalAlignment(SwingConstants.CENTER); lblDataSize.setFont(new Font("Arial", 15, 16)); add(lblDataSize); final JComboBox comboBox_2 = new JComboBox(Data); comboBox_2.setFont(new Font("Arial", 15, 16)); add(comboBox_2); JSeparator separator = new JSeparator(); add(separator); btnOpen = new JButton("Open"); btnOpen.setFont(new Font("Arial", 15, 16)); btnOpen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (btnOpen.getText() == "Open") { btnOpen.setText("Close"); open = true; int baude = 9600, data = 8; try { baude = Integer.parseInt((String) comboBox_1.getSelectedItem()); data = Integer.parseInt((String) comboBox_2.getSelectedItem()); } catch (Exception e) { errors += "Enter correct Bauderate\n"; error_flag = true; } comport = new Comport((String) comboBox.getSelectedItem(), baude, data); comport.start(); } else { comport.flag = false; btnOpen.setText("Open"); open = false; comport.close(); // comport.stop(); System.out.println("Comport = " + comport.isAlive()); System.out.println("Comport life = " + comport.get_life()); } } }); add(btnOpen); setBounds(x + 50, y, width - 40, height - 20); err.setBounds(x + 50, y, 50, 50); //add(err); }
From source file:Main.java
public static Point arrangeWithin(final Shape shapeToArrange, final Rectangle window, final int arrangement, Insets padding) {// w ww .ja v a 2 s . co m if (shapeToArrange == null) throw new IllegalArgumentException("Parameter 'shapeToArrange' must not be null!"); if (window == null) throw new IllegalArgumentException("Parameter 'window' must not be null!"); if (padding == null) padding = new Insets(0, 0, 0, 0); final Rectangle bounds = shapeToArrange.getBounds(); switch (arrangement) { case SwingConstants.NORTH: return new Point((window.width - bounds.width) / 2, padding.top); case SwingConstants.NORTH_EAST: return new Point(window.width - padding.right, padding.top); case SwingConstants.EAST: return new Point(window.width - padding.right, (window.height - bounds.height) / 2); case SwingConstants.SOUTH_EAST: return new Point(window.width - padding.right, window.height - padding.bottom); case SwingConstants.SOUTH: return new Point((window.width - bounds.width) / 2, window.height - padding.bottom); case SwingConstants.SOUTH_WEST: return new Point(padding.left, window.height - padding.bottom); case SwingConstants.WEST: return new Point(padding.left, (window.height - bounds.height) / 2); case SwingConstants.NORTH_WEST: return new Point(padding.left, padding.top); case SwingConstants.CENTER: return new Point((window.width - bounds.width) / 2, (window.height - bounds.height) / 2); default: throw new IllegalArgumentException("Illegal arrangement key, expected one of the SwingConstants keys"); } }
From source file:WelcomeApplet.java
public void init() { EventQueue.invokeLater(new Runnable() {//from www . j a va 2s. co m public void run() { setLayout(new BorderLayout()); JLabel label = new JLabel(getParameter("greeting"), SwingConstants.CENTER); label.setFont(new Font("Serif", Font.BOLD, 18)); add(label, BorderLayout.CENTER); JPanel panel = new JPanel(); JButton cayButton = new JButton("Cay Horstmann"); cayButton.addActionListener(makeAction("http://www.horstmann.com")); panel.add(cayButton); JButton garyButton = new JButton("Gary Cornell"); garyButton.addActionListener(makeAction("mailto:gary_cornell@apress.com")); panel.add(garyButton); add(panel, BorderLayout.SOUTH); } }); }
From source file:brainflow.core.ImageBrowser.java
private void initSourceView() { sourceView = new JList(); final DefaultListModel model = new DefaultListModel(); for (IImageSource source : sourceList.sourceList) { model.addElement(source);/*w w w .ja v a2s . c o m*/ } sourceView.setModel(model); sourceView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ButtonPanel panel = new ButtonPanel(SwingConstants.CENTER); JButton nextButton = new JButton("Next"); ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_play_blue.png")); nextButton.setIcon(icon); JButton prevButton = new JButton("Previous"); icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_rev_blue.png")); prevButton.setIcon(icon); panel.addButton(prevButton); panel.addButton(nextButton); panel.setSizeConstraint(ButtonPanel.SAME_SIZE); JPanel container = new JPanel(new BorderLayout()); container.setBorder(new TitledBorder("Image List")); container.add(new JScrollPane(sourceView), BorderLayout.CENTER); container.add(panel, BorderLayout.SOUTH); add(container, BorderLayout.WEST); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int index = sourceView.getSelectedIndex(); if (index == (sourceList.size() - 1)) { index = 0; } else { index++; } updateView(index); } }); sourceView.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = sourceView.getSelectedIndex(); if (currentModel.getSelectedLayer().getDataSource() != sourceView.getSelectedValue()) { System.out.println("updating view"); updateView(index); } else { System.out.println("not updating view "); } } }); }
From source file:com.pos.spatobiz.app.view.desktop.GambarAbstract.java
/** This method is called from within the constructor to * initialize the form./* w ww. j av a 2s.c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { labelAbstract = new JLabel(); setLayout(new BorderLayout()); labelAbstract.setHorizontalAlignment(SwingConstants.CENTER); labelAbstract.setIcon( new ImageIcon(getClass().getResource("/com/pos/spatobiz/app/resource/image/abstract.png"))); // NOI18N add(labelAbstract, BorderLayout.CENTER); }
From source file:com.aw.core.format.FillerFormat.java
public static String fill(String source, char fillerCharacter, int length, int aligment, boolean fillInclusiveEmptyString) { // if (StringUtils.isEmpty(source) || length<0) { if (length < 0) { return source; }//w w w . j a v a2 s .c om if (source == null) 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(); 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:fr.pasteque.pos.sales.restaurant.Place.java
public Place(JSONObject o) { this.m_sId = o.getString("id"); this.m_sName = o.getString("label"); this.m_ix = o.getInt("x"); this.m_iy = o.getInt("y"); this.m_sfloor = o.getString("floorId"); m_bPeople = false;//from ww w. j av a2 s.co m m_btn = new JButton(); m_btn.setFocusPainted(false); m_btn.setFocusable(false); m_btn.setRequestFocusEnabled(false); m_btn.setHorizontalTextPosition(SwingConstants.CENTER); m_btn.setVerticalTextPosition(SwingConstants.BOTTOM); m_btn.setIcon(ICO_FRE); m_btn.setText(m_sName); }
From source file:pl.piotrsukiennik.jbrain.gui.JBrainMainFrame.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*w w w. j a v a 2s.co m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bottomDescription = new javax.swing.JLabel(); leftColumnMenu = new javax.swing.JTree(); mainPanel = new javax.swing.JPanel(); mainMenuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); newMenuItem = new javax.swing.JMenuItem(); openMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); saveMenuItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("JBrain Manager"); bottomDescription.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); bottomDescription.setText("Piotr Sukiennik @ PJIIT 2014"); javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("options"); javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("model"); treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("simulations"); javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode( "new simulation"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("history"); treeNode2.add(treeNode3); treeNode1.add(treeNode2); leftColumnMenu.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); leftColumnMenu.setRootVisible(false); leftColumnMenu.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { leftColumnMenuValueChanged(evt); } }); mainPanel.setBackground(new java.awt.Color(255, 255, 255)); mainPanel.setLayout(new java.awt.CardLayout()); fileMenu.setText("File"); newMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); newMenuItem.setIcon(new javax.swing.ImageIcon( getClass().getResource("/pl/piotrsukiennik/jbrain/gui/icons/file-2x.png"))); // NOI18N newMenuItem.setText("New"); newMenuItem.setEnabled(false); newMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newMenuItemActionPerformed(evt); } }); fileMenu.add(newMenuItem); openMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); openMenuItem.setIcon(new javax.swing.ImageIcon( getClass().getResource("/pl/piotrsukiennik/jbrain/gui/icons/folder-2x.png"))); // NOI18N openMenuItem.setText("Open"); openMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openMenuItemActionPerformed(evt); } }); fileMenu.add(openMenuItem); fileMenu.add(jSeparator1); saveMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); saveMenuItem.setIcon(new javax.swing.ImageIcon( getClass().getResource("/pl/piotrsukiennik/jbrain/gui/icons/data-transfer-download-2x.png"))); // NOI18N saveMenuItem.setText("Save"); saveMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); fileMenu.add(saveMenuItem); mainMenuBar.add(fileMenu); setJMenuBar(mainMenuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(leftColumnMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) .addComponent(bottomDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(leftColumnMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE) .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bottomDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))); pack(); }
From source file:forge.gui.CardDetailPanel.java
public CardDetailPanel() { super();/*w w w .j a v a 2 s . c o m*/ setLayout(null); setOpaque(false); nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build(); powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); setInfoLabel = new JLabel(); setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER); final Font font = new Font("Dialog", 0, 14); nameCostLabel.setFont(font); typeLabel.setFont(font); idLabel.setFont(font); powerToughnessLabel.setFont(font); cdArea = new FHtmlViewer(); cdArea.setBorder(new EmptyBorder(2, 6, 2, 6)); cdArea.setOpaque(false); scrArea = new FScrollPane(cdArea, false); add(nameCostLabel); add(typeLabel); add(idLabel); add(powerToughnessLabel); add(setInfoLabel); add(scrArea); }