List of usage examples for javax.swing JLabel setBounds
public void setBounds(int x, int y, int width, int height)
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_1.CFSecuritySwing.CFSecuritySwingSecDeviceAttrJPanel.java
public CFSecuritySwingSecDeviceAttrJPanel(ICFSecuritySwingSchema argSchema, ICFSecuritySecDeviceObj argFocus) { super();/*from w ww. j a v a 2s.co m*/ JLabel label; JComponent compo; CFJReferenceEditor reference; final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; setSwingFocusAsSecDevice(argFocus); final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 785; final int panelwidth = fieldx + fieldwidth + spacing; // temporary -- I think you have to have a panel bigger than the coordinates initially setSize(panelwidth, 100000); label = getSwingLabelContainerSecUser(); add(label); label.setBounds(labelx, y, labelwidth, height); reference = getSwingReferenceContainerSecUser(); add(reference); reference.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelDevName(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorDevName(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelPubKey(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorPubKey(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; // Now we can set the proper size based on the fields and references populated setSize(panelwidth, y); Dimension pfsz = new Dimension(panelwidth, y); setPreferredSize(pfsz); Dimension min = new Dimension(400, y); setMinimumSize(min); populateFields(); adjustComponentEnableStates(); swingIsInitializing = false; }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_1.CFSecuritySwing.CFSecuritySwingSecSessionAttrJPanel.java
public CFSecuritySwingSecSessionAttrJPanel(ICFSecuritySwingSchema argSchema, ICFSecuritySecSessionObj argFocus) { super();/*ww w .j av a2 s.com*/ JLabel label; JComponent compo; CFJReferenceEditor reference; final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; setSwingFocusAsSecSession(argFocus); final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 785; final int panelwidth = fieldx + fieldwidth + spacing; // temporary -- I think you have to have a panel bigger than the coordinates initially setSize(panelwidth, 100000); label = getSwingLabelContainerSecUser(); add(label); label.setBounds(labelx, y, labelwidth, height); reference = getSwingReferenceContainerSecUser(); add(reference); reference.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelParentSecProxy(); add(label); label.setBounds(labelx, y, labelwidth, height); reference = getSwingReferenceParentSecProxy(); add(reference); reference.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelSecSessionId(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorSecSessionId(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelSecDevName(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorSecDevName(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelStart(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorStart(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelFinish(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorFinish(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; // Now we can set the proper size based on the fields and references populated setSize(panelwidth, y); Dimension pfsz = new Dimension(panelwidth, y); setPreferredSize(pfsz); Dimension min = new Dimension(400, y); setMinimumSize(min); populateFields(); adjustComponentEnableStates(); swingIsInitializing = false; }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_1.CFSecuritySwing.CFSecuritySwingSecUserAttrJPanel.java
public CFSecuritySwingSecUserAttrJPanel(ICFSecuritySwingSchema argSchema, ICFSecuritySecUserObj argFocus) { super();/*from w ww . j a v a 2 s.c o m*/ JLabel label; JComponent compo; CFJReferenceEditor reference; final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; setSwingFocusAsSecUser(argFocus); final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 785; final int panelwidth = fieldx + fieldwidth + spacing; // temporary -- I think you have to have a panel bigger than the coordinates initially setSize(panelwidth, 100000); label = getSwingLabelLookupDefDev(); add(label); label.setBounds(labelx, y, labelwidth, height); reference = getSwingReferenceLookupDefDev(); add(reference); reference.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelSecUserId(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorSecUserId(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelEMailAddress(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorEMailAddress(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelHtmlPwHexHash(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorHtmlPwHexHash(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelHtmlResetPwHexHash(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorHtmlResetPwHexHash(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelAppPwHexHash(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorAppPwHexHash(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelAppResetPwHexHash(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorAppResetPwHexHash(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelMailtoEMailAddress(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorMailtoEMailAddress(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; // Now we can set the proper size based on the fields and references populated setSize(panelwidth, y); Dimension pfsz = new Dimension(panelwidth, y); setPreferredSize(pfsz); Dimension min = new Dimension(400, y); setMinimumSize(min); populateFields(); adjustComponentEnableStates(); swingIsInitializing = false; }
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * creates a label with the reader/* w ww. j a v a 2 s . co m*/ * * @return reader label */ private Component getReader() { JLabel reader = new JLabel(); String filename = propsConfig.getString("ReaderImage"); URL fileurl = ResourceLocator.getURL(filename, defaultfilename, this.getClass()); reader.setIcon(new ImageIcon(fileurl)); reader.setBounds( getProperty("AntennaPaneX") + (getProperty("AntennaPaneWidth") - getProperty("ReaderWidth")) / 2, getProperty("FramePadding"), getProperty("ReaderWidth"), getProperty("ReaderHeight")); return reader; }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates a label with the reader/*from ww w. ja v a2 s . com*/ * * @return reader label */ private Component getReader() { JLabel reader = new JLabel(); String filename = props.getProperty("ReaderImage"); reader.setIcon(new ImageIcon(this.getClass().getResource(filename))); reader.setBounds( getProperty("AntennaPaneX") + (getProperty("AntennaPaneWidth") - getProperty("ReaderWidth")) / 2, getProperty("FramePadding"), getProperty("ReaderWidth"), getProperty("ReaderHeight")); return reader; }
From source file:org.coronastreet.gpxconverter.AccountManager.java
public AccountManager(MainWindow window) { setTitle("Account Settings"); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 450, 199);/* w ww . j av a2s . c om*/ frmAccounts = new JPanel(); frmAccounts.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(frmAccounts); frmAccounts.setLayout(null); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(5, 5, 424, 118); frmAccounts.add(tabbedPane); JPanel stravaPanel = new JPanel(); stravaPanel.setLayout(null); tabbedPane.addTab("Strava", stravaPanel); strava_username = new JTextField(); strava_username.setBounds(79, 11, 235, 20); stravaPanel.add(strava_username); strava_username.setColumns(10); JLabel lblUsername = new JLabel("Username:"); lblUsername.setBounds(10, 14, 69, 14); stravaPanel.add(lblUsername); JLabel lblPassword = new JLabel("Password:"); lblPassword.setBounds(10, 45, 69, 14); stravaPanel.add(lblPassword); strava_password = new JPasswordField(); strava_password.setColumns(10); strava_password.setBounds(79, 42, 235, 20); stravaPanel.add(strava_password); JPanel rwgpsPanel = new JPanel(); rwgpsPanel.setLayout(null); tabbedPane.addTab("RideWithGPS", rwgpsPanel); JLabel label = new JLabel("Username:"); label.setBounds(10, 14, 69, 14); rwgpsPanel.add(label); rwgps_username = new JTextField(); rwgps_username.setColumns(10); rwgps_username.setBounds(79, 11, 235, 20); rwgpsPanel.add(rwgps_username); rwgps_password = new JPasswordField(); rwgps_password.setColumns(10); rwgps_password.setBounds(79, 42, 235, 20); rwgpsPanel.add(rwgps_password); JLabel label_1 = new JLabel("Password:"); label_1.setBounds(10, 45, 69, 14); rwgpsPanel.add(label_1); JPanel garminPanel = new JPanel(); garminPanel.setLayout(null); tabbedPane.addTab("Garmin Connect", garminPanel); JLabel label_2 = new JLabel("Username:"); label_2.setBounds(10, 14, 69, 14); garminPanel.add(label_2); garmin_username = new JTextField(); garmin_username.setColumns(10); garmin_username.setBounds(79, 11, 235, 20); garminPanel.add(garmin_username); garmin_password = new JPasswordField(); garmin_password.setColumns(10); garmin_password.setBounds(79, 42, 235, 20); garminPanel.add(garmin_password); JLabel label_3 = new JLabel("Password:"); label_3.setBounds(10, 45, 69, 14); garminPanel.add(label_3); loadAccountPrefs(); JButton btnSave = new JButton("SAVE"); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { saveAccountInfo(); } }); btnSave.setBounds(106, 127, 89, 23); frmAccounts.add(btnSave); JButton btnCancel = new JButton("CANCEL"); btnCancel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { cancel(); } }); btnCancel.setBounds(242, 127, 89, 23); frmAccounts.add(btnCancel); }
From source file:org.eclipse.om2m.ipe.sample.gui.GUI.java
/** * Creates the frame.// w ww. j a va2 s . co m */ public GUI() { setLocationByPlatform(true); setVisible(false); setResizable(false); setTitle("Sample Simulated IPE"); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPanel); contentPanel.setLayout(null); // Lamp0 Switcher0 JPanel panel_Lamp0 = new JPanel(); panel_Lamp0.setBounds(10, 5, 319, 260); contentPanel.add(panel_Lamp0); panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp0.setLayout(null); LABEL_LAMP_0.setIcon(iconLampOFF); LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_0.setBounds(10, 9, 149, 240); panel_Lamp0.add(LABEL_LAMP_0); // Lamp0 Switch Button JButton button_Lamp0 = new JButton(); button_Lamp0.setOpaque(false); button_Lamp0.setPressedIcon(iconButtonON); button_Lamp0.setIcon(iconButtonOFF); button_Lamp0.setBounds(187, 44, 122, 155); panel_Lamp0.add(button_Lamp0); button_Lamp0.setMinimumSize(new Dimension(30, 23)); button_Lamp0.setMaximumSize(new Dimension(30, 23)); button_Lamp0.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher0 = new JLabel("Switch LAMP_0"); labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher0.setFocusCycleRoot(true); labelSwitcher0.setBorder(null); labelSwitcher0.setAutoscrolls(true); labelSwitcher0.setBounds(187, 199, 118, 29); panel_Lamp0.add(labelSwitcher0); // Listener for Lamp0 Switch Button button_Lamp0.addActionListener(new java.awt.event.ActionListener() { // Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp0 State new Thread() { public void run() { // Send switch request to switch lamp0 state SampleMonitor.switchLamp(LAMP_0); } }.start(); } }); // Lamp1 Switcher 1 JPanel panel_Lamp1 = new JPanel(); panel_Lamp1.setBounds(10, 271, 319, 260); contentPanel.add(panel_Lamp1); panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp1.setLayout(null); LABEL_LAMP_1.setIcon(iconLampOFF); LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_1.setBounds(10, 9, 154, 240); panel_Lamp1.add(LABEL_LAMP_1); // Lamp1 Switch Button JButton button_Lamp1 = new JButton(); button_Lamp1.setOpaque(false); button_Lamp1.setPressedIcon(iconButtonON); button_Lamp1.setIcon(iconButtonOFF); button_Lamp1.setBounds(187, 44, 122, 156); panel_Lamp1.add(button_Lamp1); button_Lamp1.setMinimumSize(new Dimension(30, 23)); button_Lamp1.setMaximumSize(new Dimension(30, 23)); button_Lamp1.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher1 = new JLabel("Switch LAMP_1"); labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher1.setFocusCycleRoot(true); labelSwitcher1.setBorder(null); labelSwitcher1.setAutoscrolls(true); labelSwitcher1.setBounds(187, 199, 118, 29); panel_Lamp1.add(labelSwitcher1); // Listener for Lamp1 Switch Button button_Lamp1.addActionListener(new java.awt.event.ActionListener() { //Switch Button clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp1 State new Thread() { public void run() { // Send switch request to switch lamp1 state SampleMonitor.switchLamp(LAMP_1); } }.start(); } }); // Switcher All lamps JButton buttonAllLamp = new JButton(); buttonAllLamp.setOpaque(false); buttonAllLamp.setPressedIcon(iconButtonON); buttonAllLamp.setIcon(iconButtonOFF); buttonAllLamp.setBounds(339, 190, 145, 168); contentPanel.add(buttonAllLamp); buttonAllLamp.setMinimumSize(new Dimension(30, 23)); buttonAllLamp.setMaximumSize(new Dimension(30, 23)); buttonAllLamp.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitchAll = new JLabel("Switch All"); labelSwitchAll.setAutoscrolls(true); labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitchAll.setFocusCycleRoot(true); labelSwitchAll.setBorder(null); labelSwitchAll.setBounds(371, 369, 85, 29); contentPanel.add(labelSwitchAll); // Listener of Switch all Button buttonAllLamp.addActionListener(new java.awt.event.ActionListener() { // Switch Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change all lamps states new Thread() { public void run() { // Send switch all request to create a content with the current State SampleMonitor.switchAll(); } }.start(); } }); lampObserver = new SampleModel.LampObserver() { @Override public void onLampStateChange(String lampId, boolean state) { setLabel(lampId, state); } }; SampleModel.addObserver(lampObserver); }
From source file:org.eclipse.om2m.ipu.sample.GUI.java
/** * Creates the frame.//from www. ja va2 s . co m */ public GUI() { setLocationByPlatform(true); setResizable(false); setTitle("Sample Simulated IPU"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPanel); contentPanel.setLayout(null); // Lamp0 Switcher0 JPanel panel_Lamp0 = new JPanel(); panel_Lamp0.setBounds(10, 5, 319, 260); contentPanel.add(panel_Lamp0); panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp0.setLayout(null); LABEL_LAMP_0.setIcon(iconLampOFF); LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_0.setBounds(10, 9, 149, 240); panel_Lamp0.add(LABEL_LAMP_0); // Lamp0 Switch Button JButton button_Lamp0 = new JButton(); button_Lamp0.setOpaque(false); button_Lamp0.setPressedIcon(iconButtonON); button_Lamp0.setIcon(iconButtonOFF); button_Lamp0.setBounds(187, 44, 122, 155); panel_Lamp0.add(button_Lamp0); button_Lamp0.setMinimumSize(new Dimension(30, 23)); button_Lamp0.setMaximumSize(new Dimension(30, 23)); button_Lamp0.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher0 = new JLabel("Switch LAMP_0"); labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher0.setFocusCycleRoot(true); labelSwitcher0.setBorder(null); labelSwitcher0.setAutoscrolls(true); labelSwitcher0.setBounds(187, 199, 118, 29); panel_Lamp0.add(labelSwitcher0); // Listener for Lamp0 Switch Button button_Lamp0.addActionListener(new java.awt.event.ActionListener() { // Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp0 State new Thread() { public void run() { // Send switch request to switch lamp0 state Switchs.switchLamp(LAMP_0, !SampleMonitor.LAMPS.get(LAMP_0).getState()); } }.start(); } }); // Lamp1 Switcher 1 JPanel panel_Lamp1 = new JPanel(); panel_Lamp1.setBounds(10, 271, 319, 260); contentPanel.add(panel_Lamp1); panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp1.setLayout(null); LABEL_LAMP_1.setIcon(iconLampOFF); LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_1.setBounds(10, 9, 154, 240); panel_Lamp1.add(LABEL_LAMP_1); // Lamp1 Switch Button JButton button_Lamp1 = new JButton(); button_Lamp1.setOpaque(false); button_Lamp1.setPressedIcon(iconButtonON); button_Lamp1.setIcon(iconButtonOFF); button_Lamp1.setBounds(187, 44, 122, 156); panel_Lamp1.add(button_Lamp1); button_Lamp1.setMinimumSize(new Dimension(30, 23)); button_Lamp1.setMaximumSize(new Dimension(30, 23)); button_Lamp1.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher1 = new JLabel("Switch LAMP_1"); labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher1.setFocusCycleRoot(true); labelSwitcher1.setBorder(null); labelSwitcher1.setAutoscrolls(true); labelSwitcher1.setBounds(187, 199, 118, 29); panel_Lamp1.add(labelSwitcher1); // Listener for Lamp1 Switch Button button_Lamp1.addActionListener(new java.awt.event.ActionListener() { //Switch Button clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp1 State new Thread() { public void run() { // Send switch request to switch lamp1 state Switchs.switchLamp(LAMP_1, !SampleMonitor.LAMPS.get(LAMP_1).getState()); } }.start(); } }); // Switcher All lamps JButton buttonAllLamp = new JButton(); buttonAllLamp.setOpaque(false); buttonAllLamp.setPressedIcon(iconButtonON); buttonAllLamp.setIcon(iconButtonOFF); buttonAllLamp.setBounds(339, 190, 145, 168); contentPanel.add(buttonAllLamp); buttonAllLamp.setMinimumSize(new Dimension(30, 23)); buttonAllLamp.setMaximumSize(new Dimension(30, 23)); buttonAllLamp.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitchAll = new JLabel("Switch All"); labelSwitchAll.setAutoscrolls(true); labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitchAll.setFocusCycleRoot(true); labelSwitchAll.setBorder(null); labelSwitchAll.setBounds(371, 369, 85, 29); contentPanel.add(labelSwitchAll); // Listener of Switch all Button buttonAllLamp.addActionListener(new java.awt.event.ActionListener() { // Switch Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change all lamps states new Thread() { public void run() { // Send switch all request to create a content with the current State Switchs.switchAll(!(SampleMonitor.LAMPS.get(LAMP_0).getState() && SampleMonitor.LAMPS.get(LAMP_1).getState())); } }.start(); } }); }
From source file:org.mc.okapi.Correlation.java
/** * Create the dialog.//from ww w .j a va2s . c o m */ public Correlation() { setTitle("Correlation"); setIconImage(Toolkit.getDefaultToolkit().getImage("src/images/ico/extra/science_32.png")); setBounds(100, 100, 450, 140); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(null); JLabel lblIx = new JLabel("X:"); lblIx.setBounds(110, 11, 46, 14); contentPanel.add(lblIx); JLabel lblIy = new JLabel("Y:"); lblIy.setBounds(286, 11, 46, 14); contentPanel.add(lblIy); JLabel lblX = new JLabel("X Label:"); lblX.setBounds(83, 44, 88, 14); contentPanel.add(lblX); tfX = new JTextField(); tfX.setBounds(128, 41, 104, 23); contentPanel.add(tfX); tfX.setColumns(10); JLabel lblY = new JLabel("Y Label:"); lblY.setBounds(260, 44, 82, 14); contentPanel.add(lblY); tfY = new JTextField(); tfY.setBounds(307, 41, 104, 23); contentPanel.add(tfY); tfY.setColumns(10); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { double[] X = new double[data.getRowCount()]; double[] Y = new double[data.getRowCount()]; for (int i = 0; i < X.length; i++) { X[i] = Double.valueOf(datmat.getColumnElements(cbX.getSelectedIndex())[i]); } for (int i = 0; i < Y.length; i++) { Y[i] = Double.valueOf(datmat.getColumnElements(cbY.getSelectedIndex())[i]); } Plot plotxy = new Plot(X, Y, tfX.getText(), tfY.getText(), "(" + tfX.getText() + "," + tfY.getText() + ")", "Correlation", "r=" + new PearsonsCorrelation().correlation(X, Y)); plotxy.pack(); plotxy.setVisible(true); //System.out.println(Arrays.toString(datmat.getColumnElements(1))); //Runtime.getRuntime().exec("CMD /C start R CMD BATCH --no-save --no-restore --slave -f src/r/cor.R \"--args inFile='"+inFile+"' outFile='"+outPath+"/"+tfoutfile.getText()+"' iX='"+tfiX.getText()+"' iY='"+tfiY.getText()+"'\" "); //Runtime.getRuntime().exec("CMD /C start Rscript cor.R '"+inFile+"' '"+outPath+"/"+tfoutfile.getText()+"' "+tfiX.getText()+" "+tfiY.getText()); //Rsession ss = Rsession.newInstanceTry(System.out,null); //Rsession rs = Rsession.newInstanceTry(System.out,RserverConf.parse("R://localhost")); /* Rsession rs = Rsession.newInstanceTry(System.out,RserverConf.parse("R://localhost")); rs.set("df", data); //create R variable from java one rs.save(new File("save.Rdata"), "df"); //save variables in .Rdata*/ /*RConnection c; try { c = new RConnection(); double[] dataX = {1,4,5,8}; double[] dataY = {1,7,9,12}; c.assign("x", dataX); c.assign("y", dataY); //c.assign("z", datmat.getColumnElements(1)); //String[] d= c.eval("c(z)").asStrings(); //System.out.println(d[1].toString()); System.out.println(Arrays.toString(datmat.getColumnElements(1))); } catch (RserveException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (REngineException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }*/ try { Thread.sleep(3000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); okButton.setBounds(175, 72, 57, 23); contentPanel.add(okButton); okButton.setActionCommand("OK"); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { dispose(); } }); cancelButton.setBounds(242, 72, 74, 23); contentPanel.add(cancelButton); cancelButton.setActionCommand("Cancel"); } cbX = new JComboBox(); cbX.setBounds(128, 8, 104, 20); contentPanel.add(cbX); cbY = new JComboBox(); cbY.setBounds(307, 8, 104, 20); contentPanel.add(cbY); }
From source file:org.monome.pages.MIDIKeyboardPage.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from ww w . j a v a 2 s . c o m*/ JPanel panel = new JPanel(); panel.setLayout(null); panel.setPreferredSize(new java.awt.Dimension(220, 240)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": " + pageName); panel.add(pageNameLBL); pageNameLBL.setBounds(0, 0, 245, 14); JLabel midiout = new JLabel("<html>MIDI Out: " + this.midiDeviceName + "</html>"); panel.add(midiout); midiout.setBounds(20, 25, 200, 35); JLabel scalelbl = new JLabel("Scales:"); panel.add(scalelbl); scalelbl.setBounds(20, 75, 100, 14); resetScales = new JButton("Reset Scales"); resetScales.addActionListener(this); panel.add(resetScales); resetScales.setBounds(80, 75, 120, 20); scaleTF1 = new JTextField(); scaleTF2 = new JTextField(); scaleTF3 = new JTextField(); scaleTF4 = new JTextField(); scaleTF5 = new JTextField(); scaleTF6 = new JTextField(); panel.add(scaleTF1); scaleTF1.setBounds(20, 100, 80, 20); panel.add(scaleTF2); scaleTF2.setBounds(120, 100, 80, 20); panel.add(scaleTF3); scaleTF3.setBounds(20, 125, 80, 20); panel.add(scaleTF4); scaleTF4.setBounds(120, 125, 80, 20); panel.add(scaleTF5); scaleTF5.setBounds(20, 150, 80, 20); panel.add(scaleTF6); scaleTF6.setBounds(120, 150, 80, 20); //populate the text fields with the selected scales getScales(); midiOutButton = new JButton("Set MIDI Output"); midiOutButton.addActionListener(this); panel.add(midiOutButton); midiOutButton.setBounds(20, 175, 180, 20); updatePrefsButton = new JButton("Update Preferences"); updatePrefsButton.addActionListener(this); panel.add(this.updatePrefsButton); updatePrefsButton.setBounds(20, 200, 180, 20); this.panel = panel; return panel; }