Java Code Examples for javax.swing.border.LineBorder

The following examples show how to use javax.swing.border.LineBorder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void addCustomEntriesToTable(UIDefaults table) {

    Border blackLineBorder =
            new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder =
            new BorderUIResource(new LineBorder(getWhite()));

    Object textBorder = new BorderUIResource(new CompoundBorder(
            blackLineBorder,
            new BasicBorders.MarginBorder()));

    table.put("ToolTip.border", blackLineBorder);
    table.put("TitledBorder.border", blackLineBorder);
    table.put("Table.focusCellHighlightBorder", whiteLineBorder);
    table.put("Table.focusCellForeground", getWhite());

    table.put("TextField.border", textBorder);
    table.put("PasswordField.border", textBorder);
    table.put("TextArea.border", textBorder);
    table.put("TextPane.font", textBorder);


}
 
Example 2
private void run() {
    JFrame frame = new JFrame("Test Character (no crash = PASS)");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JLabel label = new JLabel("(empty)");
    label.setSize(400, 100);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(new Font("Lucida Bright", Font.PLAIN, 12));
    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
       label.setText(Character.toString('\u0DDD'));
    } else {
    JButton button = new JButton("Set Char x0DDD");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
       label.setText(Character.toString('\u0DDD'));
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 3
Source Project: ghidra   Source File: FcgVertex.java    License: Apache License 2.0 6 votes vote down vote up
private void buildUi() {

		createPaints();

		// init the components
		String truncated = StringUtilities.trimMiddle(getName(), MAX_NAME_LENGTH);
		nameLabel.setText(truncated);
		buildVertexShape();

		// calculate the needed size
		layeredPane = new JLayeredPane();
		Border border = createDebugBorder(new LineBorder(Color.YELLOW.darker(), 1));
		layeredPane.setBorder(border);

		updateLayeredPaneSize();

		// layout the components
		addVertexShape();
		addToggleButtons();
		addNameLabel();

		buildFullShape();
	}
 
Example 4
Source Project: arcusplatform   Source File: CapabilityTableCellEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean stopCellEditing() {
   if(current == null) {
      return true;
   }
   try {
      boolean stopped = current.stopCellEditing();
      if(stopped) {
         current = null;
      }
      return stopped;
   }
   catch(Exception e) {
      JComponent c = (JComponent) getComponent();
      c.setBorder(new LineBorder(Color.RED));
      Oculus.warn("Invalid value for cell: " + e.getMessage() + "\nClick 'esc' to stop editing", e);
      return false;
   }
}
 
Example 5
@Override
public void addCustomEntriesToTable(UIDefaults table) {

    Border blackLineBorder =
            new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder =
            new BorderUIResource(new LineBorder(getWhite()));

    Object textBorder = new BorderUIResource(new CompoundBorder(
            blackLineBorder,
            new BasicBorders.MarginBorder()));

    table.put("ToolTip.border", blackLineBorder);
    table.put("TitledBorder.border", blackLineBorder);
    table.put("Table.focusCellHighlightBorder", whiteLineBorder);
    table.put("Table.focusCellForeground", getWhite());

    table.put("TextField.border", textBorder);
    table.put("PasswordField.border", textBorder);
    table.put("TextArea.border", textBorder);
    table.put("TextPane.font", textBorder);


}
 
Example 6
private void run() {
    JFrame frame = new JFrame("Test Character (no crash = PASS)");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JLabel label = new JLabel("(empty)");
    label.setSize(400, 100);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(new Font("Lucida Bright", Font.PLAIN, 12));
    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
       label.setText(Character.toString('\u0DDD'));
    } else {
    JButton button = new JButton("Set Char x0DDD");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
       label.setText(Character.toString('\u0DDD'));
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 7
Source Project: jdk8u60   Source File: ContrastMetalTheme.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void addCustomEntriesToTable(UIDefaults table) {

    Border blackLineBorder =
            new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder =
            new BorderUIResource(new LineBorder(getWhite()));

    Object textBorder = new BorderUIResource(new CompoundBorder(
            blackLineBorder,
            new BasicBorders.MarginBorder()));

    table.put("ToolTip.border", blackLineBorder);
    table.put("TitledBorder.border", blackLineBorder);
    table.put("Table.focusCellHighlightBorder", whiteLineBorder);
    table.put("Table.focusCellForeground", getWhite());

    table.put("TextField.border", textBorder);
    table.put("PasswordField.border", textBorder);
    table.put("TextArea.border", textBorder);
    table.put("TextPane.font", textBorder);


}
 
Example 8
Source Project: jdk8u60   Source File: TestSinhalaChar.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void run() {
    JFrame frame = new JFrame("Test Character (no crash = PASS)");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JLabel label = new JLabel("(empty)");
    label.setSize(400, 100);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(new Font("Lucida Bright", Font.PLAIN, 12));
    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
       label.setText(Character.toString('\u0DDD'));
    } else {
    JButton button = new JButton("Set Char x0DDD");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
       label.setText(Character.toString('\u0DDD'));
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 9
Source Project: nanoleaf-desktop   Source File: Main.java    License: MIT License 6 votes vote down vote up
private void initWindow() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
    if (getUserWindowWidth() != DEFAULT_WINDOW_WIDTH ||
            getUserWindowHeight() != DEFAULT_WINDOW_HEIGHT) {
        setSize(getUserWindowWidth(), getUserWindowHeight());
    }
    setUndecorated(true);
    URL iconPath = getClass().getResource("/images/icon.png");
    ImageIcon imageIcon = new ImageIcon(iconPath);
    Image image = imageIcon.getImage();
    setIconImage(image);

    contentPane = new JPanel();
    contentPane.setBackground(Color.DARK_GRAY);
    contentPane.setBorder(new LineBorder(new Color(128, 128, 128), 3, true));
    setContentPane(contentPane);
    contentPane.setLayout(new MigLayout("", "[-27.00,grow][755.00,grow]",
                                        "[][120px:120px,grow][300px:400px,grow][100px:400px,grow]"));
}
 
Example 10
Source Project: nanoleaf-desktop   Source File: SingleEntryDialog.java    License: MIT License 6 votes vote down vote up
public SingleEntryDialog(Component parent, String entryLabel,
		String buttonLabel, ActionListener buttonListener)
{
	super();
	
	entry = new JTextField(entryLabel);
	entry.setForeground(Color.WHITE);
	entry.setBackground(Color.DARK_GRAY);
	entry.setBorder(new LineBorder(Color.GRAY));
	entry.setCaretColor(Color.WHITE);
	entry.setFont(new Font("Tahoma", Font.PLAIN, 22));
	entry.addFocusListener(new TextFieldFocusListener(entry));
	contentPanel.add(entry, "cell 0 1, grow, gapx 2 2");
	
	JButton btnConfirm = new ModernButton(buttonLabel);
	btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnConfirm.addActionListener(buttonListener);
	contentPanel.add(btnConfirm, "cell 0 3, alignx center");
	
	JLabel spacer = new JLabel(" ");
	contentPanel.add(spacer, "cell 0 4");
	
	finalize(parent);
	
	btnConfirm.requestFocus();
}
 
Example 11
Source Project: nanoleaf-desktop   Source File: BasicDialog.java    License: MIT License 6 votes vote down vote up
public BasicDialog()
{
	setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	setUndecorated(true);
	contentPanel.setLayout(new MigLayout("", "[432.00,grow]", "[][]"));
	contentPanel.setBackground(Color.DARK_GRAY);
	contentPanel.setBorder(new LineBorder(new Color(128, 128, 128), 2));
	setContentPane(contentPanel);
	
	WindowDragListener wdl = new WindowDragListener(50);
	addMouseListener(wdl);
	addMouseMotionListener(wdl);
	
	CloseButton btnClose = new CloseButton(this, JFrame.DISPOSE_ON_CLOSE);
	contentPanel.add(btnClose, "cell 0 0,alignx right,gapx 0 15");
}
 
Example 12
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 6 votes vote down vote up
public PartRowPanel(PartType type) {
	_type = type;
	_typeCombo = new PartTypeComboBox();
	_typeCombo.setSelectedItem(_type.getName());
	JButton addButton = new JButton(IconsTable.ICON_PLUS);
	addButton.setActionCommand("+id");
	addButton.addActionListener(new PacketEditorActionListener());
	JButton delButton = new JButton(IconsTable.ICON_MINUS);
	delButton.setActionCommand("-id");
	delButton.addActionListener(new PacketEditorActionListener());
	this.add(_typeCombo);
	this.add(addButton);
	this.add(delButton);
	this.setBackground(Color.CYAN);
	this.setBorder(new LineBorder(Color.BLACK));
}
 
Example 13
Source Project: JavaFX-Tutorial-Codes   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
private void addIcon(MaterialDesign icon) {
    JPanel panel = new JPanel();
    panel.setBackground(Color.decode("#FAFAFA"));
    panel.setBorder(new LineBorder(Color.GRAY));
    panel.setLayout(new GridLayout());
    panel.setSize(300, 300);

    FontIcon fontIcon = FontIcon.of(icon);
    fontIcon.setIconSize(150);
    fontIcon.setIconColor(Color.decode(getRandomColor()));

    JLabel label = new JLabel();
    label.setIcon(fontIcon);
    panel.add(label);
    root.add(panel);
}
 
Example 14
Source Project: Game   Source File: PopupFrame.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void build() {
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setUndecorated(true);
	setPreferredSize(new Dimension(300, 150));
	setLayout(null);
	setResizable(false);

	getContentPane().setBackground(new Color(30, 30, 30));
	getRootPane().setBorder(new LineBorder(new Color(0, 0, 0), 1));

	msg = new JLabel(message);
	msg.setForeground(Color.WHITE);
	msg.setHorizontalAlignment(0);
	msg.setBounds(0, 45, 300, 25);
	msg.setFont(Utils.getFont("Helvetica.otf", 0, 12.0F));
	add(msg);

	ControlButton close = new ControlButton(3, 110, 100, 75, 25);
	close.setText("Close");
	close.setFocusable(false);
	close.setForeground(Color.WHITE);
	close.addActionListener(arg0 -> setVisible(false));
	add(close);
	addMouseListener();
	pack();
}
 
Example 15
@Override
public void addCustomEntriesToTable(UIDefaults table) {

    Border blackLineBorder =
            new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder =
            new BorderUIResource(new LineBorder(getWhite()));

    Object textBorder = new BorderUIResource(new CompoundBorder(
            blackLineBorder,
            new BasicBorders.MarginBorder()));

    table.put("ToolTip.border", blackLineBorder);
    table.put("TitledBorder.border", blackLineBorder);
    table.put("Table.focusCellHighlightBorder", whiteLineBorder);
    table.put("Table.focusCellForeground", getWhite());

    table.put("TextField.border", textBorder);
    table.put("PasswordField.border", textBorder);
    table.put("TextArea.border", textBorder);
    table.put("TextPane.font", textBorder);


}
 
Example 16
private void run() {
    JFrame frame = new JFrame("Test Character (no crash = PASS)");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JLabel label = new JLabel("(empty)");
    label.setSize(400, 100);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(new Font("Lucida Bright", Font.PLAIN, 12));
    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
       label.setText(Character.toString('\u0DDD'));
    } else {
    JButton button = new JButton("Set Char x0DDD");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
       label.setText(Character.toString('\u0DDD'));
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 17
private void initComponents()
{
    setBorder(new LineBorder(Colors.LIGHT_GRAY));
    setBackground(Colors.FONT_WHITE);

    setPreferredSize(new Dimension(ROOM_MEMBER_PANEL_WIDTH, MainFrame.getContext().currentWindowHeight));
    setVisible(false);
    listView.setScrollBarColor(Colors.SCROLL_BAR_THUMB, Colors.WINDOW_BACKGROUND);
    listView.setContentPanelBackground(Colors.FONT_WHITE);
    listView.getContentPanel().setBackground(Colors.FONT_WHITE);

    operationPanel.setPreferredSize(new Dimension(60, 80));
    operationPanel.setBackground(Colors.FONT_WHITE);


    leaveButton = new RCButton("退出群聊", Colors.WINDOW_BACKGROUND_LIGHT, Colors.WINDOW_BACKGROUND, Colors.SCROLL_BAR_TRACK_LIGHT);
    leaveButton.setForeground(Colors.RED);
    leaveButton.setPreferredSize(new Dimension(180, 30));

}
 
Example 18
private void initComponents()
{
    setPreferredSize(new Dimension(100, 70));
    setMaximumSize(new Dimension(100, 70));
    setBackground(Colors.FONT_WHITE);
    setBorder(new LineBorder(Colors.LIGHT_GRAY));

    icon = new JLabel();
    icon.setHorizontalAlignment(SwingConstants.CENTER);
    ImageIcon imageIcon = attachmentIconHelper.getImageIcon(path, 35, 35);
    icon.setIcon(imageIcon);


    text = new JLabel();
    text.setFont(FontUtil.getDefaultFont(12));
    text.setText(path.substring(path.lastIndexOf(File.separator) + 1));
    text.setHorizontalAlignment(SwingConstants.CENTER);
}
 
Example 19
Source Project: views-widgets-samples   Source File: AnimationPanel.java    License: Apache License 2.0 5 votes vote down vote up
AnimationPanel(CycleSetModel cycleModel, JButton play) {
  super(new FlowLayout(FlowLayout.LEFT));
  setBackground(new Color(0xF8F8F4));
  setBorder(new  LineBorder(new Color(0x888888),1));
  myCycleModel = cycleModel;
  myPlayButton = play;
  myPlayButton.addActionListener(e -> play());
}
 
Example 20
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
Example 21
private void run()  {
    Font ourFont = null;
    final String fontName = "UnBatangOdal.ttf";  // download from http://chem.skku.ac.kr/~wkpark/project/font/GSUB/UnbatangOdal/  and place in {user.home}/fonts/
    try {
        ourFont = Font.createFont(Font.TRUETYPE_FONT, new java.io.File(new java.io.File(System.getProperty("user.home"),"fonts"), fontName));
        ourFont = ourFont.deriveFont((float)48.0);
    } catch(Throwable t) {
        t.printStackTrace();
        System.err.println("Fail: " + t);
        return;
    }
    JFrame frame = new JFrame(System.getProperty("java.version"));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JTextArea label = new JTextArea("(empty)");
    label.setSize(400, 300);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(ourFont);
    final String str = "\u110A\u119E\u11B7\u0020\u1112\u119E\u11AB\uAE00\u0020\u1100\u119E\u11F9\u0020\u112B\u119E\u11BC\n";

    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
        label.setText(str);
    } else {
    JButton button = new JButton("Old Hangul");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            label.setText(str);
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 22
Source Project: ghidra   Source File: FcgVertex.java    License: Apache License 2.0 5 votes vote down vote up
private void buildVertexShape() {
	int w = VERTEX_SHAPE_SIZE;
	int h = VERTEX_SHAPE_SIZE;
	Double circle = new Ellipse2D.Double(0, 0, w, h);

	BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g2 = (Graphics2D) image.getGraphics();
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	FcgDirection direction = level.getDirection();
	if (direction.isSource()) {
		g2.setColor(getVertexShapeColor());
	}
	else if (direction.isIn()) {
		g2.setPaint(inPaint);
	}
	else {
		g2.setPaint(outPaint);
	}

	g2.fill(circle);

	g2.dispose();

	vertexShape = circle;
	compactShape = (Double) vertexShape.clone();
	vertexImageLabel.setIcon(new ImageIcon(image));

	Border border = createDebugBorder(new LineBorder(Color.PINK, 1));
	vertexImageLabel.setBorder(border);
}
 
Example 23
Source Project: ghidra   Source File: FcgVertex.java    License: Apache License 2.0 5 votes vote down vote up
private void addNameLabel() {

		Border border = createDebugBorder(new LineBorder(Color.GREEN, 1));
		nameLabel.setBorder(border);

		// assume the vertex label has been bounded
		Rectangle parentBounds = vertexImageLabel.getBounds();
		Dimension size = nameLabel.getPreferredSize();

		// bottom, centered under the shape
		int x = (parentBounds.x + (parentBounds.width / 2)) - (size.width / 2);
		int y = parentBounds.y + parentBounds.height + GAP;
		nameLabel.setBounds(x, y, size.width, size.height);
		layeredPane.add(nameLabel, LABEL_LAYER);
	}
 
Example 24
Source Project: arcusplatform   Source File: Table.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean stopCellEditing() {
   try {
      return super.stopCellEditing();
   }
   catch(Exception e) {
      JComponent c = (JComponent) getComponent();
      c.setBorder(new LineBorder(Color.RED));
      Oculus.warn("Invalid value for cell: " + e.getMessage() + "\nClick 'esc' to stop editing", e);
      return false;
   }
}
 
Example 25
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
Example 26
Source Project: TencentKona-8   Source File: TestOldHangul.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void run()  {
    Font ourFont = null;
    final String fontName = "UnBatangOdal.ttf";  // download from http://chem.skku.ac.kr/~wkpark/project/font/GSUB/UnbatangOdal/  and place in {user.home}/fonts/
    try {
        ourFont = Font.createFont(Font.TRUETYPE_FONT, new java.io.File(new java.io.File(System.getProperty("user.home"),"fonts"), fontName));
        ourFont = ourFont.deriveFont((float)48.0);
    } catch(Throwable t) {
        t.printStackTrace();
        System.err.println("Fail: " + t);
        return;
    }
    JFrame frame = new JFrame(System.getProperty("java.version"));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JTextArea label = new JTextArea("(empty)");
    label.setSize(400, 300);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(ourFont);
    final String str = "\u110A\u119E\u11B7\u0020\u1112\u119E\u11AB\uAE00\u0020\u1100\u119E\u11F9\u0020\u112B\u119E\u11BC\n";

    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
        label.setText(str);
    } else {
    JButton button = new JButton("Old Hangul");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            label.setText(str);
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 27
Source Project: jdk8u60   Source File: CompositionArea.java    License: GNU General Public License v2.0 5 votes vote down vote up
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
Example 28
Source Project: jdk8u60   Source File: TestOldHangul.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void run()  {
    Font ourFont = null;
    final String fontName = "UnBatangOdal.ttf";  // download from http://chem.skku.ac.kr/~wkpark/project/font/GSUB/UnbatangOdal/  and place in {user.home}/fonts/
    try {
        ourFont = Font.createFont(Font.TRUETYPE_FONT, new java.io.File(new java.io.File(System.getProperty("user.home"),"fonts"), fontName));
        ourFont = ourFont.deriveFont((float)48.0);
    } catch(Throwable t) {
        t.printStackTrace();
        System.err.println("Fail: " + t);
        return;
    }
    JFrame frame = new JFrame(System.getProperty("java.version"));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JTextArea label = new JTextArea("(empty)");
    label.setSize(400, 300);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(ourFont);
    final String str = "\u110A\u119E\u11B7\u0020\u1112\u119E\u11AB\uAE00\u0020\u1100\u119E\u11F9\u0020\u112B\u119E\u11BC\n";

    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
        label.setText(str);
    } else {
    JButton button = new JButton("Old Hangul");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            label.setText(str);
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 29
Source Project: nanoleaf-desktop   Source File: Main.java    License: MIT License 5 votes vote down vote up
private void initPanelCanvas() {
    canvas = new PanelCanvas(devices);
    canvas.setLayout(new GridBagLayout());
    canvas.setBorder(new TitledBorder(new LineBorder(Color.GRAY),
                                      "Preview", TitledBorder.LEFT, TitledBorder.TOP, null, Color.WHITE));
    ((javax.swing.border.TitledBorder) canvas.getBorder())
            .setTitleFont(new Font("Tahoma", Font.BOLD, 22));
    contentPane.add(canvas, "cell 1 1 1 2,grow");
}
 
Example 30
Source Project: nanoleaf-desktop   Source File: DiscoveryCellRenderer.java    License: MIT License 5 votes vote down vote up
public DiscoveryCellRenderer()
{
	setOpaque(true);
	setBorder(new CompoundBorder(
			new LineBorder(java.awt.Color.GRAY, 1),
			new EmptyBorder(0, 0, 10, 0)));
	setVerticalTextPosition(JLabel.BOTTOM);
	setHorizontalTextPosition(JLabel.CENTER);
	setIconTextGap(10);
	setFont(new Font("Tahoma", Font.PLAIN, 22));
	setForeground(java.awt.Color.WHITE);
}