List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout(int align, int hgap, int vgap)
From source file:de.weltraumschaf.minesweeper.gui.StatusBar.java
/** * Dedicated constructor.//from w ww. ja v a2 s.co m * * Initializes {@link #elapsedTime} and {@link #minesLeft} with {@code 0}. */ public StatusBar() { super(new FlowLayout(FlowLayout.LEFT, 2, 0)); add(scoreLabel); add(new JLabel(SEPARATOR)); elapsedTime.setValue("0"); add(elapsedTime); add(new JLabel(SEPARATOR)); minesLeft.setValue("0"); add(minesLeft); setBorder(new BevelBorder(BevelBorder.LOWERED)); }
From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacPreferencesPane.java
public MacPreferencesPane(final AgentMacWindow agentMacWindow) { super();//from w w w . j a v a2 s . c o m getContentPane().setLayout(new BorderLayout(10, 10)); JLabel prefsText = new JLabel("Go Server Hostname or IP"); serverTextField = new JTextField(""); serverTextField.setColumns(15); serverTextField.selectAll(); JPanel textPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); textPanel.add(prefsText); textPanel.add(serverTextField); getContentPane().add(textPanel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); JButton okButton = new JButton("OK"); buttonPanel.add(okButton); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent newEvent) { String newHost = serverTextField.getText(); if (!originalHost.equals(newHost)) { LOG.info("Server changed to " + newHost); agentMacWindow.setHost(newHost); } else { LOG.info("Server is still " + originalHost); } setVisible(false); } }); getContentPane().add(buttonPanel, BorderLayout.SOUTH); setSize(getPreferredSize()); setLocation(20, 40); setResizable(false); }
From source file:org.onesun.sdi.swing.app.views.dialogs.ChartDialog.java
public ChartDialog(Frame parent, JFreeChart moodChart, JFreeChart sentimentChart) { super(parent, true); this.parent = parent; this.setLayout(new BorderLayout(5, 5)); setTitle("Chart"); setSize(350, 225);/*from w ww .j a va2s . c om*/ setResizable(false); setVisible(false); JPanel chartPanel = new JPanel(new GridLayout(1, 2)); chartPanel.add(new ChartPanel(moodChart)); chartPanel.add(new ChartPanel(sentimentChart)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 15)); panel.add(okButton); this.add(chartPanel, BorderLayout.CENTER); this.add(panel, BorderLayout.SOUTH); UserActionListener userActionListener = new UserActionListener(); okButton.addActionListener(userActionListener); }
From source file:WebCrawler.java
public void init() { // set up the main UI panel panelMain = new Panel(); panelMain.setLayout(new BorderLayout(5, 5)); // text entry components Panel panelEntry = new Panel(); panelEntry.setLayout(new BorderLayout(5, 5)); Panel panelURL = new Panel(); panelURL.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); Label labelURL = new Label("Starting URL: ", Label.RIGHT); panelURL.add(labelURL);//from w w w.j av a2s .co m textURL = new TextField("", 40); panelURL.add(textURL); panelEntry.add("North", panelURL); Panel panelType = new Panel(); panelType.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); Label labelType = new Label("Content type: ", Label.RIGHT); panelType.add(labelType); choiceType = new Choice(); choiceType.addItem("text/html"); choiceType.addItem("audio/basic"); choiceType.addItem("audio/au"); choiceType.addItem("audio/aiff"); choiceType.addItem("audio/wav"); choiceType.addItem("video/mpeg"); choiceType.addItem("video/x-avi"); panelType.add(choiceType); panelEntry.add("South", panelType); panelMain.add("North", panelEntry); // list of result URLs Panel panelListButtons = new Panel(); panelListButtons.setLayout(new BorderLayout(5, 5)); Panel panelList = new Panel(); panelList.setLayout(new BorderLayout(5, 5)); Label labelResults = new Label("Search results"); panelList.add("North", labelResults); Panel panelListCurrent = new Panel(); panelListCurrent.setLayout(new BorderLayout(5, 5)); listMatches = new List(10); panelListCurrent.add("North", listMatches); labelStatus = new Label(""); panelListCurrent.add("South", labelStatus); panelList.add("South", panelListCurrent); panelListButtons.add("North", panelList); // control buttons Panel panelButtons = new Panel(); Button buttonSearch = new Button(SEARCH); buttonSearch.addActionListener(this); panelButtons.add(buttonSearch); Button buttonStop = new Button(STOP); buttonStop.addActionListener(this); panelButtons.add(buttonStop); panelListButtons.add("South", panelButtons); panelMain.add("South", panelListButtons); add(panelMain); setVisible(true); repaint(); // initialize search data structures vectorToSearch = new Vector(); vectorSearched = new Vector(); vectorMatches = new Vector(); // set default for URL access URLConnection.setDefaultAllowUserInteraction(false); }
From source file:org.pgptool.gui.ui.importkey.KeyImporterView.java
private JPanel buildPanelButtons() { JPanel ret = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); ret.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); ret.add(btnImport = new JButton()); ret.add(btnCancel = new JButton()); return ret;//ww w . j av a 2s . c om }
From source file:components.ButtonTabComponent.java
public ButtonTabComponent(final JTabbedPane pane) { //unset default FlowLayout' gaps super(new FlowLayout(FlowLayout.LEFT, 0, 0)); if (pane == null) { throw new NullPointerException("TabbedPane is null"); }// ww w .j a v a 2 s . co m this.pane = pane; setOpaque(false); //make JLabel read titles from JTabbedPane JLabel label = new JLabel() { public String getText() { int i = pane.indexOfTabComponent(ButtonTabComponent.this); if (i != -1) { return pane.getTitleAt(i); } return null; } }; add(label); //add more space between the label and the button label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); //tab button JButton button = new TabButton(); add(button); //add more space to the top of the component setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); }
From source file:com.emental.mindraider.ui.dialogs.DownloadModelJDialog.java
/** * Constructor.//www .ja v a 2 s . c om * * @param union * made union of models. */ public DownloadModelJDialog(boolean union) { super(Messages.getString("DownloadModelJDialog.title")); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); p.add(new JLabel(Messages.getString("DownloadModelJDialog.url"))); String[] knowUris = new String[] { "http://", "http://wymiwyg.org/", "http://www.osar.ch", "http://wymiwyg.org/.rdf?appendLang=en&till=50", "http://www.osar.ch/.rdf?appendLang=de&till=50" }; modelUrlCombo = new JComboBox(knowUris); modelUrlCombo.setEditable(true); modelUrlCombo.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { upload(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(modelUrlCombo); JButton uploadButton = new JButton(Messages.getString("DownloadModelJDialog.download")); uploadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { upload(); } }); p.add(uploadButton); JButton cancelButton = new JButton(Messages.getString("DownloadModelJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); getContentPane().add(p, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//from www . java 2 s .co m */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }
From source file:gdt.jgui.tool.JIconSelector.java
/** * The default constructor.// w w w. ja va 2 s . c o m */ public JIconSelector() { FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 5, 5); flowLayout.setAlignOnBaseline(true); WrapLayout wrapLayout = new WrapLayout(FlowLayout.LEFT, 5, 5); wrapLayout.setAlignOnBaseline(true); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); panel = new JPanel(); panel.setLayout(wrapLayout); scrollPane = new JScrollPane(panel); add(scrollPane); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); }
From source file:ja.lingo.application.gui.main.settings.appearance.AppearanceGui.java
public AppearanceGui(Model model) { model.addApplicationModelListener(new ModelAdapter() { public void settingsUpdated(Preferences preferences) { setSelectedFontSize(preferences.getFontSize()); setSelectedFontFace(preferences.getFontFace()); dropZoneCheckBox.setSelected(preferences.isDropZoneVisible()); memoryBarCheckBox.setSelected(preferences.isMemoryBarVisible()); }/* w w w.j a v a2 s. co m*/ }); dropZoneCheckBox = new JCheckBox(resources.text("showDropZone")); fontSizeComboBox = new JComboBox(new Integer[] { 12, 13, DEFAULT_FONT_SIZE, 15, 16, 17 }); memoryBarCheckBox = new JCheckBox(resources.text("showMemoryBar")); JPanel fontSizePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, Gaps.GAP5, 0)); fontSizePanel.add(resources.label("fontSize")); fontSizePanel.add(fontSizeComboBox); fontSizePanel.add(resources.label("requiresRestart")); gui = new JPanel(new TableLayout(new double[][] { { TableLayout.PREFERRED }, { TableLayout.PREFERRED, // 0: font face Gaps.GAP5, TableLayout.PREFERRED, // 2: font size Gaps.GAP5, TableLayout.PREFERRED, // 4: drop-zone Gaps.GAP5, TableLayout.PREFERRED, // 6: memory bar } })); JPanel fontFacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, Gaps.GAP5, 0)); fontFacePanel.add(resources.label("fontFace")); GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); fontFaceComboBox = new JComboBox(gEnv.getAvailableFontFamilyNames()); fontFaceComboBox.setMaximumRowCount(10); fontFacePanel.add(fontFaceComboBox); fontFacePanel.add(resources.label("requiresRestart")); gui.add(fontFacePanel, "0, 0"); gui.add(fontSizePanel, "0, 2"); gui.add(dropZoneCheckBox, "0, 4"); gui.add(memoryBarCheckBox, "0, 6"); Gaps.applyBorder5(gui); ActionBinder.bind(this); }