List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:com.moss.greenshell.state.StateTray.java
public void reset() { widgets.clear();/* ww w . j a v a 2 s . c o m*/ removeAll(); setLayout(new GridBagLayout()); c = new GridBagConstraints(); c.insets.left = 15; c.insets.top = 5; c.insets.bottom = 5; c.fill = GridBagConstraints.BOTH; repaint(); }
From source file:ChiSquareCalculator.java
ChiSquareCalculator() { final JFrame jfrm = new JFrame("Chi Square Calculator"); jfrm.setSize(400, 550);/*from w ww .j a v a2 s .c o m*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jfrm.setResizable(false); // panel 1 JPanel pn1 = new JPanel(); pn1.setOpaque(true); pn1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "2 x 2")); JLabel jlab1 = new JLabel("class 1"); JLabel jlab2 = new JLabel("class 2"); JLabel jlab3 = new JLabel("case"); JLabel jlab4 = new JLabel("control"); jtf1 = new JTextField(); jtf2 = new JTextField(); jtf3 = new JTextField(); jtf4 = new JTextField(); // pn1 layout all GridBagLayout CalLayout1 = new GridBagLayout(); GridBagConstraints gbc1 = new GridBagConstraints(); pn1.setLayout(CalLayout1); gbc1.weightx = 1.0; //default 0.0 gbc1.weighty = 1.0; //default 0.0 gbc1.insets = new Insets(4, 4, 4, 4); // Add some space gbc1.fill = GridBagConstraints.BOTH; gbc1.gridwidth = 1; gbc1.gridx = 1; gbc1.gridy = 0; CalLayout1.setConstraints(jlab1, gbc1); gbc1.gridx = 2; gbc1.gridy = 0; CalLayout1.setConstraints(jlab2, gbc1); gbc1.gridx = 0; gbc1.gridy = 1; CalLayout1.setConstraints(jlab3, gbc1); gbc1.gridx = 1; gbc1.gridy = 1; CalLayout1.setConstraints(jtf1, gbc1); gbc1.gridx = 2; gbc1.gridy = 1; CalLayout1.setConstraints(jtf2, gbc1); gbc1.gridx = 0; gbc1.gridy = 2; CalLayout1.setConstraints(jlab4, gbc1); gbc1.gridx = 1; gbc1.gridy = 2; CalLayout1.setConstraints(jtf3, gbc1); gbc1.gridx = 2; gbc1.gridy = 2; CalLayout1.setConstraints(jtf4, gbc1); pn1.add(jlab1); pn1.add(jlab2); pn1.add(jlab3); pn1.add(jlab4); pn1.add(jtf1); pn1.add(jtf2); pn1.add(jtf3); pn1.add(jtf4); // panel 2 JPanel pn2 = new JPanel(); pn2.setOpaque(true); pn2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "2 x 3")); JLabel jlab5 = new JLabel("class 1"); JLabel jlab6 = new JLabel("class 2"); JLabel jlab7 = new JLabel("class 3"); JLabel jlab8 = new JLabel("case"); JLabel jlab9 = new JLabel("control"); jtf5 = new JTextField(); jtf6 = new JTextField(); jtf7 = new JTextField(); jtf8 = new JTextField(); jtf9 = new JTextField(); jtf10 = new JTextField(); // pn2 layout all GridBagLayout CalLayout2 = new GridBagLayout(); GridBagConstraints gbc2 = new GridBagConstraints(); pn2.setLayout(CalLayout2); gbc2.weightx = 1.0; //default 0.0 gbc2.weighty = 1.0; //default 0.0 gbc2.insets = new Insets(4, 4, 4, 4); // Add some space gbc2.fill = GridBagConstraints.BOTH; gbc2.gridwidth = 1; gbc2.gridx = 1; gbc2.gridy = 0; CalLayout2.setConstraints(jlab5, gbc2); gbc2.gridx = 2; gbc2.gridy = 0; CalLayout2.setConstraints(jlab6, gbc2); gbc2.gridx = 3; gbc2.gridy = 0; CalLayout2.setConstraints(jlab7, gbc2); gbc2.gridx = 0; gbc2.gridy = 1; CalLayout2.setConstraints(jlab8, gbc2); gbc2.gridx = 1; gbc2.gridy = 1; CalLayout2.setConstraints(jtf5, gbc2); gbc2.gridx = 2; gbc2.gridy = 1; CalLayout2.setConstraints(jtf6, gbc2); gbc2.gridx = 3; gbc2.gridy = 1; CalLayout2.setConstraints(jtf7, gbc2); gbc2.gridx = 0; gbc2.gridy = 2; CalLayout2.setConstraints(jlab9, gbc2); gbc2.gridx = 1; gbc2.gridy = 2; CalLayout2.setConstraints(jtf8, gbc2); gbc2.gridx = 2; gbc2.gridy = 2; CalLayout2.setConstraints(jtf9, gbc2); gbc2.gridx = 3; gbc2.gridy = 2; CalLayout2.setConstraints(jtf10, gbc2); pn2.add(jlab5); pn2.add(jlab6); pn2.add(jlab7); pn2.add(jlab8); pn2.add(jlab9); pn2.add(jtf5); pn2.add(jtf6); pn2.add(jtf7); pn2.add(jtf8); pn2.add(jtf9); pn2.add(jtf10); // panel 3 JPanel pn3 = new JPanel(); pn3.setOpaque(true); pn3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "statistic")); JLabel jlab10 = new JLabel("chi-square"); JLabel jlab11 = new JLabel("degree of freedom"); jtf11 = new JTextField(); jtf12 = new JTextField(); GridBagLayout CalLayout3 = new GridBagLayout(); GridBagConstraints gbc3 = new GridBagConstraints(); pn3.setLayout(CalLayout3); gbc3.weightx = 1.0; //default 0.0 gbc3.weighty = 1.0; //default 0.0 gbc3.insets = new Insets(4, 4, 4, 4); // Add some space gbc3.fill = GridBagConstraints.BOTH; gbc3.gridwidth = 1; gbc3.gridx = 0; gbc3.gridy = 0; CalLayout3.setConstraints(jlab10, gbc3); gbc3.gridwidth = 3; gbc3.gridx = 1; gbc3.gridy = 0; CalLayout3.setConstraints(jtf11, gbc3); gbc3.gridwidth = 2; gbc3.gridx = 0; gbc3.gridy = 1; CalLayout3.setConstraints(jlab11, gbc3); gbc3.gridx = 2; gbc3.gridy = 1; CalLayout3.setConstraints(jtf12, gbc3); pn3.add(jlab10); pn3.add(jlab11); pn3.add(jtf11); pn3.add(jtf12); JPanel pn4 = new JPanel(); pn4.setOpaque(true); pn4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "result")); JLabel jlab12 = new JLabel("p-value"); final JLabel jlab13 = new JLabel("odds ratio"); final JLabel jlab14 = new JLabel("standard error"); final JLabel jlab15 = new JLabel("confidence interval 95%"); jtf13 = new JTextField(); jtf14 = new JTextField(); jtf15 = new JTextField(); jtf16 = new JTextField(); jtf17 = new JTextField(); jlab13.setEnabled(false); jlab14.setEnabled(false); jlab15.setEnabled(false); jtf14.setEnabled(false); jtf15.setEnabled(false); jtf16.setEnabled(false); jtf17.setEnabled(false); JButton jbtn1 = new JButton("Run 2x2"); jbtn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long number1, number2, number3, number4; try { number1 = Long.parseLong(jtf1.getText()); number2 = Long.parseLong(jtf2.getText()); number3 = Long.parseLong(jtf3.getText()); number4 = Long.parseLong(jtf4.getText()); } catch (Exception ne) { JOptionPane.showMessageDialog(jfrm, "Error: Bad input, only integer is acceptable!"); return; } long[][] obs = new long[2][2]; obs[0][0] = number1; obs[0][1] = number2; obs[1][0] = number3; obs[1][1] = number4; ChiSquareTest mychiSquare = new ChiSquareTest(); double stats = mychiSquare.chiSquare(obs); jtf11.setText(String.valueOf(stats)); jtf12.setText(String.valueOf(1)); double pvalue = mychiSquare.chiSquareTest(obs); jtf13.setText(String.valueOf(pvalue)); jtf5.setText(""); jtf6.setText(""); jtf7.setText(""); jtf8.setText(""); jtf9.setText(""); jtf10.setText(""); jlab13.setEnabled(true); jlab14.setEnabled(true); jlab15.setEnabled(true); jtf14.setEnabled(true); jtf15.setEnabled(true); jtf16.setEnabled(true); jtf17.setEnabled(true); double or = (double) (number2 * number3) / (number1 * number4); double se = Math.sqrt( (double) 1 / number1 + (double) 1 / number2 + (double) 1 / number3 + (double) 1 / number4); double logOR = Math.log(or); double logU95 = logOR + 1.96 * se; double logL95 = logOR - 1.96 * se; double U95 = Math.exp(logU95); double L95 = Math.exp(logL95); final java.text.DecimalFormat mydf = new java.text.DecimalFormat("0.000000"); jtf14.setText(String.valueOf(or)); jtf15.setText(String.valueOf(se)); jtf16.setText(String.valueOf(mydf.format(L95))); jtf17.setText(String.valueOf(mydf.format(U95))); } }); JButton jbtn2 = new JButton("Run 2x3"); jbtn2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long number1, number2, number3, number4, number5, number6; try { number1 = Long.parseLong(jtf5.getText()); number2 = Long.parseLong(jtf6.getText()); number3 = Long.parseLong(jtf7.getText()); number4 = Long.parseLong(jtf8.getText()); number5 = Long.parseLong(jtf9.getText()); number6 = Long.parseLong(jtf10.getText()); } catch (Exception ne) { JOptionPane.showMessageDialog(jfrm, "Error: Bad input, only integer is acceptable!"); return; } long[][] obs = new long[2][3]; obs[0][0] = number1; obs[0][1] = number2; obs[0][2] = number3; obs[1][0] = number4; obs[1][1] = number5; obs[1][2] = number6; ChiSquareTest mychiSquare = new ChiSquareTest(); double stats = mychiSquare.chiSquare(obs); jtf11.setText(String.valueOf(stats)); jtf12.setText(String.valueOf(2)); double pvalue = mychiSquare.chiSquareTest(obs); jtf13.setText(String.valueOf(pvalue)); jtf1.setText(""); jtf2.setText(""); jtf3.setText(""); jtf4.setText(""); jtf14.setText(""); jtf15.setText(""); jtf16.setText(""); jtf17.setText(""); jlab13.setEnabled(false); jlab14.setEnabled(false); jlab15.setEnabled(false); jtf14.setEnabled(false); jtf15.setEnabled(false); jtf16.setEnabled(false); jtf17.setEnabled(false); } }); JButton jbtn3 = new JButton("Run Statistic"); jbtn3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double stat, df; try { stat = Double.parseDouble(jtf11.getText()); df = Double.parseDouble(jtf12.getText()); } catch (Exception ne) { JOptionPane.showMessageDialog(jfrm, "Error: Bad input, only number is acceptable!"); return; } ChiSquaredDistribution distribution = new ChiSquaredDistribution(df); double pvalue = 1 - distribution.cumulativeProbability(stat); jtf13.setText(String.valueOf(pvalue)); jtf1.setText(""); jtf2.setText(""); jtf3.setText(""); jtf4.setText(""); jtf5.setText(""); jtf6.setText(""); jtf7.setText(""); jtf8.setText(""); jtf9.setText(""); jtf10.setText(""); jtf14.setText(""); jtf15.setText(""); jtf16.setText(""); jtf17.setText(""); jlab13.setEnabled(false); jlab14.setEnabled(false); jlab15.setEnabled(false); jtf14.setEnabled(false); jtf15.setEnabled(false); jtf16.setEnabled(false); jtf17.setEnabled(false); } }); JButton jbtn4 = new JButton("clear"); jbtn4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jtf1.setText(""); jtf2.setText(""); jtf3.setText(""); jtf4.setText(""); jtf5.setText(""); jtf6.setText(""); jtf7.setText(""); jtf8.setText(""); jtf9.setText(""); jtf10.setText(""); jtf11.setText(""); jtf12.setText(""); jtf13.setText(""); jtf14.setText(""); jtf15.setText(""); jtf16.setText(""); jtf17.setText(""); jlab13.setEnabled(false); jlab14.setEnabled(false); jlab15.setEnabled(false); jtf14.setEnabled(false); jtf15.setEnabled(false); jtf16.setEnabled(false); jtf17.setEnabled(false); } }); GridBagLayout CalLayout4 = new GridBagLayout(); GridBagConstraints gbc4 = new GridBagConstraints(); pn4.setLayout(CalLayout4); gbc4.weightx = 1.0; //default 0.0 gbc4.weighty = 1.0; //default 0.0 gbc4.insets = new Insets(4, 4, 4, 4); // Add some space gbc4.fill = GridBagConstraints.BOTH; gbc4.gridwidth = 1; gbc4.gridx = 0; gbc4.gridy = 0; CalLayout4.setConstraints(jbtn1, gbc4); gbc4.gridx = 1; gbc4.gridy = 0; CalLayout4.setConstraints(jbtn2, gbc4); gbc4.gridx = 2; gbc4.gridy = 0; CalLayout4.setConstraints(jbtn3, gbc4); gbc4.gridx = 3; gbc4.gridy = 0; CalLayout4.setConstraints(jbtn4, gbc4); gbc4.gridx = 0; gbc4.gridy = 1; CalLayout4.setConstraints(jlab12, gbc4); gbc4.gridwidth = 3; gbc4.gridx = 1; gbc4.gridy = 1; CalLayout4.setConstraints(jtf13, gbc4); gbc4.gridwidth = 2; gbc4.gridx = 0; gbc4.gridy = 2; CalLayout4.setConstraints(jlab13, gbc4); gbc4.gridx = 2; gbc4.gridy = 2; CalLayout4.setConstraints(jtf14, gbc4); gbc4.gridx = 0; gbc4.gridy = 3; CalLayout4.setConstraints(jlab14, gbc4); gbc4.gridx = 2; gbc4.gridy = 3; CalLayout4.setConstraints(jtf15, gbc4); gbc4.gridx = 0; gbc4.gridy = 4; CalLayout4.setConstraints(jlab15, gbc4); gbc4.gridwidth = 1; gbc4.gridx = 2; gbc4.gridy = 4; CalLayout4.setConstraints(jtf16, gbc4); gbc4.gridx = 3; gbc4.gridy = 4; CalLayout4.setConstraints(jtf17, gbc4); pn4.add(jlab12); pn4.add(jlab13); pn4.add(jlab14); pn4.add(jlab15); pn4.add(jtf13); pn4.add(jtf14); pn4.add(jtf15); pn4.add(jtf16); pn4.add(jtf17); pn4.add(jbtn1); pn4.add(jbtn2); pn4.add(jbtn3); pn4.add(jbtn4); // jfrm layout all GridBagLayout CalLayout = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); jfrm.setLayout(CalLayout); gbc.weightx = 1.0; //default 0.0 gbc.weighty = 1.0; //default 0.0 gbc.insets = new Insets(4, 4, 4, 4); // Add some space gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = 4; gbc.gridx = 0; gbc.gridy = 0; CalLayout.setConstraints(pn1, gbc); gbc.gridx = 0; gbc.gridy = 1; CalLayout.setConstraints(pn2, gbc); gbc.gridx = 0; gbc.gridy = 2; CalLayout.setConstraints(pn3, gbc); gbc.gridx = 0; gbc.gridy = 3; CalLayout.setConstraints(pn4, gbc); jfrm.add(pn1); jfrm.add(pn2); jfrm.add(pn3); jfrm.add(pn4); // Help Menu Bar JMenuBar jmb = new JMenuBar(); JMenu jmh = new JMenu("Help"); JMenuItem jmiAbout = new JMenuItem("About"); jmiAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(jfrm, "Name: Chi Square Calculator\n" + "Version: 1.0\n" + "Author: Felix Yanhui Fan\n" + "EMail: nolanfyh@gmail.com\n" + "Website: http://felixfan.github.io/ChiSquareCalculator\n"); } }); JMenuItem jmiLisence = new JMenuItem("Lisence"); jmiLisence.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(jfrm, "This program is licensed under the terms of \n" + "the GNU General Public License version 3 \n" + "Available online under: \n" + "http://www.gnu.org/licenses/gpl-3.0.html\n"); } }); jmh.add(jmiAbout); jmh.add(jmiLisence); jmb.add(Box.createHorizontalGlue()); // Aligning JMenu on the right corner of JMenuBar jmb.add(jmh); jfrm.setJMenuBar(jmb); jfrm.setVisible(true); }
From source file:flow.visibility.tapping.OpenDayLightUtils.java
/** Creating the Pane for Flow Entry */ public OpenDayLightUtils() { super("Installed Flow"); FlowtextArea = new JTextArea(50, 10); FlowtextArea.setEditable(false);/* w w w.j av a2 s . c o m*/ FlowtextArea.setFont(new Font("Courier New", Font.BOLD, 12)); PrintStream FlowprintStream = new PrintStream(new CustomOutputStream(FlowtextArea)); // re-assigns standard output stream and error output stream System.setOut(FlowprintStream); System.setErr(FlowprintStream); // creates the GUI setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(10, 10, 10, 10); constraints.anchor = GridBagConstraints.WEST; constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 2; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.weighty = 1.0; /** Adding the Pane into Frame */ scrollPane = new JScrollPane(FlowtextArea); this.add(scrollPane, constraints); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(400, 600); setLocationRelativeTo(null); // centers on screen }
From source file:Composite.java
public void init() { GridBagLayout layOut = new GridBagLayout(); getContentPane().setLayout(layOut);/*from w w w .j a v a 2 s .c o m*/ GridBagConstraints l = new GridBagConstraints(); l.weightx = 1.0; l.fill = GridBagConstraints.BOTH; l.gridwidth = GridBagConstraints.RELATIVE; alphaLabel = new JLabel(); alphaLabel.setText("Alphas"); Font newFont = getFont().deriveFont(1); alphaLabel.setFont(newFont); alphaLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(alphaLabel, l); getContentPane().add(alphaLabel); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(layOut); l.gridwidth = GridBagConstraints.REMAINDER; rulesLabel = new JLabel(); rulesLabel.setText("Rules"); newFont = getFont().deriveFont(1); rulesLabel.setFont(newFont); rulesLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(rulesLabel, l); getContentPane().add(rulesLabel); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = GridBagConstraints.RELATIVE; a.weightx = 1.0; a.fill = GridBagConstraints.BOTH; alphas = new JComboBox(); layOut.setConstraints(alphas, a); alphas.addItem("1.0"); alphas.addItem("0.75"); alphas.addItem("0.50"); alphas.addItem("0.25"); alphas.addItem("0.0"); alphas.addItemListener(this); getContentPane().add(alphas); a.gridwidth = GridBagConstraints.REMAINDER; rules = new JComboBox(); layOut.setConstraints(rules, a); rules.addItem("SRC"); rules.addItem("DST_IN"); rules.addItem("DST_OUT"); rules.addItem("DST_OVER"); rules.addItem("SRC_IN"); rules.addItem("SRC_OVER"); rules.addItem("SRC_OUT"); rules.addItem("CLEAR"); rules.addItemListener(this); getContentPane().add(rules); GridBagConstraints fC = new GridBagConstraints(); fC.fill = GridBagConstraints.BOTH; fC.weightx = 1.0; fC.weighty = 1.0; fC.gridwidth = GridBagConstraints.REMAINDER; comp = new CompPanel(); layOut.setConstraints(comp, fC); getContentPane().add(comp); validate(); }
From source file:com.std.StockPanel.java
public void setHistoricalData() { this.setLayout(new BorderLayout()); nameAndChangePanel.setLayout(new BoxLayout(nameAndChangePanel, BoxLayout.PAGE_AXIS)); nameAndChangePanel.add(nameLbl);//from ww w . java2 s .com nameAndChangePanel.add(priceChangePercentLbl); data = new Object[30][2]; String[] colnames = { "1", "2" }; GridBagConstraints c = new GridBagConstraints(); dataAndGraph.setLayout(new GridBagLayout()); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 1; c.insets = new Insets(0, 20, 0, 20); dataAndGraph.add(nameAndChangePanel, c); c.weightx = 0; c.weighty = 1; c.insets = new Insets(0, 20, 0, 0); //c.ipady = 20; c.gridx = 0; c.gridy = 1; remainingInfoTable = new StockTable(data, colnames); remainingInfoTable.setShowGrid(false); remainingInfoTable.setTableHeader(null); remainingInfoTable.setBackground(this.getBackground()); remainingInfoTable.setFocusable(false); remainingInfoTable.setColumnSelectionAllowed(false); remainingInfoTable.setRowSelectionAllowed(false); remainingInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataAndGraph.add(remainingInfoTable, c); this.add(dataAndGraph, BorderLayout.CENTER); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 2; //c.ipady = 20; c.gridx = 1; c.gridy = 0; dataAndGraph.add(chartPane, c); chartPane.setVisible(false); this.add(dataAndGraph, BorderLayout.CENTER); Test.show_hist_data(currentStock, b); currentStock.calculate_beta(sp500, 1200); nameLbl.setText(currentStock.get_name() + " (" + currentStock.get_symbol() + ")"); nameLbl.setFont(new Font(nameLbl.getName(), Font.BOLD, 24)); priceChangePercentLbl.setText(currentStock.get_price() + " "); String message = currentStock.get_change() + " " + currentStock.get_percent_change(); if (Double.parseDouble(currentStock.get_change()) < 0) priceChangePercentLbl.setText(String.format("<html>%s<font color='red'>%s</font></html>", priceChangePercentLbl.getText(), message)); else priceChangePercentLbl.setText(String.format("<html>%s<font color='green'>%s</font></html>", priceChangePercentLbl.getText(), message)); priceChangePercentLbl.setFont(new Font(priceChangePercentLbl.getName(), Font.PLAIN, 15)); data[0][0] = "Prev Close: " + currentStock.get_prev_close(); data[1][0] = "Open: " + currentStock.get_open_price(); data[2][0] = "Bid: " + currentStock.get_bid(); data[3][0] = "Ask: " + currentStock.get_ask(); data[4][0] = "One Year Target: " + currentStock.get_one_year_target(); data[5][0] = "Ebita: " + currentStock.get_ebitda(); data[0][1] = "Day Range: " + currentStock.get_days_range(); data[1][1] = "52 Week Range: " + currentStock.get_year_range(); data[2][1] = "Volume: " + currentStock.get_volume(); data[3][1] = "Average Daily Volume: " + currentStock.get_avg_daily_volume(); data[4][1] = "Market Cap: " + currentStock.get_market_cap(); data[5][1] = "P/E: " + currentStock.get_pe(); data[6][1] = "EPS: " + currentStock.get_earnings_per_share(); data[7][1] = "Dividend (Yield): " + currentStock.get_dividend_per_share() + "(" + currentStock.get_dividend_yield() + ")"; data[6][0] = "Reveune:" + currentStock.get_revenue(); data[7][0] = "Earnings Estimate: " + currentStock.get_earnings_estimate_current_year(); data[8][0] = "Beta: " + currentStock.get_beta(); data[8][1] = "PEG Ratio: " + currentStock.get_peg_ratio(); data[9][0] = "Short Ratio: " + currentStock.get_short_ratio(); data[11][0] = "50 Day MA: " + currentStock.get_fiftyday_moving_avg(); data[12][0] = "200 Day MA: " + currentStock.get_twohundredday_moving_avg(); if (currentStock.get_change_from_fiftyday_moving_avg() != null && currentStock.get_change_from_fiftyday_moving_avg().contains("-")) { data[13][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 50 Day MA: ", currentStock.get_change_from_fiftyday_moving_avg()); data[14][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 50 Day MA: ", currentStock.get_percent_change_from_fiftyday_moving_avg()); } else { data[13][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 50 Day MA: ", currentStock.get_change_from_fiftyday_moving_avg()); data[14][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 50 Day MA: ", currentStock.get_percent_change_from_fiftyday_moving_avg()); } if (currentStock.get_change_from_twohundredday_moving_avg() != null && currentStock.get_change_from_twohundredday_moving_avg().contains("-")) { data[15][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 200 Day MA: ", currentStock.get_change_from_twohundredday_moving_avg()); data[16][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 200 Day MA: ", currentStock.get_percent_change_from_twohundredday_moving_avg()); } else { data[15][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 200 Day MA: ", currentStock.get_change_from_twohundredday_moving_avg()); data[16][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 200 Day MA: ", currentStock.get_percent_change_from_twohundredday_moving_avg()); } data[17][0] = "Year High: " + currentStock.get_year_high(); data[18][0] = "Year Low: " + currentStock.get_year_low(); if (currentStock.get_change_from_year_high() != null && currentStock.get_change_from_year_high().contains("-")) { data[19][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Change: ", currentStock.get_change_from_year_high()); data[20][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Percent: ", currentStock.get_percent_change_from_year_high()); } else { data[19][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Change: ", currentStock.get_change_from_year_high()); data[20][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Percent: ", currentStock.get_percent_change_from_year_high()); } if (currentStock.get_change_from_year_low() != null && currentStock.get_change_from_year_low().contains("-")) { data[21][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Change: ", currentStock.get_change_from_year_low()); data[22][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Percent: ", currentStock.get_percent_change_from_year_low()); } else { data[21][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Change: ", currentStock.get_change_from_year_low()); data[22][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Percent: ", currentStock.get_percent_change_from_year_low()); } if (currentStock.get_five_day_change()[0] != null && currentStock.get_five_day_change()[0].contains("-")) data[11][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5D Change: ", currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")"); else data[11][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5D Change: ", currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")"); if (currentStock.get_one_month_change()[0] != null && currentStock.get_one_month_change()[0].contains("-")) data[12][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1M Change: ", currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")"); else data[12][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1M Change: ", currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")"); if (currentStock.get_three_month_change()[0] != null && currentStock.get_three_month_change()[0].contains("-")) data[13][1] = String.format("<html>%s<font color='red'>%s</font></html>", "3M Change: ", currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1] + ")"); else data[13][1] = String.format("<html>%s<font color='green'>%s</font></html>", "3M Change: ", currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1] + ")"); if (currentStock.get_six_month_change()[0] != null && currentStock.get_six_month_change()[0].contains("-")) data[14][1] = String.format("<html>%s<font color='red'>%s</font></html>", "6M Change: ", currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")"); else data[14][1] = String.format("<html>%s<font color='green'>%s</font></html>", "6M Change: ", currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")"); if (currentStock.get_ytd_change()[0] != null && currentStock.get_ytd_change()[0].contains("-")) data[15][1] = String.format("<html>%s<font color='red'>%s</font></html>", "YTD Change: ", currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")"); else data[15][1] = String.format("<html>%s<font color='green'>%s</font></html>", "YTD Change: ", currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")"); if (currentStock.get_one_year_change()[0] != null && currentStock.get_one_year_change()[0].contains("-")) data[16][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1Y Change: ", currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")"); else data[16][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1Y Change: ", currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")"); if (currentStock.get_five_year_change()[0] != null && currentStock.get_five_year_change()[0].contains("-")) data[17][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5Y Change: ", currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")"); else data[17][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5Y Change: ", currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")"); if (currentStock.get_ten_year_change()[0] != null && currentStock.get_ten_year_change()[0].contains("-")) data[18][1] = String.format("<html>%s<font color='red'>%s</font></html>", "10Y Change: ", currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")"); else data[18][1] = String.format("<html>%s<font color='green'>%s</font></html>", "10Y Change: ", currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")"); if (currentStock.get_max_year_change()[0] != null && currentStock.get_max_year_change()[0].contains("-")) data[19][1] = String.format("<html>%s<font color='red'>%s</font></html>", "Max Change: ", currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")"); else data[19][1] = String.format("<html>%s<font color='green'>%s</font></html>", "Max Change: ", currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")"); data[24][0] = "Earnings Est Next Quarter: " + currentStock.get_earnings_estimate_next_quarter(); data[25][0] = "Earnings Est Current Year: " + currentStock.get_earnings_estimate_current_year(); data[26][0] = "Earnings Est Next Year: " + currentStock.get_earnings_estimate_next_year(); data[24][1] = "P/E Est Current Year: " + currentStock.get_price_eps_estimate_current_year(); data[25][1] = "P/E Est Next Year: " + currentStock.get_price_eps_estimate_next_year(); remainingInfoTable.setFont(new Font(remainingInfoTable.getName(), Font.PLAIN, 15)); remainingInfoTable.packColumn(0, 4); remainingInfoTable.packColumn(1, 4); try { dataAndGraph.remove(chartPane); chartPane = new JTabbedPane(); chartPane.setVisible(true); ChartPanel intradayChart = new IntradayChart(currentStock).getChartPanel(); intradayChart.setPopupMenu(graphMenu); chartPane.addTab("1d", intradayChart); chartPane.setMnemonicAt(0, KeyEvent.VK_1); ChartPanel fivedayChart = new FiveDayChart(currentStock).getChartPanel(); fivedayChart.setPopupMenu(graphMenu); chartPane.addTab("5d", fivedayChart); chartPane.setMnemonicAt(0, KeyEvent.VK_2); ChartPanel onemonthChart = new OneMonthChart(currentStock).getChartPanel(); onemonthChart.setPopupMenu(graphMenu); chartPane.addTab("1m", onemonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_3); ChartPanel threemonthChart = new ThreeMonthChart(currentStock).getChartPanel(); threemonthChart.setPopupMenu(graphMenu); chartPane.addTab("3m", threemonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_4); ChartPanel sixmonthChart = new SixMonthChart(currentStock).getChartPanel(); sixmonthChart.setPopupMenu(graphMenu); chartPane.addTab("6m", sixmonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_5); ChartPanel ytdChart = new YTDChart(currentStock).getChartPanel(); ytdChart.setPopupMenu(graphMenu); chartPane.addTab("ytd", ytdChart); chartPane.setMnemonicAt(0, KeyEvent.VK_6); ChartPanel oneyearChart = new OneYearChart(currentStock).getChartPanel(); oneyearChart.setPopupMenu(graphMenu); chartPane.addTab("1y", oneyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_7); ChartPanel fiveyearChart = new FiveYearChart(currentStock).getChartPanel(); fiveyearChart.setPopupMenu(graphMenu); chartPane.addTab("5y", fiveyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_8); ChartPanel tenyearChart = new TenYearChart(currentStock).getChartPanel(); tenyearChart.setPopupMenu(graphMenu); chartPane.addTab("10y", tenyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_9); ChartPanel maxChart = new MaxChart(currentStock).getChartPanel(); maxChart.setPopupMenu(graphMenu); chartPane.addTab("max", maxChart); chartPane.setMnemonicAt(0, KeyEvent.VK_0); c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 2; //c.ipady = 20; c.gridx = 1; c.gridy = 0; dataAndGraph.add(chartPane, c); } catch (ParseException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } chartPane.revalidate(); chartPane.repaint(); revalidate(); repaint(); finished = true; }
From source file:TextDemo.java
public TextDemo() { super(new GridBagLayout()); textField = new JTextField(20); textField.addActionListener(this); textArea = new JTextArea(5, 20); textArea.setEditable(false);/*from w w w. j a va2 s . c o m*/ JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); //Add Components to this panel. GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; add(textField, c); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; add(scrollPane, c); }
From source file:org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.weightx = 1;//from w w w . j a v a 2 s . c om c.weighty = 1; c.fill = GridBagConstraints.BOTH; final List<ClasseCompte> classeComptes = new ArrayList<ClasseCompte>(); tabbedClasse = new JTabbedPane(); final SQLTable classeCompteTable = getTable().getBase().getTable("CLASSE_COMPTE"); final SQLSelect selClasse = new SQLSelect(); selClasse.addSelect(classeCompteTable.getField("ID")); selClasse.addSelect(classeCompteTable.getField("NOM")); selClasse.addSelect(classeCompteTable.getField("TYPE_NUMERO_COMPTE")); selClasse.addRawOrder("TYPE_NUMERO_COMPTE"); String reqClasse = selClasse.asString(); Object obClasse = getTable().getBase().getDataSource().execute(reqClasse, new ArrayListHandler()); List<Object[]> myListClasse = (List<Object[]>) obClasse; for (Object[] objTmp : myListClasse) { ClasseCompte ccTmp = new ClasseCompte(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString(), objTmp[2].toString()); classeComptes.add(ccTmp); tabbedClasse.add(ccTmp.getNom(), new JScrollPane(creerJTable(ccTmp))); } this.add(tabbedClasse, c); final SQLTableModifiedListener tListener = new SQLTableModifiedListener() { @Override public void tableModified(SQLTableEvent evt) { final int tabCount = tabbedClasse.getTabCount(); for (int i = 0; i < tabCount; i++) { tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i)))); } } }; final SQLTable tAxeAnalytique = getElement().getDirectory() .getElement(AxeAnalytiqueSQLElement.class).getTable(); tAxeAnalytique.addTableModifiedListener(tListener); final SQLTable tRepartitionAnalytique = getElement().getDirectory() .getElement(RepartitionAnalytiqueSQLElement.class).getTable(); tRepartitionAnalytique.addTableModifiedListener(tListener); final SQLTable tRepartitionAnalytiqueElement = getElement().getDirectory() .getElement(RepartitionAnalytiqueElementSQLElement.class).getTable(); tRepartitionAnalytiqueElement.addTableModifiedListener(tListener); final SQLTable tComptePCE = getElement().getDirectory().getElement(ComptePCESQLElement.class) .getTable(); tComptePCE.addTableModifiedListener(tListener); } }; }
From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java
private JPanel getJPanMain() { if (jPanMain == null) { jPanMain = new JPanel(); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.BOTH; gridBagConstraints1.gridx = 0;//from w ww .jav a 2 s . c o m gridBagConstraints1.gridy = 0; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.fill = GridBagConstraints.BOTH; gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 1; GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints3.gridx = 0; gridBagConstraints3.gridy = 2; jPanMain.add(getJScrollPaneImportSPDX(), gridBagConstraints1); jPanMain.add(getJPanelForOption(), gridBagConstraints2); jPanMain.add(getJButtonPanel(), gridBagConstraints3); addJPanSPDXLocation(null); } return jPanMain; }
From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java
/** * Creates a new {@link CollectArgsDialog} * /* w ww . j av a 2 s . c o m*/ * @param frame * the parent JFrame for the new {@link CollectArgsDialog} * @param statusBar * the {@link StatusBar} to update (can be null) * @param title * the title of the new {@link CollectArgsDialog} * @param xOptions * the {@link Collection} of {@link XOption}s for which to * collect user input */ public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title, final Collection<XOption<?>> xOptions) { super(frame, title, true); argComponents = new ArrayList<JComponent>(); final CollectArgsDialog dialog = this; JPanel panel = new JPanel(new GridBagLayout()); getContentPane().add(panel); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(3, 3, 3, 3); c.fill = GridBagConstraints.BOTH; int row = 0; for (XOption<?> xOption : xOptions) { if (xOption.getName() == null) { continue; } if (xOption.hasArg()) { JLabel label = new JLabel(xOption.getName()); JTextField textField = new JTextField(); textField.setName(xOption.getOpt()); textField.setToolTipText(xOption.getDescription()); argComponents.add(textField); c.gridx = 0; c.gridy = row; panel.add(label, c); c.gridx = 1; c.gridy = row; panel.add(textField, c); } else { JCheckBox checkBox = new JCheckBox(xOption.getName()); checkBox.setName(xOption.getOpt()); checkBox.setToolTipText(xOption.getDescription()); argComponents.add(checkBox); c.gridx = 0; c.gridy = row; panel.add(checkBox, c); } row++; } JPanel buttonPanel = new JPanel(); c.gridx = 1; c.gridy = row; panel.add(buttonPanel, c); JButton okButton = new JButton(new AbstractAction("OK") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.setMessage("building args..."); } ArrayList<String> args = new ArrayList<String>(); for (JComponent component : argComponents) { if (component instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) component; String opt = checkbox.getName(); if (checkbox.isSelected()) { args.add("-" + opt); } } if (component instanceof JTextField) { JTextField textField = (JTextField) component; String opt = textField.getName(); String text = textField.getText().trim(); if (!text.isEmpty()) { args.add("-" + opt); args.add("\"" + text + "\""); } } } if (statusBar != null) { statusBar.setMessage("parsing args..."); } try { Options options = new Options(); for (XOption<?> xOpt : xOptions) { options.addOption(xOpt); } XOption.parseArgs(options, args.toArray(new String[0])); dialog.success = true; } catch (ParseException e1) { e1.printStackTrace(); dialog.success = false; } if (statusBar != null) { statusBar.clearMessage(); } } }); buttonPanel.add(okButton); getRootPane().setDefaultButton(okButton); buttonPanel.add(new JButton(new AbstractAction("Cancel") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.clearMessage(); } } })); pack(); setLocationRelativeTo(frame); setVisible(true); }
From source file:com.github.pemapmodder.pocketminegui.gui.server.ConsolePanel.java
public ConsolePanel(ServerMainActivity activity) { this.activity = activity; setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10)); title = new JLabel("PocketMine-MP"); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.CENTER; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 0.1;//from w ww . j av a 2 s . co m add(title, c); stdout = new JEditorPane(); stdout.setContentType("text/html"); stdout.setText("<html><body style='font-family: monospace; color: #FFFFFF;'><p id='p'></p></body></html>"); doc = (HTMLDocument) stdout.getDocument(); para = doc.getElement("p"); // stdout.setEditable(false); // People NEED to see this to feel happy stdout.setForeground(Color.WHITE); stdout.setBackground(Color.BLACK); Style style = doc.getStyleSheet().addStyle(null, null); // style.addAttribute(StyleConstants.Foreground, Color.WHITE); // style.addAttribute(StyleConstants.Background, Color.RED); doc.setParagraphAttributes(para.getStartOffset(), 1, style, true); stdout.setBorder(BorderFactory.createDashedBorder(new Color(0x80, 0x80, 0x80))); c.gridy = 1; c.weightx = 0.9; c.weighty = 0.9; c.weighty = 0.6; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.NORTH; add(stdout, c); Timer timer = new Timer(50, e -> updateConsole()); timer.start(); }