List of usage examples for java.awt Container setLayout
public void setLayout(LayoutManager mgr)
From source file:fedroot.dacs.swingdemo.DacsSwingDemo.java
private void init(JFrame mainFrame) { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel gotoUrlPanel = new JPanel(new FlowLayout()); JPanel actionPanel = new JPanel(new FlowLayout()); JPanel modifiersPanel = new JPanel(new FlowLayout()); btnGO = new JButton("GO"); btnGO.addActionListener(new ActionListener() { @Override/*from w w w . j ava 2s. c o m*/ public void actionPerformed(ActionEvent ae) { loadPage("text/html", testURLs[actionsComboBox.getSelectedIndex()]); } }); btnLOGIN = new JButton("Login"); btnLOGIN.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { loginDialog.showDialog(); } }); btnLOGOUT = new JButton("Logout"); btnLOGOUT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { sessionManager.signout(); } }); //initially user is not signed in - btnLOGOUT will be enabled upon successful login btnLOGOUT.setEnabled(false); actionsComboBox = new JComboBox(actions); actionsComboBox.setToolTipText("Select an Action"); actionsComboBox.setEditable(true); actionsComboBox.setSelectedIndex(0); JLabel actionLabel = new JLabel("Action:"); urlTextField = new TextField(70); urlTextField.setEditable(true); actionPanel.add(actionLabel); actionPanel.add(actionsComboBox); actionPanel.add(btnGO); actionPanel.add(btnLOGIN); actionPanel.add(btnLOGOUT); mainPanel.add(gotoUrlPanel, BorderLayout.NORTH); mainPanel.add(actionPanel, BorderLayout.SOUTH); JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel); splitInputPane.setOneTouchExpandable(false); responseTextArea = new JTextArea(); responseTextArea.setEditable(false); responseTextArea.setCaretPosition(0); htmlPane = new JEditorPane(); // htmlPane.setContentType("image/png"); htmlPane.setEditable(false); JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea), new JScrollPane(htmlPane)); splitResponsePane.setOneTouchExpandable(false); splitResponsePane.setResizeWeight(0.35); Container container = mainFrame.getContentPane(); container.setLayout(new BorderLayout()); container.add(splitInputPane, BorderLayout.NORTH); container.add(splitResponsePane, BorderLayout.CENTER); mainFrame.pack(); }
From source file:test.uk.co.modularaudio.util.swing.colouredtoggle.TestUseColouredTextToggle.java
public void go() throws Exception { final JFrame testFrame = new JFrame("TestFrame"); testFrame.setSize(new Dimension(300, 300)); testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container contentPane = testFrame.getContentPane(); final MigLayoutStringHelper msh = new MigLayoutStringHelper(); msh.addLayoutConstraint("fill"); msh.addLayoutConstraint("gap 0"); msh.addLayoutConstraint("insets 0"); contentPane.setLayout(msh.createMigLayout()); final Color surroundColor = Color.decode("#44BB44"); final Color backgroundColor = Color.BLACK; final ToggleReceiver testReceiver = new ToggleReceiver() { @Override/*from www . j a va 2 s . c om*/ public void receiveToggle(final int toggleId, final boolean active) { log.trace("Received a toggle of " + toggleId + " to " + active); } }; final ColouredTextToggle ctt = new ColouredTextToggle("NoTS", "Tooltip Text", backgroundColor, surroundColor, false, testReceiver, 1); contentPane.add(ctt, "grow"); testFrame.pack(); testFrame.addWindowListener(new WindowListener() { @Override public void windowOpened(final WindowEvent e) { } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } @Override public void windowClosing(final WindowEvent e) { log.trace("Window closing. Value of control is \"" + ctt.getControlValue() + "\""); } @Override public void windowClosed(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { log.trace("Showing test frame"); testFrame.setVisible(true); } }); }
From source file:test.uk.co.modularaudio.util.swing.colouredtoggle.TestUseColouredLabelToggle.java
public void go() throws Exception { final JFrame testFrame = new JFrame("TestFrame"); testFrame.setSize(new Dimension(300, 300)); testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container contentPane = testFrame.getContentPane(); final MigLayoutStringHelper msh = new MigLayoutStringHelper(); msh.addLayoutConstraint("fill"); msh.addLayoutConstraint("gap 0"); msh.addLayoutConstraint("insets 0"); contentPane.setLayout(msh.createMigLayout()); final Color surroundColor = Color.decode("#FFFFFF"); final Color backgroundColor = Color.BLACK; final Color foregroundColor = Color.white; final ToggleReceiver testReceiver = new ToggleReceiver() { @Override/*from w w w. j av a2 s . co m*/ public void receiveToggle(final int toggleId, final boolean active) { log.trace("Received a toggle of " + toggleId + " to " + active); } }; final ColouredLabelToggle clt = new ColouredLabelToggle("Trigger", "Tooltip Text", backgroundColor, foregroundColor, surroundColor, false, testReceiver, 0); contentPane.add(clt, "grow"); testFrame.pack(); testFrame.addWindowListener(new WindowListener() { @Override public void windowOpened(final WindowEvent e) { } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } @Override public void windowClosing(final WindowEvent e) { log.trace("Window closing. Value of control is \"" + clt.getControlValue() + "\""); } @Override public void windowClosed(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { log.trace("Showing test frame"); testFrame.setVisible(true); } }); }
From source file:IDlookGetStream.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();/* ww w. ja v a2s .c o m*/ accountNumberList.setVisibleRowCount(2); JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList); //Do Get Account Button getAccountButton = new JButton("Get Account"); getAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.beforeFirst(); while (rs.next()) { if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue())) break; } if (!rs.isAfterLast()) { accountIDText.setText(rs.getString("acc_id")); thumbIDText.setText(rs.getString("thumb_id")); Blob blob = rs.getBlob("pic"); int b; InputStream bis = rs.getBinaryStream("pic"); FileOutputStream f = new FileOutputStream("pic.jpg"); while ((b = bis.read()) >= 0) { f.write(b); } f.close(); bis.close(); icon = new ImageIcon(blob.getBytes(1L, (int) blob.length())); createThumbnail(); photographLabel.setIcon(iconThumbnail); } } catch (Exception selectException) { displaySQLErrors(selectException); } } }); //Do Update Account Button updateAccountButton = new JButton("Update Account"); updateAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.updateBytes("thumbnail.pic", bytes); rs.updateRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); //Do insert Account Button insertAccountButton = new JButton("Insert Account"); insertAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.moveToInsertRow(); rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText())); rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText())); rs.updateBytes("pic", bytes); rs.updateObject("sysobject", null); rs.updateTimestamp("ts", new Timestamp(0)); rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime())); rs.insertRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); photographLabel = new JLabel(); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setVerticalAlignment(JLabel.CENTER); photographLabel.setVerticalTextPosition(JLabel.CENTER); photographLabel.setHorizontalTextPosition(JLabel.CENTER); JPanel first = new JPanel(new GridLayout(4, 1)); first.add(accountNumberListScrollPane); first.add(getAccountButton); first.add(updateAccountButton); first.add(insertAccountButton); accountIDText = new JTextField(15); thumbIDText = new JTextField(15); errorText = new JTextArea(5, 15); errorText.setEditable(false); JPanel second = new JPanel(); second.setLayout(new GridLayout(2, 1)); second.add(thumbIDText); second.add(accountIDText); JPanel third = new JPanel(); third.add(new JScrollPane(errorText)); nailFileText = new JTextField(25); c.add(first); c.add(second); c.add(third); c.add(nailFileText); c.add(photographLabel); setSize(500, 500); show(); }
From source file:edu.clemson.cs.nestbed.client.gui.MessageMonitorFrame.java
public MessageMonitorFrame(Mote mote, ProgramProfilingMessageSymbol profMessageSymbol) throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException { this.mote = mote; this.profMessageSymbol = profMessageSymbol; this.methodFieldMap = new HashMap<Method, JTextField>(); lookupRemoteManagers();//from w w w. j a v a 2 s . co m messageSymbol = progMsgSymManager.getProgramMessageSymbol(profMessageSymbol.getProgramMessageSymbolID()); setTitle(messageSymbol.getName() + " Message Monitor"); setSize(WINDOW_WIDTH, WINDOW_HEIGHT); setJMenuBar(buildMenuBar()); Container c = this.getContentPane(); c.setLayout(new BorderLayout()); c.add(new JScrollPane(buildMessageDataPanel()), BorderLayout.NORTH); c.add(buildButtonPanel(), BorderLayout.SOUTH); }
From source file:test.uk.co.modularaudio.util.swing.texttoggle.TestUseTextToggle.java
public void go() throws Exception { final JFrame testFrame = new JFrame("TestFrame"); testFrame.setSize(new Dimension(300, 300)); testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container contentPane = testFrame.getContentPane(); final MigLayoutStringHelper msh = new MigLayoutStringHelper(); msh.addLayoutConstraint("fill"); msh.addLayoutConstraint("gap 0"); msh.addLayoutConstraint("insets 0"); contentPane.setLayout(msh.createMigLayout()); final Color BACKGROUND_COLOR = Color.BLACK; final Color SCOPE_BODY = new Color(75, 131, 155); final Color SCOPE_AXIS_DETAIL = SCOPE_BODY.darker().darker(); final Color selectedTextColor = SCOPE_BODY; final Color unselectedTextColor = SCOPE_AXIS_DETAIL; final Color borderColor = SCOPE_AXIS_DETAIL; final Color backgroundColor = BACKGROUND_COLOR; final ToggleReceiver testReceiver = new ToggleReceiver() { @Override/*from w ww . j ava2 s . co m*/ public void receiveToggle(final int toggleId, final boolean active) { log.trace("Received a toggle of " + toggleId + " to " + active); } }; final TextToggle tt = new TextToggle("Bi Polar", "Uni Polar", selectedTextColor, unselectedTextColor, backgroundColor, borderColor, true, true, testReceiver, -1); contentPane.add(tt, "grow"); testFrame.pack(); testFrame.addWindowListener(new WindowListener() { @Override public void windowOpened(final WindowEvent e) { } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } @Override public void windowClosing(final WindowEvent e) { log.trace("Window closing. Value of control is \"" + tt.getControlValue() + "\""); } @Override public void windowClosed(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { log.trace("Showing test frame"); testFrame.setVisible(true); } }); }
From source file:fungus.MycoNodeFrame.java
public MycoNodeFrame(MycoNode node) { this.node = node; this.setTitle("Node " + node.getID()); graph = JungGraphObserver.getGraph(); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(7, 2)); JPanel neighborPane = new JPanel(); neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS)); JPanel logPane = new JPanel(); logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); loggingTextArea = new JTextArea("", 25, 100); loggingTextArea.setLineWrap(true);/*from w w w. j a va2s .c om*/ loggingTextArea.setEditable(false); handler = new MycoNodeLogHandler(node, loggingTextArea); handler.addChangeListener(this); JScrollPane logScrollPane = new JScrollPane(loggingTextArea); logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); logPane.add(logScrollPane); contentPane.add(labelPane); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(neighborPane); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(logPane); contentPane.add(buttonPane); data = node.getHyphaData(); link = node.getHyphaLink(); mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); stateLabel = new JLabel(); typeLabel = new JLabel(); queueLengthLabel = new JLabel(); sameLabel = new JLabel(); differentLabel = new JLabel(); maxCapacityLabel = new JLabel(); idealImmobileLabel = new JLabel(); idealHyphaeLabel = new JLabel(); idealBiomassLabel = new JLabel(); degreeLabel = new JLabel(); hyphaDegreeLabel = new JLabel(); biomassDegreeLabel = new JLabel(); hyphaUtilizationLabel = new JLabel(); biomassUtilizationLabel = new JLabel(); capacityUtilizationLabel = new JLabel(); labelPane.add(new JLabel("state")); labelPane.add(stateLabel); labelPane.add(new JLabel("type")); labelPane.add(typeLabel); labelPane.add(new JLabel("queue")); labelPane.add(queueLengthLabel); labelPane.add(new JLabel("")); labelPane.add(new JLabel("")); labelPane.add(new JLabel("same")); labelPane.add(sameLabel); labelPane.add(new JLabel("different")); labelPane.add(differentLabel); //labelPane.add(new JLabel("immobile")); //labelPane.add(idealImmobileLabel); labelPane.add(new JLabel("")); labelPane.add(new JLabel("actual")); labelPane.add(new JLabel("ideal")); labelPane.add(new JLabel("utilization")); labelPane.add(new JLabel("hyphae")); labelPane.add(hyphaDegreeLabel); labelPane.add(idealHyphaeLabel); labelPane.add(hyphaUtilizationLabel); labelPane.add(new JLabel("biomass")); labelPane.add(biomassDegreeLabel); labelPane.add(idealBiomassLabel); labelPane.add(biomassUtilizationLabel); labelPane.add(new JLabel("capacity")); labelPane.add(degreeLabel); labelPane.add(maxCapacityLabel); labelPane.add(capacityUtilizationLabel); neighborListControl = new JList(); neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP); neighborListControl.setVisibleRowCount(-1); neighborListScroller = new JScrollPane(neighborListControl); neighborListScroller.setPreferredSize(new Dimension(250, 150)); neighborListScroller.setMinimumSize(new Dimension(250, 150)); neighborPane.add(neighborListScroller); JButton updateButton = new JButton("Refresh"); ActionListener updater = new ActionListener() { public void actionPerformed(ActionEvent e) { refreshData(); } }; updateButton.addActionListener(updater); JButton closeButton = new JButton("Close"); ActionListener closer = new ActionListener() { public void actionPerformed(ActionEvent e) { closeFrame(); } }; closeButton.addActionListener(closer); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(updateButton); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(closeButton); refreshData(); JungGraphObserver.addChangeListener(this); this.pack(); this.setVisible(true); }
From source file:org.executequery.components.FileChooserDialog.java
protected JDialog createDialog(Component parent) throws HeadlessException { Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); String title = getUI().getDialogTitle(this); JDialog dialog = new JDialog(frame, title, true); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(this, BorderLayout.CENTER); setPreferredSize(new Dimension(700, getPreferredSize().height)); // add any custom panel if (customPanel != null) { contentPane.add(customPanel, BorderLayout.SOUTH); }// w ww.j ava2s .co m if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } } setFileView(new DefaultFileView()); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); return dialog; }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
public DataAnalysisWindow(DataIntegrationConfig config) { setLookAndFeel();/* w w w . ja v a 2 s .c om*/ this.config = config; this.setTitle("uniVocity data integration: " + config.getSourceDatabaseConfig().getDatabaseName() + " -> " + config.getDestinationDatabaseConfig().getDatabaseName()); this.setGlassPane(getGlass()); this.setIconImage(getIcon()); setDefaultCloseOperation(EXIT_ON_CLOSE); Container container = getContentPane(); container.setLayout(new BorderLayout()); JPanel northPanel = new JPanel(new BorderLayout()); northPanel.add(getProcessPanel(), BorderLayout.CENTER); northPanel.add(getLogoPanel(), BorderLayout.NORTH); container.add(northPanel, BorderLayout.NORTH); container.add(getDataAnalysisPanel(), BorderLayout.CENTER); container.add(getStatusPanel(), BorderLayout.SOUTH); setSize(Toolkit.getDefaultToolkit().getScreenSize()); setLocationRelativeTo(null); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.graph.SimpleCollapsableGraph.java
public SimpleCollapsableGraph(UndirectedSparseMultigraph<IB_Vertex, IB_Edge> graph, OSM_Node subnetManager, Dimension preferredSize) throws HeadlessException { super();/* ww w . ja v a 2 s.c o m*/ setGraph(graph); layout = new FRLayout<IB_Vertex, IB_Edge>(graph); if (preferredSize == null) preferredSize = new Dimension(600, 600); else { // trim 10% off the supplied size preferredSize = new Dimension((preferredSize.width * 9) / 10, (preferredSize.height * 9) / 10); } final VisualizationModel<IB_Vertex, IB_Edge> visualizationModel = new DefaultVisualizationModel<IB_Vertex, IB_Edge>( layout, preferredSize); VisualizationViewer<IB_Vertex, IB_Edge> vv = new VisualizationViewer<IB_Vertex, IB_Edge>(visualizationModel, preferredSize); vv.addGraphMouseListener(new SimpleGraphMouseListener<IB_Vertex>(this)); final PickedState<IB_Vertex> picked_v_state = vv.getPickedVertexState(); PickedState<IB_Edge> picked_e_state = vv.getPickedEdgeState(); picked_e_state.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Object subject = e.getItem(); if (subject instanceof IB_Edge) { IB_Edge edge = (IB_Edge) subject; if (e.getStateChange() == ItemEvent.SELECTED) { // craft a selection event, for this edge GraphSelectionManager.getInstance() .updateAllListeners(new IB_GraphSelectionEvent(this, subject, edge)); MessageManager.getInstance().postMessage( new SmtMessage(SmtMessageType.SMT_MSG_INFO, "SCG - edge selected: Color it!")); } else if (e.getStateChange() == ItemEvent.DESELECTED) { // this is deselected, do nothing MessageManager.getInstance() .postMessage(new SmtMessage(SmtMessageType.SMT_MSG_INFO, "SCG - edge deselected")); } else { System.err.println( "SCG - edge not selected or deselected - unknown state change: The edge itemEvent is: " + e.getStateChange()); } } else { System.err.println("SCG - not edge??: The edge subject picked is: " + subject.getClass().getCanonicalName()); } } }); // create decorators vv.getRenderContext().setVertexLabelTransformer(IB_TransformerFactory.getVertexLabelTransformer(vv)); vv.getRenderContext().setVertexShapeTransformer(IB_TransformerFactory.getVertexShapeTransformer(vv)); vv.getRenderContext().setVertexFillPaintTransformer( IB_TransformerFactory.getVertexFillPaintTransformer(vv, subnetManager)); vv.getRenderContext().setEdgeLabelTransformer(IB_TransformerFactory.getEdgeLabelTransformer(vv)); vv.getRenderContext().setEdgeFillPaintTransformer(IB_TransformerFactory.getEdgeFillPaintTransformer(vv)); vv.getRenderContext().setEdgeDrawPaintTransformer(IB_TransformerFactory.getEdgeDrawPaintTransformer(vv)); // add a listener for ToolTips vv.setVertexToolTipTransformer(IB_TransformerFactory.getVertexToolTipTransformer(vv)); vv.setEdgeToolTipTransformer(IB_TransformerFactory.getEdgeToolTipTransformer(vv)); setVisViewer(vv); final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance(); final Set exclusions = new HashSet(); eif.setPredicate(new Predicate() { public boolean evaluate(Object e) { return exclusions.contains(e); } }); vv.getRenderContext().setParallelEdgeIndexFunction(eif); vv.setBackground(Color.white); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); // Container content = getContentPane(); // for JApplet or JFrame Container content = this; // for JPanel content.setLayout(new BorderLayout()); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp, BorderLayout.CENTER); }