Refine search
JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MainPanel()); f.pack(); f.setLocationRelativeTo(null); Control control = new Control(model, view); JLabel label = new JLabel("Guess what color!", JLabel.CENTER); this.add(label, BorderLayout.NORTH); this.add(view, BorderLayout.CENTER); this.add(control, BorderLayout.SOUTH); this.setIcon(new ColorIcon(16, piece.color));
JToolBar tools = new JToolBar(); tools.setFloatable(false); gui.add(tools, BorderLayout.PAGE_START); tools.add(new JButton("New")); // TODO - add functionality! tools.add(new JButton("Save")); // TODO - add functionality! tools.add(new JButton("Restore")); // TODO - add functionality! tools.addSeparator(); b.setIcon(icon); if ((jj % 2 == 1 && ii % 2 == 1)
import javax.swing.*; import java.awt.*; public class IconButton{ public static void main(String[] args){ JFrame frame = new JFrame("Icon on button"); JButton button = new JButton("Image button fro Sectona"); Icon imgicon = new ImageIcon("sectona.gif"); JPanel panel = new JPanel(); button.setIcon(imgicon); panel.add(button); frame.add(panel, BorderLayout.NORTH); frame.setSize(400, 400); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Button extends JFrame { private JButton button; private JPanel p; public Button() { super("The title"); p = new JPanel(new BorderLayout()); button = new JButton(); ImageIcon icon = new ImageIcon(getClass().getResource("button2.jpg")); button.setIcon(icon); button.setDisabledIcon(icon); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400, 400); p.add(button); add(p); } }
import java.awt.Dimension; import javax.swing.*; public class LeftSide { public LeftSide() { JFrame frame = new JFrame("Button"); JPanel panel = new JPanel(); JButton button = new JButton("Submit"); button.setPreferredSize(new Dimension(200, 30)); button.setIcon(new ImageIcon(this.getClass().getResource("submit.gif"))); button.setHorizontalAlignment(SwingConstants.LEFT); panel.add(button); frame.add(panel); frame.setVisible(true); } public static void main(String[] args) { new LeftSide(); } }
}catch(Exception e){System.err.println("Error: " + e.getMessage());} textpanel.setBounds(100, 222, 593, 528); add(textpanel); button_1.setIcon(new ImageIcon("D:\\Facultate\\anul 2\\Java Workspace\\Encyclopedia\\src\\icons\\back.png")); button_1.setEnabled(false); button_1.setBounds(10, 700, 50, 50); add(button_1); button.setIcon(new ImageIcon("D:\\Facultate\\anul 2\\Java Workspace\\Encyclopedia\\src\\icons\\next.png")); button.setBounds(740, 700, 50, 50); add(button);
g2.fillOval(x, y, width, height); g2.dispose(); circleButton.setIcon(new ImageIcon(circleImg)); g2.fillRect(x, y, width, height); g2.dispose(); squareButton.setIcon(new ImageIcon(squareImg)); add(circleButton); add(squareButton); JFrame frame = new JFrame("ImageButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new ImageButton()); frame.pack(); frame.setLocationRelativeTo(null);
frame.add(middlePanel, BorderLayout.CENTER); middle[y][x] = b; b.setMargin(zeroMargin); b.setIcon(new ImageIcon(bi)); middlePanel.add(b); JPanel colorButtonsConstrain = new JPanel(new FlowLayout()); colorButtons.setBorder(new EmptyBorder(65, 5, 5, 0)); colorButtonsConstrain.add(colorButtons); frame.add(colorButtonsConstrain, BorderLayout.LINE_START); Color[] colors = { JButton b = new JButton(); b.setMargin(zeroMargin); b.setIcon(new ImageIcon(bi)); colours[y] = b; b.setBackground(colors[y]);
myMenu.setIcon(icon1); myMenu.setRolloverIcon(icon2); myMenu.setRolloverEnabled(true); myButton.setRolloverIcon(icon2); JPanel btnPanel = new JPanel(); btnPanel.add(myButton); frame.add(btnPanel, BorderLayout.CENTER); frame.setPreferredSize(new Dimension(400, 300)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);