List of usage examples for java.awt Component CENTER_ALIGNMENT
float CENTER_ALIGNMENT
To view the source code for java.awt Component CENTER_ALIGNMENT.
Click Source Link
From source file:BoxSample.java
private static void changeBoth(JComponent comp) { comp.setAlignmentX(Component.CENTER_ALIGNMENT); comp.setAlignmentY(Component.CENTER_ALIGNMENT); Dimension dim = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); comp.setMaximumSize(dim);/*from w ww . j a v a 2 s. c o m*/ }
From source file:org.openpnp.gui.AboutDialog.java
public AboutDialog(Frame frame) { super(frame, true); setTitle("About OpenPnP"); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setBounds(100, 100, 347, 360);/*w ww. j a v a 2 s .c o m*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); JLabel lblOpenpnp = new JLabel("OpenPnP"); lblOpenpnp.setAlignmentX(Component.CENTER_ALIGNMENT); lblOpenpnp.setFont(new Font("Lucida Grande", Font.BOLD, 32)); contentPanel.add(lblOpenpnp); JLabel lblCopyright = new JLabel("Copyright 2011 - 2016 Jason von Nieda"); lblCopyright.setFont(new Font("Lucida Grande", Font.PLAIN, 10)); lblCopyright.setAlignmentX(Component.CENTER_ALIGNMENT); contentPanel.add(lblCopyright); JLabel lblVersion = new JLabel("Version: " + Main.getVersion()); lblVersion.setFont(new Font("Lucida Grande", Font.PLAIN, 10)); lblVersion.setAlignmentX(Component.CENTER_ALIGNMENT); contentPanel.add(lblVersion); textPane = new JTextPane(); textPane.setEditable(false); contentPanel.add(new JScrollPane(textPane)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); try { String s = FileUtils.readFileToString(new File("CHANGES.md")); textPane.setText(s); textPane.setCaretPosition(0); } catch (Exception e) { } }
From source file:gda.util.userOptions.UserOptionsDialog.java
/** * @param frame/*from www . j a v a 2s . co m*/ * @param parent * @param options */ public UserOptionsDialog(JFrame frame, Component parent, UserOptions options) { super(frame, options.title, true); this.frame = frame; this.options = options; JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); label = new JLabel(options.title != null ? options.title : ""); label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); label.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel pane = makePane(); // pane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); pane.setAlignmentX(Component.CENTER_ALIGNMENT); // pane.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.add(label); panel.add(pane); JPanel btnPanel = new JPanel(); btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS)); JButton okButton = new JButton("OK"); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); JButton defButton = new JButton("Default"); defButton.addActionListener(this); JButton resetButton = new JButton("Reset"); resetButton.addActionListener(this); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(okButton); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(cancelButton); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(defButton); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(resetButton); btnPanel.add(Box.createHorizontalGlue()); btnPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.add(btnPanel); getContentPane().add(panel); getRootPane().setDefaultButton(cancelButton); pack(); setLocationRelativeTo(parent); setVisible(true); setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.panels.ServerList.java
public void retriveServerList() { try {//from w w w. j a v a 2 s . c om JSONObject json = CHGManager.getInstance().getGameCPX() .performAPICall(new String[] { "command", "service_list" }); for (int x = 0; x < json.getJSONArray("result").length(); x++) { JSONObject server = json.getJSONArray("result").getJSONObject(x); Server theServer = new Server(); ServerDisplay test = new ServerDisplay(server); test.setBorder(BorderFactory.createTitledBorder("Server 1")); test.setAlignmentX(Component.CENTER_ALIGNMENT); test.setMaximumSize(new Dimension(99999, 80)); add(test); } /*ServerDisplay test2 = new ServerDisplay(); test2.setBorder(BorderFactory.createTitledBorder("Server 2")); test2.setAlignmentX(Component.CENTER_ALIGNMENT); test2.setMaximumSize(new Dimension(99999, 70)); add(test2);*/ } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (EmptyAPIResponseException e) { e.printStackTrace(); } }
From source file:components.SliderDemo.java
public SliderDemo() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); delay = 1000 / FPS_INIT;/*from w w w . ja va 2s .c om*/ //Create the label. JLabel sliderLabel = new JLabel("Frames Per Second", JLabel.CENTER); sliderLabel.setAlignmentX(Component.CENTER_ALIGNMENT); //Create the slider. JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT); framesPerSecond.addChangeListener(this); //Turn on labels at major tick marks. framesPerSecond.setMajorTickSpacing(10); framesPerSecond.setMinorTickSpacing(1); framesPerSecond.setPaintTicks(true); framesPerSecond.setPaintLabels(true); framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); Font font = new Font("Serif", Font.ITALIC, 15); framesPerSecond.setFont(font); //Create the label that displays the animation. picture = new JLabel(); picture.setHorizontalAlignment(JLabel.CENTER); picture.setAlignmentX(Component.CENTER_ALIGNMENT); picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(10, 10, 10, 10))); updatePicture(0); //display first frame //Put everything together. add(sliderLabel); add(framesPerSecond); add(picture); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Set up a timer that calls this object's action handler. timer = new Timer(delay, this); timer.setInitialDelay(delay * 7); //We pause animation twice per cycle //by restarting the timer timer.setCoalesce(true); }
From source file:components.TablePrintDemo.java
public TablePrintDemo() { super();//from w w w .ja va 2 s .c o m setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); table = new JTable(new MyTableModel()); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); //Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); //Add the scroll pane to this panel. add(scrollPane); //Add a print button. JButton printButton = new JButton("Print"); printButton.setAlignmentX(Component.CENTER_ALIGNMENT); printButton.addActionListener(this); add(printButton); }
From source file:HtmlDemo.java
public HtmlDemo() { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); String initialText = "<html>\n" + "Color and font test:\n" + "<ul>\n" + "<li><font color=red>red</font>\n" + "<li><font color=blue>blue</font>\n" + "<li><font color=green>green</font>\n" + "<li><font size=-2>small</font>\n" + "<li><font size=+2>large</font>\n" + "<li><i>italic</i>\n" + "<li><b>bold</b>\n" + "</ul>\n"; htmlTextArea = new JTextArea(10, 20); htmlTextArea.setText(initialText);/*from w ww. j ava 2s .c o m*/ JScrollPane scrollPane = new JScrollPane(htmlTextArea); JButton changeTheLabel = new JButton("Change the label"); changeTheLabel.setMnemonic(KeyEvent.VK_C); changeTheLabel.setAlignmentX(Component.CENTER_ALIGNMENT); changeTheLabel.addActionListener(this); theLabel = new JLabel(initialText) { public Dimension getPreferredSize() { return new Dimension(200, 200); } public Dimension getMinimumSize() { return new Dimension(200, 200); } public Dimension getMaximumSize() { return new Dimension(200, 200); } }; theLabel.setVerticalAlignment(SwingConstants.CENTER); theLabel.setHorizontalAlignment(SwingConstants.CENTER); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); leftPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Edit the HTML, then click the button"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); leftPanel.add(scrollPane); leftPanel.add(Box.createRigidArea(new Dimension(0, 10))); leftPanel.add(changeTheLabel); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS)); rightPanel .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("A label with HTML"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); rightPanel.add(theLabel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); add(leftPanel); add(Box.createRigidArea(new Dimension(10, 0))); add(rightPanel); }
From source file:view.tabtables.EmulationTablesDrawer.java
protected void tablesInitialize() { JScrollPane scroll;//from w w w . j a va 2s .com logTable = new JTable(new StringTableModel(new Object[0][0], new Object[0])); logTable.getTableHeader().setReorderingAllowed(false); scroll = new JScrollPane(logTable); scroll.setAlignmentX(Component.CENTER_ALIGNMENT); add(scroll); statisticTable = new JTable(new StringTableModel(new Object[0][0], new Object[0])); statisticTable.getTableHeader().setReorderingAllowed(false); scroll = new JScrollPane(statisticTable); scroll.setAlignmentX(Component.CENTER_ALIGNMENT); add(scroll); changingMarkStatisticTable = new JTable(new StringTableModel(new Object[0][0], new Object[0])); changingMarkStatisticTable.getTableHeader().setReorderingAllowed(false); scroll = new JScrollPane(changingMarkStatisticTable); scroll.setAlignmentX(Component.CENTER_ALIGNMENT); add(scroll); changingPMarkStatisticTable = new JTable(new StringTableModel(new Object[0][0], new Object[0])); changingPMarkStatisticTable.getTableHeader().setReorderingAllowed(false); scroll = new JScrollPane(changingPMarkStatisticTable); scroll.setAlignmentX(Component.CENTER_ALIGNMENT); add(scroll); summaryTable = new JTable(new StringTableModel(new Object[0][0], new Object[0])); summaryTable.getTableHeader().setReorderingAllowed(false); scroll = new JScrollPane(summaryTable); scroll.setAlignmentX(Component.CENTER_ALIGNMENT); add(scroll); }
From source file:components.SliderDemo2.java
public SliderDemo2() { super(new BorderLayout()); delay = 1000 / FPS_INIT;/* w ww . ja va2 s .c om*/ //Create the slider. JSlider framesPerSecond = new JSlider(JSlider.VERTICAL, FPS_MIN, FPS_MAX, FPS_INIT); framesPerSecond.addChangeListener(this); framesPerSecond.setMajorTickSpacing(10); framesPerSecond.setPaintTicks(true); //Create the label table. Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); //PENDING: could use images, but we don't have any good ones. labelTable.put(new Integer(0), new JLabel("Stop")); //new JLabel(createImageIcon("images/stop.gif")) ); labelTable.put(new Integer(FPS_MAX / 10), new JLabel("Slow")); //new JLabel(createImageIcon("images/slow.gif")) ); labelTable.put(new Integer(FPS_MAX), new JLabel("Fast")); //new JLabel(createImageIcon("images/fast.gif")) ); framesPerSecond.setLabelTable(labelTable); framesPerSecond.setPaintLabels(true); framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); //Create the label that displays the animation. picture = new JLabel(); picture.setHorizontalAlignment(JLabel.CENTER); picture.setAlignmentX(Component.CENTER_ALIGNMENT); picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(10, 10, 10, 10))); updatePicture(0); //display first frame //Put everything together. add(framesPerSecond, BorderLayout.LINE_START); add(picture, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Set up a timer that calls this object's action handler. timer = new Timer(delay, this); timer.setInitialDelay(delay * 7); //We pause animation twice per cycle //by restarting the timer timer.setCoalesce(true); }
From source file:utilities.GraphViewer.java
public GraphViewer() { super("Graph Viewer"); setRootPaneCheckingEnabled(false);//from w w w .ja v a 2 s .c om this.setLocation(0, 0); this.setVisible(false); dataset = new XYSeriesCollection(); this.db = new Db(); this.sensors = new LinkedList<JCheckBox>(); this.sensors1 = new LinkedList<JCheckBox>(); getContentPane().setLayout(new BorderLayout(0, 0)); this.setName("Graph Viewer"); setIconifiable(true); setClosable(true); setBounds(6, 95, 1000, 600); option = new JPanel(); option.setBackground(new Color(240, 240, 255)); option.setPreferredSize(new Dimension(200, 500)); option.setLayout(new BorderLayout(10, 10)); getContentPane().add(option, BorderLayout.WEST); parcourir = new JButton("Add Sensor"); parcourir.setAlignmentX(Component.CENTER_ALIGNMENT); parcourir.addActionListener(this); option.add(parcourir, BorderLayout.NORTH); this.sensorsList = new JPanel(); sensorsList.setLayout(new VerticalLayout()); sensorsList.setBackground(Color.WHITE); scpane = new JScrollPane(sensorsList); scpane.setBorder(BorderFactory.createLineBorder(Color.black)); scpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); option.add(scpane, BorderLayout.CENTER); paneGraphe = new JPanel(); paneGraphe.setLayout(new BorderLayout(0, 0)); graphe = graphe(); paneGraphe.add(graphe, BorderLayout.CENTER); getContentPane().add(paneGraphe); }