List of usage examples for javax.swing JFrame setLayout
public void setLayout(LayoutManager manager)
LayoutManager
. From source file:Main.java
Main() { JFrame jfrm = new JFrame("Demonstrate a Text Field"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(240, 140);//from w w w . ja v a 2 s . c om jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jtf.setActionCommand("TF"); jtf.addActionListener(this); jbtnGetTextUpper.addActionListener(this); jtf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent ce) { System.out.println("Text in real time: " + jtf.getText()); } }); jfrm.add(jtf); jfrm.add(jbtnGetTextUpper); jfrm.setVisible(true); }
From source file:Main.java
public Main() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.pack();//from www. j av a 2 s .c om frame.setVisible(true); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("Check Box Demo"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(300, 200);/*from w w w . j a v a 2s. c om*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jcbOption1.setEnabled(false); jcbOption2.setEnabled(false); jcbOption3.setEnabled(false); jcbControl.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (jcbControl.isSelected()) { jcbOption1.setEnabled(true); jcbOption2.setEnabled(true); jcbOption3.setEnabled(true); System.out.println("enabled."); } else { jcbOption1.setEnabled(false); jcbOption2.setEnabled(false); jcbOption3.setEnabled(false); System.out.println("disabled."); } } }); jcbOption1.addItemListener(this); jcbOption2.addItemListener(this); jcbOption3.addItemListener(this); jfrm.add(jcbControl); jfrm.add(jcbOption1); jfrm.add(jcbOption2); jfrm.add(jcbOption3); jfrm.setVisible(true); }
From source file:Main.java
public Main() { JFrame jfrm = new JFrame("Cut, Copy, and Paste"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(230, 150);/*from w ww . j a va 2 s . c om*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnCut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.cut(); update(); } }); jbtnPaste.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.paste(); update(); } }); jbtnCopy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.copy(); update(); } }); jtf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent ce) { update(); } }); jfrm.add(jtf); jfrm.add(jbtnCut); jfrm.add(jbtnPaste); jfrm.add(jbtnCopy); jfrm.setVisible(true); }
From source file:Main.java
public Fonts() { doc = jta.getStyledDocument();//from w w w. j a v a 2s .c o m JScrollPane jsp = new JScrollPane(jta); jsp.setPreferredSize(new Dimension(400, 400)); JFrame frm = new JFrame(); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setLayout(new BorderLayout()); frm.add(jsp, BorderLayout.CENTER); frm.setLocation(100, 100); frm.pack(); frm.setVisible(true); jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start(); }
From source file:com.springsource.samples.resttemplate.FlickrClient.java
private void showPhotos(String searchTerm, List<BufferedImage> imageList) { JFrame frame = new JFrame(searchTerm + " photos"); frame.setLayout(new GridLayout(2, imageList.size() / 2)); for (BufferedImage image : imageList) { if (image != null) frame.add(new JLabel(new ImageIcon(image))); }//from w w w. j av a 2 s . com frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public Main() { JFrame frame = new JFrame(); JPanel contentPane = (JPanel) frame.getContentPane(); addKeyBind(contentPane, "F10"); clicker = new JButton("Clicker"); contentPane.add(clicker);//from w w w . j a v a 2 s . c om frame.setLayout(new GridBagLayout()); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:ListDrop.java
public ListDrop() { JFrame f = new JFrame(); JList list = new JList(model); list.setDropMode(DropMode.INSERT); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setTransferHandler(new ListHandler()); field.setDragEnabled(true);/*from ww w. ja v a 2s . com*/ f.setLayout(new FlowLayout()); f.add(new JScrollPane(list)); f.add(field); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:TradeMonitorGui.java
private XYPlot createChartFrame(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Average Stock Price over 1 minute", "Time", "Price in USD", dataset, true, true, false); XYPlot plot = chart.getXYPlot();/*from ww w . j av a2s .c o m*/ plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Trade Monitor"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { avgPrices.removeEntryListener(listenerId); } }); frame.setVisible(true); return plot; }
From source file:freemrs.ChartPanelDraw.java
public ChartPanelDraw(java.util.List<Vitals> result, String type) { this.type = type; this.result = result; dataset = createTimeDataset();/*ww w .j a v a2 s . co m*/ chartPanel = createChart(dataset, type); JFrame f = new JFrame("Vital Plot"); //Jframe to draw the graph f.setTitle("Vital Plot"); f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); f.setLayout(new BorderLayout(0, 5)); f.add(chartPanel, BorderLayout.CENTER); f.setIconImage(new ImageIcon(getClass().getResource("/images/icon_transparent.png")).getImage()); chartPanel.setHorizontalAxisTrace(true); //set properties of the graph chartPanel.setVerticalAxisTrace(true); chartPanel.setMouseWheelEnabled(true); JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(createTrace()); //Add components to panel panel.add(createDate()); panel.add(createZoom()); f.add(panel, BorderLayout.SOUTH); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }